For AI agents: markdown of this page — /docs-content-en/chats/management/folders-order.md documentation index — /llms.txt
Reorder chat folders
PUT /v1/chats/folders/order
Saves the order of the current user's chat folders in the interface, both system and personal.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
folderIds |
number[] | yes | IDs of all the user's visible folders in the new order, both system and personal. Each element is a positive integer: a number or a string of digits. The folder ID is the id field in GET /v1/chats/folders |
There are no query parameters. Any query parameter or other body field is rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
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": [27, 29, 31, 33, 35, 37, 127]}'
curl — OAuth application
curl -X PUT "https://vibecode.bitrix24.com/v1/chats/folders/order" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"folderIds": [27, 29, 31, 33, 35, 37, 127]}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/order', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ folderIds: [27, 29, 31, 33, 35, 37, 127] }),
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/folders/order', {
method: 'PUT',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ folderIds: [27, 29, 31, 33, 35, 37, 127] }),
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.result |
boolean | true — the order is saved |
Response example
{
"success": true,
"data": {
"result": true
}
}
Error response example
422 — folderIds does not list all visible folders:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "FOLDER_SORT_INVALID",
"b24Code": "FOLDER_SORT_INVALID"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS |
folderIds is missing or not an array, an element is not a positive integer, a query parameter or an unknown body field is passed, or the body is not a JSON object. Checked before the Bitrix24 call |
| 422 | BITRIX_ERROR |
Bitrix24 returned an error; the Bitrix24 code is in error.b24Code. FOLDER_SORT_INVALID — the set of folderIds does not match the user's visible folders |
| 404 | ENTITY_NOT_FOUND |
Bitrix24 answered "not found"; the Bitrix24 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: reordering folders 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 |
Full list of common API errors — Errors.
Known specifics
- Take the set for
folderIdsfromGET /v1/chats/foldersright before the call. A folder created or deleted after the list was read makes the set stale, and the call returnsFOLDER_SORT_INVALID. - Bitrix24 recalculates the
sortvalues itself. After the call they may differ from the previous ones even when the folder order is the same.