For AI agents: markdown of this page — /docs-content-en/chats/messages/unread.md documentation index — /llms.txt
Unread starting from a message
POST /v1/chats/messages/:messageId/unread
Makes the given message the first unread one in a dialog, without marking the whole chat unread the way the chat-level mark does.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParametermessageId (path) |
Typenumber | Requiredyes | DescriptionMessage ID, a positive integer — the id field of a message from the message history or chat loading |
There are no query parameters: any parameter is refused with 400 INVALID_PARAMS.
Request body fields
| Field | Type | Required | Description |
|---|---|---|---|
FielddialogId |
Typestring | number | Requiredyes | DescriptionThe dialog that holds the message: chatXXX for a group chat, a user ID for a personal one, me for the current user's personal dialog. chatXXX is the id field of a recent dialogs row, a user ID comes from the user list |
Other body fields are refused with 400 INVALID_PARAMS.
Examples
curl — personal key
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/1001/unread" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "dialogId": "chat42" }'
curl — OAuth application
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/1001/unread" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "dialogId": "chat42" }'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/1001/unread', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ dialogId: 'chat42' }),
})
const { success } = await res.json()
console.log('Mark set:', success)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/1001/unread', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ dialogId: 'chat42' }),
})
const { success } = await res.json()
console.log('Mark set:', success)
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata |
Typeboolean | Descriptiontrue — the mark is set |
Response example
{
"success": true,
"data": true
}
Error response example
404 — the message is not in the given dialog:
{
"success": false,
"error": {
"code": "ENTITY_NOT_FOUND",
"message": "Message is not in the specified dialog. Nothing was changed."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionmessageId is not a positive integer or equals 9007199254740991, dialogId is missing or does not look like a user ID, chatXXX or me, or another body field or a query parameter was sent. Checked before any Bitrix24 call |
| HTTP401 | CodeMISSING_API_KEY |
DescriptionX-Api-Key was not sent |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no Bitrix24 tokens configured |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe API key lacks the im scope |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is read-only. Checked before any Bitrix24 call |
| HTTP403 | CodeBITRIX_ACCESS_DENIED |
DescriptionBitrix24 denied access |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionThe message is not in the given dialog or belongs to another dialog. The mark is not set |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 refused the operation. The refusal text is in error.message |
| HTTP429 | CodeRATE_LIMITED |
DescriptionThe Bitrix24 request limit was exceeded. Retry after the pause in the Retry-After header |
| HTTP502 | CodeME_ALIAS_RESOLUTION_FAILED |
DescriptionThe current user could not be determined for me |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable, returned a server error or did not confirm the mark |
| HTTP503 | CodeBITRIX_TIMEOUT |
DescriptionBitrix24 did not respond in time, and it is unknown whether the mark was set. Retry after the pause in the Retry-After header |
Full list of common API errors — Errors.
Known specifics
Messages and chats have three different marks — pick the one that fits the task:
| Route | Action |
|---|---|
RoutePOST /v1/chats/:dialogId/unread |
ActionMark the whole chat unread |
RoutePOST /v1/chats/messages/:messageId/mark |
ActionA "read later" pointer. It does not move an existing mark |
RoutePOST /v1/chats/messages/:messageId/unread |
ActionMake the message the first unread one in the given dialog |