[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-openlines\u002Fsessions\u002Fopen":3,"docs-tabs-openlines\u002Fsessions\u002Fopen":6},{"content":4,"lastmod":5},"## Open a client chat\n\n`POST \u002Fv1\u002Fopenlines\u002Fsessions\u002Fopen`\n\nFinds an Open Channel chat by the client's code in the connector. The identifier of the found chat is needed to pick up the dialog and perform operator actions.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `userCode` | string | yes | The client's code in the connector, in the form `connector\\|lineId\\|externalChatId\\|userId`. Passed unchanged. Source: the `userCode` field in the [`POST \u002Fv1\u002Fopenlines\u002Fsessions\u002Fsearch`](\u002Fdocs\u002Fopenlines\u002Fsessions\u002Fsearch) response |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenlines\u002Fsessions\u002Fopen \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"userCode\": \"doccheck|59|cloud-chat-2|1575\"}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenlines\u002Fsessions\u002Fopen \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"userCode\": \"doccheck|59|cloud-chat-2|1575\"}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenlines\u002Fsessions\u002Fopen', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ userCode: 'doccheck|59|cloud-chat-2|1575' }),\n})\n\nconst { data } = await res.json()\nconsole.log('Chat ID:', data.chatId)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenlines\u002Fsessions\u002Fopen', {\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({ userCode: 'doccheck|59|cloud-chat-2|1575' }),\n})\n\nconst { data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|----------|\n| `success` | boolean | `true` on a successful response |\n| `data.chatId` | number | Open Channel chat identifier. See [Chat ID](\u002Fdocs\u002Fopenlines\u002Foperator#chat-id) |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"chatId\": 5255\n  }\n}\n```\n\n## Error response example\n\n400 — the client's code is missing:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"MISSING_REQUIRED_FIELDS\",\n    \"message\": \"userCode is required and must be a non-empty string\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|----------|\n| 400 | `MISSING_REQUIRED_FIELDS` | The `userCode` field is missing, is not a string, is empty or consists of whitespace |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The refusal text is in `message` |\n| 403 | `BITRIX_ACCESS_DENIED` | The employee the call runs as has no permission for the action, or there is no client with this `userCode`. Both causes return the same response |\n| 502 | `OPENLINE_OPERATOR_FAILED` | Bitrix24 did not return a chat identifier |\n| 403 | `SCOPE_DENIED` | The key has no `imopenlines` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. Finding a chat by the client's code requires a key with write access |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |\n| 401 | `INVALID_API_KEY` | The key is not recognized |\n| 401 | `TOKEN_MISSING` | A personal key has no access to the Bitrix24 portal, or an application key was sent without a session token in `Authorization` |\n| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or the connection to it broke before the response was complete |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **The call does not start a session.** For a dialog with a closed session, the method returns `chatId`, and the session stays closed. To pick up the dialog, use [`POST \u002Fv1\u002Fopenlines\u002Fsessions\u002Fstart`](\u002Fdocs\u002Fopenlines\u002Fsessions\u002Fstart).\n\n## See also\n\n- [Session search](\u002Fdocs\u002Fopenlines\u002Fsessions\u002Fsearch)\n- [Operator actions and my pause](\u002Fdocs\u002Fopenlines\u002Foperator)\n- [Open Channels](\u002Fdocs\u002Fopenlines)\n","2026-10-19",{},1795000567069]