For AI agents: markdown of this page — /docs-content-en/chats/discovery/counters.md documentation index — /llms.txt

Unread counters

GET /v1/chats/counters

Returns the current user's unread message counters across all of their chats in one request. Use it to show unread-count badges in the chat list without reading the messages themselves.

Parameters

There are no parameters. Any query parameter is rejected with 400 INVALID_PARAMS.

Examples

curl — personal key

Terminal
curl "https://vibecode.bitrix24.com/v1/chats/counters" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl "https://vibecode.bitrix24.com/v1/chats/counters" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/counters', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
const unread = data.userCounters.filter((c) => c.counter > 0 && !c.isMuted)
console.log('Chats with unread messages:', unread.length)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/counters', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
const unread = data.userCounters.filter((c) => c.counter > 0 && !c.isMuted)
console.log('Chats with unread messages:', unread.length)

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.userCounters Typearray DescriptionCounters for chats that have unread messages or an "unread" mark
Fielddata.userCounters[].chatId Typenumber DescriptionChat ID — to open the chat, use chat loading with a dialogId of the form chat<chatId>
Fielddata.userCounters[].counter Typenumber DescriptionNumber of unread messages
Fielddata.userCounters[].parentChatId Typenumber DescriptionID of the parent chat for comment chats, otherwise 0. It opens the same way as chatId
Fielddata.userCounters[].isMuted Typeboolean DescriptionNotifications are turned off for the chat
Fielddata.userCounters[].isMarkedAsUnread Typeboolean DescriptionThe chat was manually marked as unread
Fielddata.userCounters[].recentSections Typearray DescriptionSections of the chat list the chat is counted in (default, chat, tasksTask and others)

Response example

JSON
{
  "success": true,
  "data": {
    "userCounters": [
      {
        "chatId": 1945,
        "counter": 3,
        "parentChatId": 0,
        "isMuted": false,
        "isMarkedAsUnread": false,
        "recentSections": ["default"]
      }
    ]
  }
}

Error response example

400 — a query parameter was passed:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Query parameter `unreadOnly` is not accepted by GET /v1/chats/counters. It takes no query parameters."
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionA query parameter was passed — the endpoint takes none
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the im scope
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no Bitrix24 tokens configured
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 returned an error. The portal code is in error.b24Code
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 is unavailable or returned a server error

The full list of general API errors — Errors.

See also