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

Number of a chat's links

GET /v1/chats/:chatId/links/counter

Returns how many links were sent in the chat's messages, without loading the links themselves.

Parameters

Parameter Type Required Description
ParameterchatId (path) Typenumber Requiredyes DescriptionChat ID. Get it from GET /v1/chats/recent

No body and no query parameters are accepted: any body field or query parameter is rejected with 400 INVALID_PARAMS.

Examples

curl — personal key

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

curl — OAuth application

Terminal
curl "https://vibecode.bitrix24.com/v1/chats/1001/links/counter" \
  -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/1001/links/counter', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { data } = await res.json()
console.log('Links:', data.counter)

JavaScript — OAuth application

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

const { data } = await res.json()
console.log('Links:', data.counter)

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.counter Typenumber DescriptionNumber of links in the chat

Response example

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

Error response example

400 — a query parameter was passed:

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

Errors

HTTP Code Description
HTTP400 CodeINVALID_CHAT_ID DescriptionchatId is not a positive integer. Checked before any call to Bitrix24
HTTP400 CodeINVALID_PARAMS DescriptionA body field or query parameter was passed. Checked before any call to Bitrix24
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no Bitrix24 tokens configured
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the im scope
HTTP404 CodeENTITY_NOT_FOUND DescriptionBitrix24 returned a generic "not found" error; the portal code is in error.b24Code
HTTP422 CodeBITRIX_ERROR Descriptionerror.b24Code is ACCESS_ERROR — the employee has no access to the chat, or there is no such chat

Full list of common API errors — Errors.

Known specifics

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.

See also