For AI agents: markdown of this page — /docs-content-en/chats/files/upload-discard.md documentation index — /llms.txt

Discard an uploaded file

POST /v1/chats/:chatId/files/uploads/discard

Asks Bitrix24 to delete a file from the chat folder. The true or false result is returned as is: the client decides whether it can treat the file as removed.

Parameters

Parameter Type Required Description
ParameterchatId (path) Typenumber Requiredyes DescriptionChat ID
ParameterfileId (body) Typenumber Requiredyes DescriptionPositive file ID

Requires the im scope and a write-enabled key. Other fields and query parameters are rejected with 400 INVALID_PARAMS.

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/chats/42/files/uploads/discard \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fileId":7701}'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/chats/42/files/uploads/discard \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fileId":7701}'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/42/files/uploads/discard', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"fileId": 7701}),
})
const { success, data, error } = await res.json()
console.log(success ? data : error)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/42/files/uploads/discard', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"fileId": 7701}),
})
const { success, data, error } = await res.json()
console.log(success ? data : error)

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue on success
Fielddata Typeboolean DescriptionThe Bitrix24 true or false value, unchanged

Response example

JSON
{
  "success": true,
  "data": true
}

Error response example

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "`fileId` must be a positive integer."
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionfileId is not a positive integer, or another body field or a query parameter was sent
HTTP400 CodeINVALID_CHAT_ID DescriptionchatId in the path is not a positive integer
HTTP401 CodeTOKEN_MISSING DescriptionNo Bitrix24 access tokens
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the im scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionNo access to the chat or file in Bitrix24
HTTP404 CodeENTITY_NOT_FOUND DescriptionFile or chat not found
HTTP422 CodeBITRIX_ERROR DescriptionOther Bitrix24 refusal
HTTP429 CodeQUEUE_TIMEOUT DescriptionBitrix24 request queue is busy

false is still a successful response, distinct from a refusal. A named Bitrix24 refusal can map to 400, 403, or 404; error.b24Code is not guaranteed. The platform does not retry after an unknown outcome.

Full list of common API errors — Errors.

See also