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

Read messages

POST /v1/bots/:botId/chats/:dialogId/read

Marks messages as read on behalf of the bot. Without messageId, marks all messages in the chat as read.

Parameters

Parameter Type Required Default Description
botId (path) number yes Bot ID
dialogId (path) string yes Dialog ID: numeric user ID for direct messages, chatXXX for group chats
messageId (body) number no Read all messages up to and including this one. Without the parameter — read all

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/read \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "messageId": 1501 }'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/read \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "messageId": 1501 }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/read', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ messageId: 1501 }),
})

const { success, data } = await res.json()
console.log('Read up to:', data.lastId)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/chats/chat456/read', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ messageId: 1501 }),
})

const { success, data } = await res.json()

Response fields

Field Type Description
chatId number Chat ID
lastId number ID of the last read message
counter number Remaining number of unread messages
viewedMessages number[] IDs of the read messages

Response example

JSON
{
  "success": true,
  "data": {
    "chatId": 456,
    "lastId": 1501,
    "counter": 0,
    "viewedMessages": [1499, 1500, 1501]
  }
}

Error response example

404 — bot not found:

JSON
{
  "success": false,
  "error": {
    "code": "BOT_NOT_FOUND",
    "message": "Bot 999 not found. Register it first via POST /v1/bots."
  }
}

Errors

HTTP Code Description
400 INVALID_BOT_ID botId is not a number
404 BOT_NOT_FOUND No bot found with this ID
403 BOT_ACCESS_DENIED The bot belongs to a different API key
502 BITRIX_ERROR Bitrix24 error (error text in message)
403 SCOPE_DENIED The API key does not have the imbot scope
401 TOKEN_MISSING The API key has no configured tokens

Full list of common API errors — Errors.

Known specifics

Without messageId: if messageId is not passed, all messages in the chat are marked as read.

Reading up to a message: when messageId is specified, all messages up to and including the specified one are read, not just that single message.

See also