[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmessages\u002Fpins-count":3,"docs-tabs-chats\u002Fmessages\u002Fpins-count":6},{"content":4,"lastmod":5},"## Number of pinned messages\n\n`GET \u002Fv1\u002Fchats\u002F:dialogId\u002Fpins\u002Fcount`\n\nReturns how many messages are pinned in the chat, without loading the pins themselves.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `dialogId` (path) | string | yes | Dialog ID: numeric user ID for personal messages, `chatXXX` for group chats — the `dialogId` field of a [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) row; a user ID comes from the [user list](\u002Fdocs\u002Fentities\u002Fusers\u002Flist). The special `me` alias refers to the current user's personal dialog (details in the [Chats overview](\u002Fdocs\u002Fchats)) |\n\nNo query parameters are accepted: any of them is rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X GET \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Fpins\u002Fcount\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\"\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X GET \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Fpins\u002Fcount\" \\\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\u002Fchat42\u002Fpins\u002Fcount', {\n  method: 'GET',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\n\nconst { data } = await res.json()\nconsole.log('Pinned:', data.counter)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat42\u002Fpins\u002Fcount', {\n  method: 'GET',\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('Pinned:', 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 pinned messages |\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:dialogId\u002Fpins\u002Fcount. It takes no query parameters.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | A query parameter was passed. Checked before any call to Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 reported \"not found\"; the portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the code is in `error.b24Code`, for example `CHAT_NOT_FOUND` — there is no such chat |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | Read-only mode: the existing chat was not confirmed within the bounded window of recent dialogs, or a creating or ambiguous alias was passed. The method that would create a chat is not sent to the Bitrix24 account |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The read in `READONLY` mode is not available to an application key, a management key or a key whose owner type is unconfirmed |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | The `me` alias could not be resolved: Bitrix24 returned no ID of the current user |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The request may make you a member.** When the chat allows auto-join, the call may add the current user as a member, as [loading a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) does. An ordinary employee's personal key in `READONLY` mode can perform this read. It does not mark messages read.\n\n**Only the visible history is counted.** If you can see the chat history only from a certain point on — for example, you were added later without access to older messages — pins before that point are not counted.\n\n## See also\n\n- [List pinned messages](\u002Fdocs\u002Fchats\u002Fmessages\u002Fpins)\n- [Pin a message](\u002Fdocs\u002Fchats\u002Fmessages\u002Fpins-create)\n- [Unpin a message](\u002Fdocs\u002Fchats\u002Fmessages\u002Fpins-delete)\n- [Messages](\u002Fdocs\u002Fchats\u002Fmessages)\n","2026-10-06",{},1795344021013]