[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmanagement\u002Ffolder-chats-set":3,"docs-tabs-chats\u002Fmanagement\u002Ffolder-chats-set":6},{"content":4,"lastmod":5},"## Set the folders of a chat\n\n`PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Ffolders`\n\nPuts a chat into exactly the listed personal folders of the current user: the chat is added to the listed folders and removed from the other personal folders.\n\nThe call is a write: a read-only key gets `403 WRITE_BLOCKED_READONLY_KEY` before any call to Bitrix24.\n\nDo not confuse with [`GET \u002Fv1\u002Fchats\u002F:chatId\u002Ffolder`](\u002Fdocs\u002Fchats\u002Ffiles\u002Ffolder) — that is the chat's Drive folder, not a chat-list folder.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `dialogId` (path) | string | yes | Dialog ID: `chatXXX` for a group chat — the `dialogId` field of [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent), a user ID for a direct dialog — from the [user list](\u002Fdocs\u002Fentities\u002Fusers\u002Flist), or the `me` alias |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `folderIds` | (number \\| string)[] | yes | IDs of the personal folders the chat should end up in — the `id` of folders with `type: \"personal\"` from [`GET \u002Fv1\u002Fchats\u002Ffolders`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders). Each element is a positive integer up to `9007199254740991`: a number or a string of decimal digits without leading zeros or spaces. `[]` removes the chat from all personal folders |\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\u002Fchat42\u002Ffolders\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"folderIds\": [15, 16]}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Ffolders\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"folderIds\": [15, 16]}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Ffolders', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ folderIds: [15, 16] }),\n})\n\nconst { success } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Ffolders', {\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: [15, 16] }),\n})\n\nconst { success } = 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 write succeeded. The resulting folder contents — [`GET \u002Fv1\u002Fchats\u002Ffolders\u002F:folderId`](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-get) |\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\n400 — `folderIds` is missing:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"`folderIds` is missing: pass the full list of the personal folders of the chat (`[]` takes it out of all of them).\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `folderIds` is missing, is not an array or has an element that does not match the format or limit in the parameter table. A query parameter or an unknown body field was sent, or the body is not a JSON object. Checked before any call to Bitrix24 |\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` | The key is read-only — the call changes folder contents |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered \"not found\"; the portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`: `FOLDER_CHATS_LIMIT_EXCEEDED` — the folder would hold more than 50 chats, `FOLDER_CHAT_NOT_ELIGIBLE` — the user is not a chat member or the chat type is not eligible, `CHAT_NOT_FOUND` — the chat does not exist on the portal |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user when using the `me` alias |\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- **IDs of system, other users' and non-existent folders are skipped without an error** — the response is successful, and the contents of those folders do not change.\n- **The call can 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.\n\n## See also\n\n- [Add chats to a folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-chats)\n- [Remove chats from a folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-chats-delete)\n- [Create a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-create)\n- [Update a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-update)\n- [Chat folders](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders)\n- [Folder chats](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolder-recent)\n","2026-11-20",{},1795415427480]