For AI agents: markdown of this page — /docs-content-en/chats/management/folder-chats.md documentation index — /llms.txt
Folder contents
POST /v1/chats/folders/:folderId/chats
DELETE /v1/chats/folders/:folderId/chats
PUT /v1/chats/:dialogId/folders
Sorts chats into the current user's personal folders — from both sides:
POST /v1/chats/folders/:folderId/chatsadds chats to a folder — the v2 messenger methodim.v2.Folder.addChats.DELETE /v1/chats/folders/:folderId/chatsremoves chats from a folder — the methodim.v2.Folder.deleteChats.PUT /v1/chats/:dialogId/folderssets the full set of personal folders of one chat — the methodim.v2.Folder.setChatFolders.
Do not confuse with GET /v1/chats/:chatId/folder — that is the chat's Drive folder, not a chat-list folder.
All three calls are writes: a read-only key gets 403 WRITE_BLOCKED_READONLY_KEY before any call to Bitrix24. To create a folder and replace its contents as a whole, see Chat folders: create and edit.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
folderId (path) |
number | yes | — | Personal folder ID. For POST and DELETE |
dialogId (path) |
string | yes | — | Dialog ID for PUT: chatXXX for a group chat, a user ID for a direct dialog, or the me alias |
chatIds (body — POST; query — DELETE) |
number[] | no | — | Chat IDs. In the query — comma-separated: chatIds=42,57 |
dialogIds (body — POST; query — DELETE) |
string[] | no | — | Dialog IDs: chatXXX or a user ID. In the query — comma-separated: dialogIds=chat42,7 |
folderIds (body — PUT) |
number[] | yes | — | IDs of the personal folders the chat should end up in. [] removes the chat from all personal folders |
POST and DELETE require at least one ID in chatIds or dialogIds. For DELETE the lists are passed only in the query: the body of a DELETE is not read.
Each element of chatIds and folderIds is a positive integer: a number or a string of digits. An element of dialogIds is a non-empty string of up to 64 characters without commas. The me alias is not accepted in the lists — pass the user ID. Any other query parameter or body field is rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
# Add two chats to folder 16
curl -X POST "https://vibecode.bitrix24.com/v1/chats/folders/16/chats" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"chatIds": [42], "dialogIds": ["chat57"]}'
# Remove a chat from folder 16
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/folders/16/chats?chatIds=42" \
-H "X-Api-Key: YOUR_API_KEY"
# Chat chat42 — only in folders 15 and 16
curl -X PUT "https://vibecode.bitrix24.com/v1/chats/chat42/folders" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"folderIds": [15, 16]}'
curl — OAuth application
curl -X POST "https://vibecode.bitrix24.com/v1/chats/folders/16/chats" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"chatIds": [42]}'
JavaScript — personal key
// Remove a chat from all personal folders
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/folders', {
method: 'PUT',
headers: { 'X-Api-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ folderIds: [] }),
})
const { success } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/16/chats?dialogIds=chat42,7', {
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
{
"success": true,
"data": {
"result": true
}
}
Error response example
400 — PUT without folderIds:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "`folderIds` is missing: pass the full list of the personal folders of the chat (`[]` takes it out of all of them)."
}
}
422 — the chat cannot be put into a folder:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "This chat cannot be added to the folder.",
"b24Code": "FOLDER_CHAT_NOT_ELIGIBLE"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
folderId is not a positive integer; no ID at all for POST and DELETE; no folderIds for PUT; an invalid list element; an unknown or repeated query parameter, an unknown body field; the body is not a JSON object. Checked before any call to Bitrix24 |
| 403 | SCOPE_DENIED |
The API key does not have the im scope |
| 403 | WRITE_BLOCKED_READONLY_KEY |
The key is read-only — all three calls change folder contents |
| 401 | TOKEN_MISSING |
The API key has no Bitrix24 tokens configured |
| 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, FOLDER_CHATS_LIMIT_EXCEEDED — the folder would hold more than 50 chats, FOLDER_CHAT_NOT_ELIGIBLE — the chat cannot be put into a folder |
| 502 | ME_ALIAS_RESOLUTION_FAILED |
PUT: failed to resolve the user when using the me alias |
| 502 | BITRIX_UNAVAILABLE |
Bitrix24 is unavailable or returned a server error |
Full list of common API errors — Errors.
Known specifics
PUTsets the full set. The chat ends up exactly in the listed personal folders and disappears from the others. That is whyfolderIdsis required: without it Bitrix24 would remove the chat from all folders. Bitrix24 silently skips IDs of system folders and of other users' folders.PUTcan make the key owner a chat member. If the chat allows auto-join — for example, a comment chat, a collab or a task chat — the call adds the key owner as a member, as opening the chat in the Bitrix24 interface does.- A user ID in
dialogIdsforPOSTcreates a direct dialog if there is none yet.DELETEcreates no dialog. dialogIdsrequires theim 26.1000.0update or later. Cloud Bitrix24 already has it. A self-hosted Bitrix24 without it silently ignoresdialogIds, so aPOSTorDELETEwith onlydialogIdssucceeds without changing anything. On such an installation, passchatIds.- Bitrix24 checks whether a chat can be put into a folder: the user must be a chat member, and the chat itself must be of a suitable type. The refusal arrives with the code
FOLDER_CHAT_NOT_ELIGIBLE; the response does not say which IDs were refused. POSTandDELETEwithout a single ID are rejected with400: Bitrix24 would answer with success and change nothing.