# Server Blocklist

## List blocked accounts by server

`GET /api/v1/server/blocklist/accounts`

Authentication (security requirement alternatives):

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

- 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: admin

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"
  ```

- `subscriptionName` (query, string, optional)
  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

## Examples

### cURL

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

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/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/server/blocklist/accounts?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Block an account by server

`POST /api/v1/server/blocklist/accounts`

Authentication (security requirement alternatives):

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

- 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: admin

Request body: application/json

Type: object

- `accountName` (required)
  Type: string
  
  account to block, in the form `username@domain`
  
  Example:
  
  ```json
  "chocobozzz@example.org"
  ```

Responses:

- 200: successful operation

- 409: self-blocking forbidden

## Examples

### cURL

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

### JavaScript

```javascript
const body = `{
  "accountName": "chocobozzz@example.org"
}`;

const response = await fetch('https://peertube2.cpy.re/api/v1/server/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": "chocobozzz@example.org"
}'''

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


## Unblock an account by server

`DELETE /api/v1/server/blocklist/accounts/{accountName}`

Authentication (security requirement alternatives):

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

- 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: admin

Parameters:

- `accountName` (path, string, required) - account to unblock, in the form `username@domain`
  Type: string

Responses:

- 201: successful operation

- 404: account or account block does not exist

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/server/blocklist/accounts/string' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/blocklist/accounts/string', {
  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/server/blocklist/accounts/string',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## List blocked servers by server

`GET /api/v1/server/blocklist/servers`

Authentication (security requirement alternatives):

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

- 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: admin

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"
  ```

- `subscriptionName` (query, string, optional)
  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

## Examples

### cURL

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

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/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/server/blocklist/servers?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Block a server by server

`POST /api/v1/server/blocklist/servers`

Authentication (security requirement alternatives):

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

- 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: admin

Request body: application/json

Type: object

- `host` (required)
  Type: string, hostname
  
  server domain to block

Responses:

- 204: successful operation

- 409: self-blocking forbidden

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/server/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/server/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/server/blocklist/servers',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Unblock a server by server

`DELETE /api/v1/server/blocklist/servers/{host}`

Authentication (security requirement alternatives):

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

- 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: admin

Parameters:

- `host` (path, string, hostname, required) - server domain to unblock
  Type: string, hostname

Responses:

- 204: successful operation

- 404: server block does not exist

## Examples

### cURL

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

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/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/server/blocklist/servers/example.com',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## List server blocklist subscriptions

`GET /api/v1/server/blocklist/subscriptions`

Authentication (security requirement alternatives):

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

- 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: admin

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) - Plain text search, applied to various parts of the model depending on endpoint
  Type: string

Responses:

- 200: successful operation

Content type: application/json

Type: object

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

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

## Examples

### cURL

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

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/blocklist/subscriptions?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/server/blocklist/subscriptions?count=15',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Add a server blocklist subscription

`POST /api/v1/server/blocklist/subscriptions`

Authentication (security requirement alternatives):

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

- 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: admin

Request body: application/json

Type: object

- `url` (required)
  Type: string, url

Responses:

- 200: successful operation

Content type: application/json

Type: BlocklistSubscription

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

- `id` (optional)
  Reference: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md); Type: id
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

- `name` (optional)
  Type: string

- `url` (optional)
  Type: string, url

- `mutedAccountsCount` (optional)
  Type: integer
  
  minimum: 0

- `mutedServersCount` (optional)
  Type: integer
  
  minimum: 0

- `lastSyncAt` (optional)
  Type: string, date-time

- `createdAt` (optional)
  Type: string, date-time

- `updatedAt` (optional)
  Type: string, date-time

- 409: subscription already exists

## Examples

### cURL

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

### JavaScript

```javascript
const body = `{
  "url": "https://example.com"
}`;

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

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

### Python

```python
import requests

body = '''{
  "url": "https://example.com"
}'''

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


## Delete a server blocklist subscription

`DELETE /api/v1/server/blocklist/subscriptions/{id}`

Authentication (security requirement alternatives):

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

- 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: admin

Parameters:

- `id` (path, integer, required)
  Type: integer

Responses:

- 204: successful operation

- 404: subscription does not exist

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/server/blocklist/subscriptions/0' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/blocklist/subscriptions/0', {
  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/server/blocklist/subscriptions/0',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## List publicly shared server blocklist log entries

`GET /api/v1/server/blocklist/public-log`

Authentication: no security requirement declared for this operation.

Parameters:

- `startDate` (query, string, date-time, required)
  Type: string, date-time

Responses:

- 200: successful operation

Content type: application/json

Type: AutoMuteList

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

- `name` (optional)
  Type: string

- `actions` (optional)
  Type: Array<object>
  
  Items:
    Type: object
    
    - `type` (optional)
      Type: string
      
      enum: ["block","unblock"]
    
    - `target` (optional)
      Type: string
    
    - `createdAt` (optional)
      Type: string, date-time

- 403: public log is disabled

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/server/blocklist/public-log?startDate=2024-01-15T09%3A30%3A00Z'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/server/blocklist/public-log?startDate=2024-01-15T09%3A30%3A00Z', {
  method: 'GET',
});

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

### Python

```python
import requests

response = requests.get('https://peertube2.cpy.re/api/v1/server/blocklist/public-log?startDate=2024-01-15T09%3A30%3A00Z')
print(response.text)
```
