# Get instance audit logs

`GET /api/v1/server/audit-logs`

User, administration and moderation actions recorded by all the PeerTube processes of the instance.

By default (`format=array`), returns an array of at most the 10,000 most recent entries of the requested date range, oldest first.
`startDate` is then required and pagination parameters are ignored.

With `format=list`, returns a paginated list.


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:

- `format` (query, string, optional)
  Type: string
  
  default: "array"
  
  enum: ["array","list"]

- `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)
  Type: string
  
  enum: ["-createdAt","createdAt"]

- `search` (query, string, optional) - Search in usernames, IP addresses and audited entities
  Type: string

- `entityType` (query, AuditLogEntityType, optional)
  Type: AuditLogEntityType
  
  Schema: [AuditLogEntityType](https://sourcey-peertube.pages.dev/api-rest-reference/models/auditlogentitytype.md)
  
  enum: ["video","video-import","video-live","video-source","video-file","video-caption","video-chapters","video-password","video-embed-privacy","video-transcoding","video-transcription","video-studio-edition","video-player-settings","ownership-change","comment","channel","channel-sync","channel-videos-import","channel-collaborator","channel-player-settings","channel-playlists-order","playlist","playlist-element","playlist-elements-order","user","registration","password-reset","token-session","failed-login","scoped-token","user-export","user-import","abuse","abuse-message","video-block","account-block","server-block","blocklist-subscription","watched-words-list","watched-words-subscription","automatic-tag-policy","config","instance-image","instance-homepage","instance-host","plugin","follow","server-redundancy","video-redundancy","job-queue","job","runner","runner-registration-token","debug-command","storage-prune"]

- `entityId` (query, integer, optional)
  Type: integer

- `action` (query, AuditLogAction, optional)
  Type: AuditLogAction
  
  Schema: [AuditLogAction](https://sourcey-peertube.pages.dev/api-rest-reference/models/auditlogaction.md)
  
  enum: ["create","update","delete"]

- `startDate` (query, string, date-time, optional) - Required with the default `array` format
  Type: string, date-time

- `endDate` (query, string, date-time, optional)
  Type: string, date-time

Responses:

- 200: successful operation

Content type: application/json

Type: Array<AuditLog> | object

oneOf:
  Type: Array<AuditLog>
  
  Default `array` format
  
  Items:
    Reference: [AuditLog](https://sourcey-peertube.pages.dev/api-rest-reference/models/auditlog.md); Type: AuditLog

  Type: object
  
  `list` format
  
  - `total` (optional)
    Type: integer
    
    Example:
    
    ```json
    1
    ```
  
  - `data` (optional)
    Type: Array<AuditLog>
    
    Items:
      Reference: [AuditLog](https://sourcey-peertube.pages.dev/api-rest-reference/models/auditlog.md); Type: AuditLog

- 403: audit log is disabled

## Examples

### cURL

```bash
curl -X GET 'https://peertube2.cpy.re/api/v1/server/audit-logs?format=array&count=15' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

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