For AI agents: markdown of this page — /docs-content-en/chats/management/folders-update.md documentation index — /llms.txt
Update a chat folder
PATCH /v1/chats/folders/:folderId
Renames the current user's personal chat folder and replaces its contents.
To add or remove individual chats without passing the full contents, see Add chats to a folder and Remove chats from a folder.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
folderId (path) |
number | yes | Personal folder ID — the id field in GET /v1/chats/folders. A positive integer |
There are no query parameters: any query parameter is rejected with 400 INVALID_PARAMS.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | no | New folder name, 1 to 30 characters after trimming whitespace. A name outside these bounds is rejected with 422 BITRIX_ERROR, not 400 |
chatIds |
number[] | no | Chat IDs of the new contents. Each element is a positive integer: a number or a string of digits. The chat ID is the id field in recent dialogs |
dialogIds |
string[] | no | Dialog IDs of the new contents: chatXXX or a user ID for a direct dialog. An element is a non-empty string of up to 64 characters, with no commas and no leading or trailing whitespace. The me alias is not accepted — pass the user ID. The ID is the dialogId field in recent dialogs |
At least one of title, chatIds, dialogIds is required. The passed contents — the union of chatIds and dialogIds — replace the previous contents entirely. Empty contents — chatIds: [], dialogIds: [] or both — clear the folder. Any other body field is rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
curl -X PATCH "https://vibecode.bitrix24.com/v1/chats/folders/127" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Key clients", "chatIds": [5287]}'
curl — OAuth application
curl -X PATCH "https://vibecode.bitrix24.com/v1/chats/folders/127" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "Key clients", "chatIds": [5287]}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/127', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'Key clients', chatIds: [5287] }),
})
const { success, data } = await res.json()
console.log(data.folder.definition.chats)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/127', {
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'Key clients', chatIds: [5287] }),
})
const { success, data } = await res.json()
console.log(data.folder.definition.chats)
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.folder |
object | The folder after the update |
data.folder.id |
number | Folder ID |
data.folder.type |
string | Always personal |
data.folder.title |
string | Name |
data.folder.sort |
number | Folder order 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 | Folder contents after the update, a list of { chatId, dialogId } |
Response example
{
"success": true,
"data": {
"folder": {
"id": 127,
"type": "personal",
"title": "Key clients",
"sort": 12,
"visible": true,
"description": null,
"displaysNestedInRoot": false,
"definition": {
"chats": [{ "chatId": 5287, "dialogId": "chat5287" }]
}
}
}
}
Error response example
400 — no field passed:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "Nothing to change: pass `title`, `chatIds` or `dialogIds`."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
folderId is not a positive integer, no field passed, title is not a string, an invalid chatIds or dialogIds element, a query parameter or an unknown body field is passed, or the body is not a JSON object. Checked before any call to Bitrix24 |
| 422 | BITRIX_ERROR |
Bitrix24 returned FOLDER_NOT_FOUND — the folder does not exist. The portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 returned FOLDER_ACCESS_DENIED — the folder belongs to another user. The portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 returned FOLDER_SYSTEM_MUTATION_FORBIDDEN — a system folder cannot be changed. The portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 returned FOLDER_CHATS_LIMIT_EXCEEDED — the contents exceed 50 chats. The portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 returned FOLDER_CHAT_NOT_ELIGIBLE — the contents include a chat that cannot be placed in a folder, for example a chat the user is not a member of. The portal code is in error.b24Code |
| 422 | BITRIX_ERROR |
Bitrix24 returned title — the name is empty after trimming whitespace or longer than 30 characters. The portal code is in error.b24Code |
| 404 | ENTITY_NOT_FOUND |
Bitrix24 returned "not found". The portal code is in error.b24Code |
| 403 | SCOPE_DENIED |
The API key does not have the im scope |
| 403 | WRITE_BLOCKED_READONLY_KEY |
Read-only key: updating a folder is a write, see access rights |
| 401 | TOKEN_MISSING |
The API key has no Bitrix24 tokens configured |
| 502 | BITRIX_UNAVAILABLE |
Bitrix24 is unavailable or returned a server error |
For the full list of common API errors, see Errors.
Known specifics
- One ineligible chat rejects the whole contents. If the user is not a member of at least one chat in
chatIdsordialogIds, the call returnsFOLDER_CHAT_NOT_ELIGIBLEand the previous contents remain, even when the other chats are eligible. - A user ID in
dialogIdscreates a direct dialog. If there is no direct chat with the user yet, the call creates it and places it in the folder. dialogIdsworks starting with theim 26.1000.0update. Cloud Bitrix24 already has it installed. On-premise Bitrix24 without this update skipsdialogIdsand returns no error: a call with onlydialogIdsdoes not change the contents. On such an installation, passchatIds.FOLDER_NOT_FOUNDarrives inerror.b24Codeof a422 BITRIX_ERRORresponse. Do not confuse it with the404 FOLDER_NOT_FOUNDon Upload a file to a chat.