# 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


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://sourcey-peertube.pages.dev/api-rest-reference/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://sourcey-peertube.pages.dev/api-rest-reference/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://sourcey-peertube.pages.dev/api-rest-reference/models/id.md); Type: id
      
      minimum: 1
      
      Example:
      
      ```json
      42
      ```

- `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://sourcey-peertube.pages.dev/api-rest-reference/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": {},
  "account": {
    "id": 0
  }
}'
```

### JavaScript

```javascript
const body = `{
  "reason": "string",
  "predefinedReasons": [
    "violentOrAbusive"
  ],
  "video": {
    "startAt": 0,
    "endAt": 0
  },
  "comment": {},
  "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": {},
  "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)
```
