# Account Blocklist

## Get block status of accounts/hosts

`GET /api/v1/blocklist/status`

Authentication: no security requirement declared for this operation.

Parameters:

- `accounts` (query, Array<string>, optional) - Check if these accounts are blocked
  Type: Array<string>
  
  Items:
    Type: string

- `hosts` (query, Array<string>, optional) - Check if these hosts are blocked
  Type: Array<string>
  
  Items:
    Type: string

Responses:

- 200: successful operation

Content type: application/json

Type: BlockStatus

Schema: [BlockStatus](https://docs.joinpeertube.org/api-rest-reference/api/models/blockstatus.md)

- `accounts` (optional)
  Type: object
  
  Additional properties: 
    Type: object
    
    - `blockedByServer` (optional)
      Type: boolean
    
    - `blockedByServerSubscription` (optional)
      Type: string
    
    - `blockedByUser` (optional)
      Type: boolean

- `hosts` (optional)
  Type: object
  
  Additional properties: 
    Type: object
    
    - `blockedByServer` (optional)
      Type: boolean
    
    - `blockedByServerSubscription` (optional)
      Type: string
    
    - `blockedByUser` (optional)
      Type: boolean

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/blocklist/status?accounts=goofy%40example.com&accounts=donald%40example.com&hosts=example.com'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/blocklist/status?accounts=goofy%40example.com&accounts=donald%40example.com&hosts=example.com', {
  method: 'GET',
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get('https://peertube2.cpy.re/api/v1/blocklist/status?accounts=goofy%40example.com&accounts=donald%40example.com&hosts=example.com')
print(response.text)
```


## List accounts blocked by my account

`GET /api/v1/users/me/blocklist/accounts`

Get the list of accounts that the authenticated user has blocked

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "user"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: user

Parameters:

- `start` (query, integer, optional) - Offset used to paginate results
  Type: integer
  
  minimum: 0

- `count` (query, integer, optional) - Number of items to return
  Type: integer
  
  default: 15
  
  minimum: 1
  
  maximum: 100

- `sort` (query, string, optional) - Sort column
  Type: string
  
  Example:
  
  ```json
  "-createdAt"
  ```

- `search` (query, string, optional) - Search query string
  Type: string

Responses:

- 200: successful operation

Content type: application/json

Type: object

- `total` (optional)
  Type: integer
  
  Example:
  
  ```json
  1
  ```

- `data` (optional)
  Type: Array<AccountBlock>
  
  Items:
    Reference: [AccountBlock](https://docs.joinpeertube.org/api-rest-reference/api/models/accountblock.md); Type: AccountBlock

- 401: authentication required

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts?count=15' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts?count=15', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Block an account by my account

`POST /api/v1/users/me/blocklist/accounts`

Add an account to the authenticated user's blocklist

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "user"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: user

Request body: application/json (required)

Type: object

- `accountName` (required)
  Type: string
  
  Account name to block (format: name@host)
  
  Example:
  
  ```json
  "user@example.com"
  ```

Responses:

- 204: successful operation - account blocked

- 400: invalid account name

- 401: authentication required

- 404: account not found

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "accountName": "user@example.com"
}'
```

### JavaScript

```javascript
const body = `{
  "accountName": "user@example.com"
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "accountName": "user@example.com"
}'''

response = requests.post(
    'https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Unblock an account by my account

`DELETE /api/v1/users/me/blocklist/accounts/{accountName}`

Remove an account from the authenticated user's blocklist

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "user"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: user

Parameters:

- `accountName` (path, string, required) - Account name to unblock (format: name@host)
  Type: string
  
  Example:
  
  ```json
  "user@example.com"
  ```

Responses:

- 204: successful operation - account unblocked

- 400: invalid account name

- 401: authentication required

- 404: account block not found

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts/user%40example.com' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts/user%40example.com', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.delete(
    'https://peertube2.cpy.re/api/v1/users/me/blocklist/accounts/user%40example.com',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## List servers blocked by my account

`GET /api/v1/users/me/blocklist/servers`

Get the list of servers that the authenticated user has blocked

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "user"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: user

Parameters:

- `start` (query, integer, optional) - Offset used to paginate results
  Type: integer
  
  minimum: 0

- `count` (query, integer, optional) - Number of items to return
  Type: integer
  
  default: 15
  
  minimum: 1
  
  maximum: 100

- `sort` (query, string, optional) - Sort column
  Type: string
  
  Example:
  
  ```json
  "-createdAt"
  ```

- `search` (query, string, optional) - Search query string
  Type: string

Responses:

- 200: successful operation

Content type: application/json

Type: object

- `total` (optional)
  Type: integer
  
  Example:
  
  ```json
  1
  ```

- `data` (optional)
  Type: Array<ServerBlock>
  
  Items:
    Reference: [ServerBlock](https://docs.joinpeertube.org/api-rest-reference/api/models/serverblock.md); Type: ServerBlock

- 401: authentication required

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/users/me/blocklist/servers?count=15' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/blocklist/servers?count=15', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://peertube2.cpy.re/api/v1/users/me/blocklist/servers?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Block a server by my account

`POST /api/v1/users/me/blocklist/servers`

Add a server to the authenticated user's blocklist

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "user"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: user

Request body: application/json (required)

Type: object

- `host` (required)
  Type: string
  
  Server host to block
  
  Example:
  
  ```json
  "example.com"
  ```

Responses:

- 204: successful operation - server blocked

- 400: invalid server host

- 401: authentication required

- 404: server not found

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/users/me/blocklist/servers' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "host": "example.com"
}'
```

### JavaScript

```javascript
const body = `{
  "host": "example.com"
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/blocklist/servers', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "host": "example.com"
}'''

response = requests.post(
    'https://peertube2.cpy.re/api/v1/users/me/blocklist/servers',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Unblock a server by my account

`DELETE /api/v1/users/me/blocklist/servers/{host}`

Remove a server from the authenticated user's blocklist

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "user"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: user

Parameters:

- `host` (path, string, required) - Server host to unblock
  Type: string
  
  Example:
  
  ```json
  "example.com"
  ```

Responses:

- 204: successful operation - server unblocked

- 400: invalid server host

- 401: authentication required

- 404: server block not found

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/users/me/blocklist/servers/example.com' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/users/me/blocklist/servers/example.com', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.delete(
    'https://peertube2.cpy.re/api/v1/users/me/blocklist/servers/example.com',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```
