For AI agents: markdown of this page — /docs-content-en/chats/management/folder-chats-delete.md documentation index — /llms.txt

Remove chats from a folder

DELETE /v1/chats/folders/:folderId/chats

Removes chats from the current user's personal folder. The chats and the folder themselves are not deleted.

The call is a write: a read-only key gets 403 WRITE_BLOCKED_READONLY_KEY before any call to Bitrix24.

Parameters

Parameter Type Required Description
folderId (path) number yes Personal folder ID — the id of a folder with type: "personal" from GET /v1/chats/folders
chatIds (query) string no Comma-separated chat IDs: chatIds=42,57. A chat ID is the chatId field of recent dialogs, each a positive integer
dialogIds (query) string no Comma-separated dialog IDs: dialogIds=chat42,7. chatXXX is the dialogId field of recent dialogs, a user ID comes from the user list. Each element is a non-empty string of up to 64 characters without surrounding spaces. The me alias is not accepted — pass the user ID

At least one ID in chatIds or dialogIds is required. The lists are passed only in the query. Any other query parameter, a repeated parameter or a body field is rejected with 400 INVALID_PARAMS.

Examples

curl — personal key

Terminal
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/folders/16/chats?chatIds=42&dialogIds=chat57" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/folders/16/chats?chatIds=42&dialogIds=chat57" \
  -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/chats/folders/16/chats?chatIds=42&dialogIds=chat57', {
  method: 'DELETE',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { success } = await res.json()

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/16/chats?chatIds=42&dialogIds=chat57', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success } = await res.json()

Response fields

Field Type Description
success boolean Always true on success
data.result boolean true — the write succeeded. The resulting folder contents — GET /v1/chats/folders/:folderId

Response example

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

Error response example

422 — there is no folder with this ID:

JSON
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "FOLDER_NOT_FOUND",
    "b24Code": "FOLDER_NOT_FOUND"
  }
}

Errors

HTTP Code Description
400 INVALID_PARAMS folderId is not a positive integer; neither chatIds nor dialogIds contains an ID; an invalid list element; an unknown or repeated query parameter; a body field was sent; the body is not a JSON object. Checked before any call to Bitrix24
404 ENTITY_NOT_FOUND Bitrix24 answered "not found"; the portal code is in error.b24Code
422 BITRIX_ERROR Bitrix24 returned an error; the portal code is in error.b24Code: FOLDER_NOT_FOUND — no such folder, FOLDER_ACCESS_DENIED — another user's folder, FOLDER_SYSTEM_MUTATION_FORBIDDEN — a system folder's contents cannot be changed
502 BITRIX_UNAVAILABLE Bitrix24 is unavailable or returned a server error
403 SCOPE_DENIED The API key does not have the im scope
403 WRITE_BLOCKED_READONLY_KEY The key is read-only — the call changes folder contents
401 TOKEN_MISSING The API key has no Bitrix24 tokens configured

Full list of common API errors — Errors.

Known specifics

  • A chat that is not in the folder is skipped. The response is successful even when none of the passed chats was in the folder.
  • A user ID in dialogIds does not create a direct dialog, unlike adding chats to a folder.
  • dialogIds requires the im 26.1000.0 update or later. Cloud Bitrix24 already has it. A self-hosted Bitrix24 without it silently ignores dialogIds, so a request with only dialogIds succeeds without changing anything. On such an installation, pass chatIds.

See also