[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmanagement\u002Ffolder-chats":3,"docs-tabs-chats\u002Fmanagement\u002Ffolder-chats":6},{"content":4,"lastmod":5},"## Add chats to a folder\n\n`POST \u002Fv1\u002Fchats\u002Ffolders\u002F:folderId\u002Fchats`\n\nAdds chats to the current user's personal folder by chat IDs or dialog IDs.\n\nThe call is a write: a read-only key gets `403 WRITE_BLOCKED_READONLY_KEY` before any call to Bitrix24. To create a folder, see [Create a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-create). To replace its contents as a whole, see [Update a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-update).\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `folderId` (path) | number | yes | Personal folder ID — the `id` of a folder with `type: \"personal\"` from [`GET \u002Fv1\u002Fchats\u002Ffolders`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders) |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `chatIds` | number[] | no | Chat IDs — the `chatId` field of [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent). Each element is a positive integer: a number or a string of digits without leading zeros |\n| `dialogIds` | string[] | no | Dialog IDs: `chatXXX` for a group chat — the `dialogId` field of [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent), or a user ID for a direct dialog — from the [user list](\u002Fdocs\u002Fentities\u002Fusers\u002Flist). Each element is a non-empty string of up to 64 characters without commas or surrounding spaces. The `me` alias is not accepted — pass the user ID |\n\nAt least one ID in `chatIds` or `dialogIds` is required. There 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 POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002F16\u002Fchats\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"chatIds\": [42], \"dialogIds\": [\"chat57\"]}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002F16\u002Fchats\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"chatIds\": [42], \"dialogIds\": [\"chat57\"]}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\u002F16\u002Fchats', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ chatIds: [42], dialogIds: ['chat57'] }),\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\u002Ffolders\u002F16\u002Fchats', {\n  method: 'POST',\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({ chatIds: [42], dialogIds: ['chat57'] }),\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\n422 — chats cannot be added to a system folder:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"FOLDER_SYSTEM_MUTATION_FORBIDDEN\",\n    \"b24Code\": \"FOLDER_SYSTEM_MUTATION_FORBIDDEN\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `folderId` is not a positive integer; neither `chatIds` nor `dialogIds` contains an ID; a list is not an array or has an invalid element; a query parameter or an unknown body field was sent; the body is not a JSON object. Checked before any call to Bitrix24 |\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_NOT_FOUND` — no such folder, `FOLDER_ACCESS_DENIED` — another user's folder, `FOLDER_SYSTEM_MUTATION_FORBIDDEN` — a system folder's contents cannot be changed, `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. The response does not say which ID was refused |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |\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| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **Adding a chat again does not duplicate it.** Adding a chat that is already in the folder, or passing an ID twice or in both `chatIds` and `dialogIds`, returns success, and the folder still holds the chat only once.\n- **A user ID in `dialogIds` creates a direct dialog** if there is none yet.\n- **`dialogIds` requires the `im 26.1000.0` update or later.** Cloud Bitrix24 already has it. A self-hosted Bitrix24 without it silently ignores `dialogIds`, so a request with only `dialogIds` succeeds without changing anything. On such an installation, pass `chatIds`.\n\n## See also\n\n- [Remove chats from a folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-chats-delete)\n- [Set the folders of a chat](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-chats-set)\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-10-05",{},1794739539400]