For AI agents: markdown of this page — /docs-content-en/chats/management/folders.md documentation index — /llms.txt
Chat folders: create and edit
POST /v1/chats/folders
GET /v1/chats/folders/:folderId
PATCH /v1/chats/folders/:folderId
DELETE /v1/chats/folders/:folderId
PUT /v1/chats/folders/order
Creates, reads, edits and deletes the current user's personal chat folders and sets the order of all their folders — the v2 messenger methods im.v2.Folder.add, im.v2.Folder.get, im.v2.Folder.update, im.v2.Folder.delete and im.v2.Folder.sort. The folder list with each folder's id and type is GET /v1/chats/folders; a folder's chats in the order of the recent dialog list are GET /v1/chats/folders/:folderId/recent. To add and remove individual chats, see Folder contents.
POST /v1/chats/folderscreates a personal folder and can fill it with chats right away.GET /v1/chats/folders/:folderIdreturns the folder with its chats and their users.PATCH /v1/chats/folders/:folderIdrenames a personal folder and replaces its contents.DELETE /v1/chats/folders/:folderIdpermanently deletes a personal folder together with its contents and pins. The chats themselves stay.PUT /v1/chats/folders/ordersets the order of the folders in the interface.
All calls except GET are writes: a read-only key gets 403 WRITE_BLOCKED_READONLY_KEY before any call to Bitrix24. System folders — the messenger's sections — cannot be created, renamed or deleted.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
folderId (path) |
number | yes | — | Folder ID from GET /v1/chats/folders. For GET, PATCH and DELETE |
title (body) |
string | POST — yes, PATCH — no |
— | Folder name, 1 to 30 characters after trimming spaces. Bitrix24 checks the length |
chatIds (body) |
number[] | no | — | Chat IDs. POST — the initial contents, PATCH — the full new contents |
dialogIds (body) |
string[] | no | — | Dialog IDs: chatXXX or a user ID for a direct dialog. Combined with chatIds |
folderIds (body) |
number[] | PUT …/order — yes |
— | IDs of all the user's visible folders, system and personal, in the new order |
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.
PATCH needs at least one of title, chatIds, dialogIds. Empty contents — chatIds: [], dialogIds: [] or both — clear the folder. There are no query parameters. Any other query parameter or body field is rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
# Create a folder with two chats
curl -X POST "https://vibecode.bitrix24.com/v1/chats/folders" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Clients", "chatIds": [42], "dialogIds": ["chat57"]}'
# Rename a folder
curl -X PATCH "https://vibecode.bitrix24.com/v1/chats/folders/16" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Key clients"}'
# Put a folder first
curl -X PUT "https://vibecode.bitrix24.com/v1/chats/folders/order" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"folderIds": [16, 1, 2, 4, 5, 6]}'
curl — OAuth application
curl "https://vibecode.bitrix24.com/v1/chats/folders/16" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const headers = { 'X-Api-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' }
const created = await fetch('https://vibecode.bitrix24.com/v1/chats/folders', {
method: 'POST',
headers,
body: JSON.stringify({ title: 'Clients', chatIds: [42] }),
}).then((r) => r.json())
const folderId = created.data.folder.id
// Clear the folder: empty contents
await fetch(`https://vibecode.bitrix24.com/v1/chats/folders/${folderId}`, {
method: 'PATCH',
headers,
body: JSON.stringify({ chatIds: [] }),
})
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/16', {
method: 'DELETE',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { success } = await res.json()
Response fields
POST and PATCH:
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.folder |
object | The folder after the write |
data.folder.id |
number | Folder ID |
data.folder.type |
string | Always personal |
data.folder.title |
string | Name |
data.folder.sort |
number | The folder's position in the interface |
data.folder.visible |
boolean | The folder is shown in the interface |
data.folder.description |
null | A personal folder has no description |
data.folder.displaysNestedInRoot |
boolean | Nested chats are also shown in the root list |
data.folder.definition.chats |
array | The folder's contents, a list of { chatId, dialogId } |
GET:
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.folder |
object | The folder — the same fields as for POST. For a system folder, definition describes the section, not the contents |
data.chats |
array | The folder's chats in the v2 messenger format: id, dialogId, name, type, role, permissions and other fields |
data.users |
array | Users of the folder's direct dialogs |
DELETE and PUT …/order:
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.result |
boolean | true — the write succeeded |
Response example
POST:
{
"success": true,
"data": {
"folder": {
"id": 16,
"type": "personal",
"title": "Clients",
"sort": 13,
"visible": true,
"description": null,
"displaysNestedInRoot": false,
"definition": { "chats": [{ "chatId": 42, "dialogId": "chat42" }] }
}
}
}
DELETE:
{
"success": true,
"data": {
"result": true
}
}
Error response example
400 — PATCH without fields:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "Nothing to change: pass `title`, `chatIds` or `dialogIds`."
}
}
422 — a name longer than 30 characters:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "String must not be longer than 30 characters.",
"b24Code": "title"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
folderId is not a positive integer; no title for POST or no folderIds for PUT …/order; PATCH without fields; an invalid list element; an unknown query parameter or 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 |
POST, PATCH, DELETE, PUT …/order: the key is read-only |
| 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 cannot be changed, FOLDER_LIMIT_EXCEEDED — the user already has 20 personal folders, FOLDER_CHATS_LIMIT_EXCEEDED — more than 50 chats in the contents, FOLDER_CHAT_NOT_ELIGIBLE — the chat cannot be put into a folder, FOLDER_SORT_INVALID — the folderIds set does not match the visible folders, title — an empty or too-long name |
| 502 | BITRIX_UNAVAILABLE |
Bitrix24 is unavailable or returned a server error |
Full list of common API errors — Errors.
Known specifics
- Empty contents clear the folder. Bitrix24 itself reads an empty list as "field not passed", so
PATCHsends Bitrix24 its clearing value instead. The contents you pass always replace the previous ones completely: to add or remove one chat, use Folder contents. - A user ID in
dialogIdscreates a direct dialog. If there is no direct chat with the user yet,POSTandPATCHcreate it and put it into the folder. dialogIdsrequires theim 26.1000.0update or later. Cloud Bitrix24 already has it. A self-hosted Bitrix24 without it silently ignoresdialogIds: aPOSTwith onlydialogIdscreates an empty folder, and aPATCHleaves the contents unchanged. On such an installation, passchatIds.- Bitrix24 removes a chat the user is no longer a member of. When the contents are written, such a chat silently drops out of the folder. Check
data.folder.definition.chatsin the response. PUT …/orderaccepts only the full set. Pass all visible folders, system and personal, otherwise Bitrix24 returnsFOLDER_SORT_INVALID. Bitrix24 recalculates thesortvalues itself, so after the call they may differ from the previous values even if the order is unchanged.GETonly reads: its argument is a folder, not a chat, so a read-only key can call it.- The limits are Bitrix24 rules: 20 personal folders, 50 chats in a folder, a name of up to 30 characters. Bitrix24 checks them, and the refusal code arrives in
error.b24Code. - The code
FOLDER_NOT_FOUNDarrives inerror.b24Codeof a422 BITRIX_ERRORresponse. Do not confuse it with404 FOLDER_NOT_FOUNDof the chat's Drive folder.