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

Count favorite messages

GET /v1/chats/:dialogId/favorites/count

Returns how many messages the current user has added to favorites in one chat, without loading the messages themselves.

Parameters

Parameter Type Required Description
ParameterdialogId (path) Typestring Requiredyes Descriptionchat followed by the actual chat ID returned when you load the chat, including a one-to-one chat. The endpoint rejects a numeric user ID and me.

Requires the im scope. The credentials identify the current user. The API rejects parameters that specify the owner and any unknown parameters.

Examples

curl — personal key

Terminal
curl -X GET "https://vibecode.bitrix24.com/v1/chats/chat1945/favorites/count" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl -X GET "https://vibecode.bitrix24.com/v1/chats/chat1945/favorites/count" \
  -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/chat1945/favorites/count', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})
const { data } = await res.json()
console.log(data)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat1945/favorites/count', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})
const { data } = await res.json()
console.log(data)

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue
Fielddata.counter Typenumber DescriptionFavorite message counter

Response example

JSON
{
  "success": true,
  "data": {
    "counter": 3
  }
}

Error response example

400 — unexpected parameter:

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

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionMalformed ID, or an unexpected or repeated parameter or body field
HTTP422 CodeBITRIX_ERROR Descriptionerror.b24Code is ACCESS_ERROR — the employee has no access to the chat, or there is no such chat
HTTP401 CodeMISSING_API_KEY DescriptionNo API key was provided
HTTP401 CodeTOKEN_MISSING DescriptionNo Bitrix24 credentials are configured
HTTP403 CodeSCOPE_DENIED DescriptionThe key does not have im scope
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe current user has no access
HTTP404 CodeENTITY_NOT_FOUND DescriptionThe record was not found
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 refused the operation with another code, which is in error.b24Code

Common API errors.

See also