[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmembers\u002Fadd":3,"docs-tabs-chats\u002Fmembers\u002Fadd":6},{"content":4,"lastmod":5},"\n## Add members\n\n`POST \u002Fv1\u002Fchats\u002F:chatId\u002Fusers`\n\nAdds one or more users to a group chat.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `chatId` (path) | number | yes | Numeric chat ID (without the `chat` prefix) |\n| `format` (query) | string | no | `v2` turns on the v2 mode — see \"The v2 mode\" below. Any other value is ignored and the response is unchanged. A repeated `format` is not rejected: with `format=v1&format=v2` the last value wins, so the v2 mode is on, while `format=v2&format=v1` returns the legacy response. The bracket form `format[]=v2` turns on the v2 mode when all its values are `v2` |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `users` | number[] | yes | Non-empty array of user IDs to add. Each element is a positive integer: a number, or a string of decimal digits without leading zeros or spaces, up to 2^53−1; any other shape is refused before Bitrix24 is called |\n| `hideHistory` | boolean | no | `true` — new members do not see the history from before they joined, default `true`. `false` — the history is open from the moment the chat was created |\n\n**The v2 mode.** `format=v2` adds the members through the v2 messenger with the same body. Only `users` — at most 50 IDs per request — and `hideHistory` are accepted: the Bitrix24 spellings `USERS` and `HIDE_HISTORY`, other body fields and query parameters are rejected with `400 INVALID_PARAMS`, and `hideHistory` must be a boolean. The `hideHistory` default is the same — `true`. `data` carries `{ \"result\": true }` instead of `true`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F123\u002Fusers\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{ \"users\": [42, 53] }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F123\u002Fusers\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{ \"users\": [42, 53] }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F123\u002Fusers', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ users: [42, 53] }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Added:', data)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F123\u002Fusers', {\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({ users: [42, 53] }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### curl — the v2 mode\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F123\u002Fusers?format=v2\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{ \"users\": [42, 53], \"hideHistory\": false }'\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data` | boolean | `true` when added successfully |\n| `data.result` | boolean | The v2 mode: `true` — the request was carried out |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": true\n}\n```\n\n## Error response example\n\n403 — the API key does not have the `im` scope:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"SCOPE_DENIED\",\n    \"message\": \"This endpoint requires 'im' scope\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_CHAT_ID` | `chatId` is not a positive integer — checked before the Bitrix24 call |\n| 400 | `MISSING_PARAMS` | The `users` field is absent or the array is empty (including a request without a body at all) |\n| 400 | `INVALID_PARAMS` | `users` is not an array, or one of its elements is not a positive integer in canonical form (the index and type are named in `message`; `\"047\"`, `\" 47\"` and values above 2^53−1 are refused). In the v2 mode also `users` longer than 50, a query parameter other than `format`, a body field other than `users` and `hideHistory`, a `hideHistory` that is not a boolean, a body that is not a JSON object. Nothing was sent to Bitrix24 |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](\u002Fdocs\u002Faccess-rights) |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 401 | `TOKEN_MISSING` | The API key has no configured Bitrix24 tokens |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error — the text is in the `message` field (for example, chat not found or no permission). The Bitrix24 code is in `error.b24Code`. Without `format`, adding members to a collab chat returns this error with `ACCESS_ERROR` and the text `It is forbidden to add users to this chat`. In the v2 mode the member is added |\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**Numeric IDs only.** Bitrix24 casts each element of `users` to a number by PHP rules: a word becomes `0` and is silently skipped with an \"added\" response, and a nested array crashes Bitrix24. To keep a typo from looking like a success, the API checks the elements itself: it accepts a number or a string of decimal digits without leading zeros or spaces, and returns `400 INVALID_PARAMS` for anything else.\n\n**Nonexistent users are skipped.** If the `users` array contains IDs of nonexistent or inactive users, they are ignored without an error. The remaining users are added.\n\n**CoPilot joins a workgroup chat along with a new member.** When you add a member in the v2 mode to the chat of a group created with [`POST \u002Fv1\u002Fworkgroups`](\u002Fdocs\u002Fentities\u002Fworkgroups\u002Fcreate), the CoPilot system bot with `bot: true` also appears among the members. If you remove the bot, it comes back when the next member is added to the chat. This does not happen in a group chat created with [`POST \u002Fv1\u002Fchats`](\u002Fdocs\u002Fchats\u002Fmanagement\u002Fcreate).\n\n**History is hidden by default.** When adding without an explicit `hideHistory`, new members do not see messages sent before they joined. To give new members access to the history from when the chat was created, pass `hideHistory: false`.\n\n## See also\n\n- [Chat members](\u002Fdocs\u002Fchats\u002Fmembers)\n- [List members](\u002Fdocs\u002Fchats\u002Fmembers\u002Flist)\n- [Remove a member](\u002Fdocs\u002Fchats\u002Fmembers\u002Fremove)\n- [Chat management](\u002Fdocs\u002Fchats\u002Fmanagement)\n- [Chats](\u002Fdocs\u002Fchats)\n","2026-10-31",{},1794739543575]