# REST-API-Endpunkte zum Blockieren von Benutzern

Verwende die REST-API, um blockierte Benutzer\*innen zu verwalten.

## Informationen zum Blockieren von Benutzern

Wenn eine Anforderungs-URL keinen `{username}`-Parameter enthält, gilt die Antwort für den*die angemeldete*n Benutzer\*in (und Sie müssen [Authentifizierungsinformationen](/de/rest/authentication/authenticating-to-the-rest-api) mit Ihrer Anforderung übergeben). Zusätzliche private Informationen, z. B. ob ein Benutzer die zweistufige Authentifizierung aktiviert hat, werden bei der Authentifizierung über OAuth mit dem `user` Zugriffsbereich eingeschlossen.

> \[!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.

## List users blocked by the authenticated user

```
GET /user/blocks
```

List the users you've blocked on your personal account.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

* **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

### HTTP response status codes

* **200** - OK

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  https://api.github.com/user/blocks
```

**Response schema (Status: 200):**

Array of `Simple User`:

* `name`: string or null
* `email`: string or null
* `login`: required, string
* `id`: required, integer, format: int64
* `node_id`: required, string
* `avatar_url`: required, string, format: uri
* `gravatar_id`: required, string or null
* `url`: required, string, format: uri
* `html_url`: required, string, format: uri
* `followers_url`: required, string, format: uri
* `following_url`: required, string
* `gists_url`: required, string
* `starred_url`: required, string
* `subscriptions_url`: required, string, format: uri
* `organizations_url`: required, string, format: uri
* `repos_url`: required, string, format: uri
* `events_url`: required, string
* `received_events_url`: required, string, format: uri
* `type`: required, string
* `site_admin`: required, boolean
* `starred_at`: string
* `user_view_type`: string

## Check if a user is blocked by the authenticated user

```
GET /user/blocks/{username}
```

Returns a 204 if the given user is blocked by the authenticated user. Returns a 404 if the given user is not blocked by the authenticated user, or if the given user account has been identified as spam by GitHub.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`username`** (string) (required)
  The handle for the GitHub user account.

### HTTP response status codes

* **204** - If the user is blocked

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - If the user is not blocked

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  https://api.github.com/user/blocks/USERNAME
```

**Response schema (Status: 204):**

## Block a user

```
PUT /user/blocks/{username}
```

Blocks the given user and returns a 204. If the authenticated user cannot block the given user a 422 is returned.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`username`** (string) (required)
  The handle for the GitHub user account.

### HTTP response status codes

* **204** - No Content

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

* **422** - Validation failed, or the endpoint has been spammed.

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X PUT \
  https://api.github.com/user/blocks/USERNAME
```

**Response schema (Status: 204):**

## Unblock a user

```
DELETE /user/blocks/{username}
```

Unblocks the given user and returns a 204.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`username`** (string) (required)
  The handle for the GitHub user account.

### HTTP response status codes

* **204** - No Content

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X DELETE \
  https://api.github.com/user/blocks/USERNAME
```

**Response schema (Status: 204):**