[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmessages\u002Flinks-count":3,"docs-tabs-chats\u002Fmessages\u002Flinks-count":6},{"content":4,"lastmod":5},"## Number of a chat's links\n\n`GET \u002Fv1\u002Fchats\u002F:chatId\u002Flinks\u002Fcounter`\n\nReturns how many links were sent in the chat's messages, without loading the links themselves.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `chatId` (path) | number | yes | Chat ID. Get it from [`GET \u002Fv1\u002Fchats\u002Frecent`](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) |\n\nNo body and no query parameters are accepted: any body field or query parameter is rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F1001\u002Flinks\u002Fcounter\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F1001\u002Flinks\u002Fcounter\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\"\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F1001\u002Flinks\u002Fcounter', {\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst { data } = await res.json()\nconsole.log('Links:', data.counter)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002F1001\u002Flinks\u002Fcounter', {\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\n\nconst { data } = await res.json()\nconsole.log('Links:', data.counter)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.counter` | number | Number of links in the chat |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"counter\": 2\n  }\n}\n```\n\n## Error response example\n\n400 — a query parameter was passed:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"Query parameter `limit` is not accepted by GET \u002Fv1\u002Fchats\u002F:chatId\u002Flinks\u002Fcounter. It takes no query parameters.\"\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 any call to Bitrix24 |\n| 400 | `INVALID_PARAMS` | A body field or query parameter was passed. 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| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned a generic \"not found\" error; the portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | `error.b24Code` is `ACCESS_ERROR` — the employee has no access to the chat, or there is no such chat |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Only the visible history is counted.** If the employee can see the chat history only from a certain point on, links before that point are not counted.\n\n## See also\n\n- [List a chat's links](\u002Fdocs\u002Fchats\u002Fmessages\u002Flinks)\n- [Remove a link from the list](\u002Fdocs\u002Fchats\u002Fmessages\u002Flinks-delete)\n- [Messages](\u002Fdocs\u002Fchats\u002Fmessages)\n","2026-11-20",{},1795415436973]