## Delete file

`DELETE /v1/files/:id`

Moves the object to Bitrix24 trash. Use [restore](/docs/entities/files/restore) to recover it or [purge](/docs/entities/files/purge) to delete it permanently.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | File ID. A positive integer |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/files/3291" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/files/3291" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/files/3291', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

if (res.status === 204) {
  console.log('File moved to trash')
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/files/3291', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

if (res.status === 204) {
  console.log('File moved to trash')
}
```

## Response

On a successful move to trash, the response is HTTP status `204 No Content` with an empty body. The success indicator is the response code, not the body.

## Response example

```
HTTP/1.1 204 No Content
```

## Error response example

404 — file not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Could not find entity with id '99999999'."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | File with the given ID not found |
| 403 | `SCOPE_DENIED` | API key lacks the `disk` scope |
| 401 | `TOKEN_MISSING` | API key has no configured authorization tokens |
| 401 | `INVALID_API_KEY` | The key is not recognized — no such key exists on the platform |

Full list of common API errors — [Error codes](/docs/errors).

## Known specifics

Use restore to recover the object or purge to delete it permanently.

## See also

- [List files](/docs/entities/files/list)
- [Get file](/docs/entities/files/get)
- [Rename file](/docs/entities/files/update)
- [Upload file](/docs/entities/files/upload)

- [Restore](/docs/entities/files/restore)
- [Purge](/docs/entities/files/purge)
