[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fmessages\u002Ffavorites-count":3,"docs-tabs-chats\u002Fmessages\u002Ffavorites-count":6},{"content":4,"lastmod":5},"## Count favorite messages\n\n`GET \u002Fv1\u002Fchats\u002F:dialogId\u002Ffavorites\u002Fcount`\n\nReturns how many messages the current user has added to favorites in one chat, without loading the messages themselves.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `dialogId` (path) | string | yes | `chat` followed by the actual chat ID returned when you [load the chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload), including a one-to-one chat. The endpoint rejects a numeric user ID and `me`. |\n\nRequires the `im` scope. The credentials identify the current user. The API rejects parameters that specify the owner and any unknown parameters.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X GET \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat1945\u002Ffavorites\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\u002Fchat1945\u002Ffavorites\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\u002Fchat1945\u002Ffavorites\u002Fcount', {\n  method: 'GET',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n  },\n})\nconst { data } = await res.json()\nconsole.log(data)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat1945\u002Ffavorites\u002Fcount', {\n  method: 'GET',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n  },\n})\nconst { data } = await res.json()\nconsole.log(data)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `success` | boolean | `true` |\n| `data.counter` | number | Favorite message counter |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"counter\": 3\n  }\n}\n```\n\n## Error response example\n\n400 — unexpected parameter:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"Query parameter `ownerId` is not accepted by GET \u002Fv1\u002Fchats\u002F:dialogId\u002Ffavorites\u002Fcount. It takes no query parameters.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|------|-------------|\n| 400 | `INVALID_PARAMS` | Malformed ID, or an unexpected or repeated parameter or body field |\n| 422 | `BITRIX_ERROR` | `error.b24Code` is `ACCESS_ERROR` — the employee has no access to the chat, or there is no such chat |\n| 401 | `MISSING_API_KEY` | No API key was provided |\n| 401 | `TOKEN_MISSING` | No Bitrix24 credentials are configured |\n| 403 | `SCOPE_DENIED` | The key does not have im scope |\n| 403 | `BITRIX_ACCESS_DENIED` | The current user has no access |\n| 404 | `ENTITY_NOT_FOUND` | The record was not found |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused the operation with another code, which is in `error.b24Code` |\n\n[Common API errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [Chat configuration](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Fconfiguration)\n- [Messages](\u002Fdocs\u002Fchats\u002Fmessages)\n","2026-11-20",{},1795415435764]