For AI agents: markdown of this page — /docs-content-en/entities/files/delete.md documentation index — /llms.txt
Delete file
DELETE /v1/files/:id
Moves the object to Bitrix24 trash. Use restore to recover it or purge to delete it permanently.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id (path) |
number | yes | File ID. A positive integer |
Examples
curl — personal key
curl -X DELETE "https://vibecode.bitrix24.com/v1/files/3291" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
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
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
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:
{
"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.
Known specifics
Use restore to recover the object or purge to delete it permanently.