[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmanagement\u002Ffolders-create":3,"docs-tabs-chats\u002Fmanagement\u002Ffolders-create":6},{"content":4,"lastmod":5},"## Create a chat folder\n\n`POST \u002Fv1\u002Fchats\u002Ffolders`\n\nCreates a personal chat folder for the current user and can populate it with chats right away.\n\nTo list folders with their `id`, call [`GET \u002Fv1\u002Fchats\u002Ffolders`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders).\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `title` | string | yes | Folder name, 1 to 30 characters after trimming whitespace. A name outside these bounds is rejected with `422 BITRIX_ERROR`, not `400` |\n| `chatIds` | (number \\| string)[] | no | IDs of the chats in the initial contents. Each element is a positive integer up to `9007199254740991`: a number or a string of decimal digits without leading zeros or spaces. The chat ID is the `chatId` field in [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) |\n| `dialogIds` | string[] | no | Dialog IDs: `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](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) |\n\nThe folder contents are the union of `chatIds` and `dialogIds`. There are no query parameters. Any query parameter or any 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\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"title\": \"Clients\", \"chatIds\": [5287], \"dialogIds\": [\"chat5289\"]}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"title\": \"Clients\", \"chatIds\": [5287], \"dialogIds\": [\"chat5289\"]}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ title: 'Clients', chatIds: [5287], dialogIds: ['chat5289'] }),\n})\n\nconst { success, data } = await res.json()\nconst folderId = data.folder.id\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Ffolders', {\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({ title: 'Clients', chatIds: [5287], dialogIds: ['chat5289'] }),\n})\n\nconst { success, data } = await res.json()\nconst folderId = data.folder.id\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.folder` | object | The created folder |\n| `data.folder.id` | number | Folder ID |\n| `data.folder.type` | string | Always `personal` |\n| `data.folder.title` | string | Name |\n| `data.folder.sort` | number | Folder position in the interface |\n| `data.folder.visible` | boolean | The folder is shown in the interface |\n| `data.folder.description` | null | A personal folder has no description |\n| `data.folder.displaysNestedInRoot` | boolean | Nested chats are also shown in the root list |\n| `data.folder.definition.chats` | array | Folder contents, a list of `{ chatId, dialogId }` |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"folder\": {\n      \"id\": 127,\n      \"type\": \"personal\",\n      \"title\": \"Clients\",\n      \"sort\": 12,\n      \"visible\": true,\n      \"description\": null,\n      \"displaysNestedInRoot\": false,\n      \"definition\": {\n        \"chats\": [\n          { \"chatId\": 5287, \"dialogId\": \"chat5287\" },\n          { \"chatId\": 5289, \"dialogId\": \"chat5289\" }\n        ]\n      }\n    }\n  }\n}\n```\n\n## Error response example\n\n422 — the name is longer than 30 characters:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"The string length must not exceed 30 characters\",\n    \"b24Code\": \"title\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `title` is missing or is not a string, an element of `chatIds` or `dialogIds` is invalid, a query parameter or an unknown body field is passed, 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` | Read-only key: creating a folder is a write, see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned \"not found\"; the portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`: `title` — the name is empty after trimming whitespace or longer than 30 characters, `FOLDER_LIMIT_EXCEEDED` — the user already has 20 personal folders, `FOLDER_CHATS_LIMIT_EXCEEDED` — the contents exceed 50 chats, `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 |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |\n\nThe full list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **A user ID in `dialogIds` creates a direct dialog.** If there is no direct chat with the user yet, the call creates one and places it in the folder.\n- **`dialogIds` works starting with the `im 26.1000.0` update.** Cloud Bitrix24 already has it installed. On-premise Bitrix24 without this update skips `dialogIds` and returns no error: a call with only `dialogIds` creates an empty folder. On such an installation, pass `chatIds`.\n- **One ineligible chat rejects the whole contents.** If the user is not a member of one or more chats in `chatIds` or `dialogIds`, the call returns `FOLDER_CHAT_NOT_ELIGIBLE` and the folder is not created, even when the other chats are eligible.\n\n## See also\n\n- [Chat folders](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Ffolders)\n- [Get a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-get)\n- [Update a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-update)\n- [Delete a chat folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-delete)\n- [Reorder chat folders](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolders-order)\n- [Add chats to a folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-chats)\n- [Remove chats from a folder](\u002Fdocs\u002Fchats\u002Fmanagement\u002Ffolder-chats-delete)\n","2026-11-20",{},1795415427899]