[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmanagement\u002Ffolders-order":3,"docs-tabs-chats\u002Fmanagement\u002Ffolders-order":6},{"content":4,"lastmod":5},"## Reorder chat folders\n\n`PUT \u002Fv1\u002Fchats\u002Ffolders\u002Forder`\n\nSaves the order of the current user's chat folders in the interface, both system and personal.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `folderIds` | (number \\| string)[] | yes | IDs of all the user's visible folders in the new order, both system and personal. Each element is a positive integer up to `9007199254740991`: a number or a string of decimal digits without leading zeros or spaces. The folder ID is the `id` field in [`GET \u002Fv1\u002Fchats\u002Ffolders`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders) |\n\nThere are no query parameters. Any query parameter or other body field is rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002Forder\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"folderIds\": [27, 29, 31, 33, 35, 37, 127]}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002Forder\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"folderIds\": [27, 29, 31, 33, 35, 37, 127]}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002Forder', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ folderIds: [27, 29, 31, 33, 35, 37, 127] }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002Forder', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ folderIds: [27, 29, 31, 33, 35, 37, 127] }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the order is saved |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n422 — `folderIds` does not list all visible folders:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"FOLDER_SORT_INVALID\",\n    \"b24Code\": \"FOLDER_SORT_INVALID\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `folderIds` is missing or not an array, an element does not match the format or limit in the parameter table, a query parameter or an unknown body field is passed, or the body is not a JSON object. Checked before the Bitrix24 call |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | Read-only key: reordering folders is a write, see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered \"not found\"; the Bitrix24 code is in `error.b24Code` |\n| 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 |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **Take the set for `folderIds` from [`GET \u002Fv1\u002Fchats\u002Ffolders`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders) right before the call.** A folder created or deleted after the list was read makes the set stale, and the call returns `FOLDER_SORT_INVALID`.\n- **Bitrix24 recalculates the `sort` values itself.** After the call they may differ from the previous ones even when the folder order is the same.\n\n## See also\n\n- [Chat folders](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders)\n- [Create a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-create)\n- [Delete a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-delete)\n- [Sources of the \"All\" folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-sources)\n","2026-11-20",{},1795415428268]