# Abuses

Abuses deal with reports of local or remote videos/comments/accounts alike.


## List abuses

`GET /api/v1/abuses`

Authentication (security requirement alternatives):

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

- 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, moderator

Parameters:

- `id` (query, integer, optional) - only list the report with this id
  Type: integer

- `predefinedReason` (query, Array<string>, optional) - predefined reason the listed reports should contain
  Type: Array<string>
  
  Reason categories that help triage reports
  
  Schema: [PredefinedAbuseReasons](https://docs.joinpeertube.org/api-rest-reference/api/models/predefinedabusereasons.md)
  
  maxItems: 8
  
  Items:
    Type: string
    
    enum: ["violentOrAbusive","hatefulOrAbusive","spamOrMisleading","privacy","rights","serverRules","thumbnails","captions"]

- `search` (query, string, optional) - plain search that will match with video titles, reporter names and more
  Type: string

- `state` (query, AbuseStateSet, optional)
  Type: AbuseStateSet
  
  The abuse state (Pending = `1`, Rejected = `2`, Accepted = `3`)
  
  Schema: [AbuseStateSet](https://docs.joinpeertube.org/api-rest-reference/api/models/abusestateset.md)
  
  enum: [1,2,3]

- `searchReporter` (query, string, optional) - only list reports of a specific reporter
  Type: string

- `searchReportee` (query, string, optional) - only list reports of a specific reportee
  Type: string

- `searchVideo` (query, string, optional) - only list reports of a specific video
  Type: string

- `searchVideoChannel` (query, string, optional) - only list reports of a specific video channel
  Type: string

- `videoIs` (query, string, optional) - only list deleted or blocklisted videos
  Type: string
  
  enum: ["deleted","blacklisted"]

- `filter` (query, string, optional) - only list account, comment or video reports
  Type: string
  
  enum: ["video","comment","account"]

- `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 abuses by criteria
  Type: string
  
  enum: ["-id","-createdAt","-state"]

Responses:

- 200: successful operation

Content type: application/json

Type: object

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

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

## Examples

### cURL

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

### JavaScript

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


## Report an abuse

`POST /api/v1/abuses`

You cannot report a video that you own or on which you are a collaborator (video channel editor).


Authentication (security requirement alternatives):

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

- 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


Parameters:

- `x-peertube-video-password` (header, string, optional) - Required on password protected video
  Type: string

Request body: application/json (required)

Type: object

- `reason` (required)
  Type: string
  
  Reason why the user reports this video
  
  minLength: 2
  
  maxLength: 3000

- `predefinedReasons` (optional)
  Reference: [PredefinedAbuseReasons](https://docs.joinpeertube.org/api-rest-reference/api/models/predefinedabusereasons.md); Type: Array<string>
  
  Reason categories that help triage reports
  
  maxItems: 8

- `video` (optional)
  Type: object
  
  - `id` (optional)
    Type: id
    
    Video id to report
    
    allOf:
      Reference: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md); Type: id
      
      object id for the video
  
  - `startAt` (optional)
    Type: integer, seconds
    
    Timestamp in the video that marks the beginning of the report
    
    minimum: 0
  
  - `endAt` (optional)
    Type: integer, seconds
    
    Timestamp in the video that marks the ending of the report
    
    minimum: 0

- `comment` (optional)
  Type: object
  
  - `id` (optional)
    Type: id
    
    Comment id to report
    
    allOf:
      Reference: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md); Type: id
      
      minimum: 1
      
      Example:
      
      ```json
      42
      ```
  
  - `videoUUID` (optional)
    Type: string, uuid
    
    UUID of the video of the comment, required to report a comment of an unlisted video

- `account` (optional)
  Type: object
  
  - `id` (optional)
    Type: integer
    
    Account id to report

Responses:

- 200: successful operation

Content type: application/json

Type: object

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

- 400: incorrect request parameters

- 403: cannot report a video you own or that you collaborate on

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/abuses' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "reason": "string",
  "predefinedReasons": [
    "violentOrAbusive"
  ],
  "video": {
    "startAt": 0,
    "endAt": 0
  },
  "comment": {
    "videoUUID": "550e8400-e29b-41d4-a716-446655440000"
  },
  "account": {
    "id": 0
  }
}'
```

### JavaScript

```javascript
const body = `{
  "reason": "string",
  "predefinedReasons": [
    "violentOrAbusive"
  ],
  "video": {
    "startAt": 0,
    "endAt": 0
  },
  "comment": {
    "videoUUID": "550e8400-e29b-41d4-a716-446655440000"
  },
  "account": {
    "id": 0
  }
}`;

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

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

### Python

```python
import requests

body = '''{
  "reason": "string",
  "predefinedReasons": [
    "violentOrAbusive"
  ],
  "video": {
    "startAt": 0,
    "endAt": 0
  },
  "comment": {
    "videoUUID": "550e8400-e29b-41d4-a716-446655440000"
  },
  "account": {
    "id": 0
  }
}'''

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


## Update an abuse

`PUT /api/v1/abuses/{abuseId}`

Authentication (security requirement alternatives):

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

- 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, moderator

Parameters:

- `abuseId` (path, id, required) - Abuse id
  Type: id
  
  Schema: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md)
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

Request body: application/json

Type: object

- `state` (optional)
  Reference: [AbuseStateSet](https://docs.joinpeertube.org/api-rest-reference/api/models/abusestateset.md); Type: AbuseStateSet
  
  The abuse state (Pending = `1`, Rejected = `2`, Accepted = `3`)
  
  enum: [1,2,3]

- `moderationComment` (optional)
  Type: string
  
  Update the report comment visible only to the moderation team
  
  minLength: 2
  
  maxLength: 3000

Responses:

- 204: successful operation

- 404: abuse not found

## Examples

### cURL

```bash
curl -X PUT 'https://peertube2.cpy.re/api/v1/abuses/42' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "state": 1,
  "moderationComment": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "state": 1,
  "moderationComment": "string"
}`;

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

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

### Python

```python
import requests

body = '''{
  "state": 1,
  "moderationComment": "string"
}'''

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


## Delete an abuse

`DELETE /api/v1/abuses/{abuseId}`

Authentication (security requirement alternatives):

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

- 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, moderator

Parameters:

- `abuseId` (path, id, required) - Abuse id
  Type: id
  
  Schema: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md)
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

Responses:

- 204: successful operation

- 404: block not found

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/abuses/42' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

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


## List messages of an abuse

`GET /api/v1/abuses/{abuseId}/messages`

Authentication (security requirement alternatives):

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

- 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


Parameters:

- `abuseId` (path, id, required) - Abuse id
  Type: id
  
  Schema: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md)
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

Responses:

- 200: successful operation

Content type: application/json

Type: object

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

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

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/abuses/42/messages' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

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


## Add message to an abuse

`POST /api/v1/abuses/{abuseId}/messages`

Authentication (security requirement alternatives):

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

- 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


Parameters:

- `abuseId` (path, id, required) - Abuse id
  Type: id
  
  Schema: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md)
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

Request body: application/json (required)

Type: object

- `message` (required)
  Type: string
  
  Message to send
  
  minLength: 2
  
  maxLength: 3000

Responses:

- 200: successful operation

- 400: incorrect request parameters

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/abuses/42/messages' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "message": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "message": "string"
}`;

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

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

### Python

```python
import requests

body = '''{
  "message": "string"
}'''

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


## Delete an abuse message

`DELETE /api/v1/abuses/{abuseId}/messages/{abuseMessageId}`

Authentication (security requirement alternatives):

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

- 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


Parameters:

- `abuseId` (path, id, required) - Abuse id
  Type: id
  
  Schema: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md)
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

- `abuseMessageId` (path, id, required) - Abuse message id
  Type: id
  
  Schema: [id](https://docs.joinpeertube.org/api-rest-reference/api/models/id.md)
  
  minimum: 1
  
  Example:
  
  ```json
  42
  ```

Responses:

- 204: successful operation

## Examples

### cURL

```bash
curl -X DELETE 'https://peertube2.cpy.re/api/v1/abuses/42/messages/42' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

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