Retrieve a List of Recent Messages im.dialog.messages.get
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
imWho can execute the method: chat participant
The im.dialog.messages.get method retrieves messages from the specified conversation, including system messages. It does not support standard pagination due to the potentially large volume of data.
Messages can only be retrieved without participating in the chat for Open Channel chats via the imopenlines.session.history.get method.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
DIALOG_ID* |
Identifier of the chat in the format:
The chat identifier can be obtained using the method im.chat.get. The user identifier can be obtained using the methods user.get and user.search |
|
LAST_ID |
Message identifier relative to which older messages should be loaded. The method will return messages with an identifier smaller than the specified one. To sequentially load history backwards, first request the latest messages without |
|
FIRST_ID |
Message identifier relative to which newer messages should be loaded. The method will return messages with an identifier larger than the specified one. For example, with |
|
LIMIT |
Limit on the number of messages in the response. If The method may return more messages than specified in Default — |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"DIALOG_ID":"chat1489","FIRST_ID":84869,"LIMIT":10}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/im.dialog.messages.get
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"DIALOG_ID":"chat1489","FIRST_ID":84869,"LIMIT":10,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/im.dialog.messages.get
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame, ISODate } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type DialogMessagesGetResult = {
chat_id: number
messages: {
id: number
chat_id: number
author_id: number
date: ISODate
text: string
unread: boolean
uuid: string | null
replaces: unknown[]
params: Record<string, unknown>
disappearing_date: ISODate | null
}[]
users: {
id: number
active: boolean
name: string
first_name: string
last_name: string
status: string
last_activity_date: ISODate
type: string
}[]
files: {
id: number
chatId: number
date: ISODate
type: string
name: string
size: number
status: string
authorId: number
authorName: string
urlDownload: string
isTranscribable: boolean
isVideoNote: boolean
isVoiceNote: boolean
}[]
}
try {
const response = await $b24.actions.v2.call.make<DialogMessagesGetResult>({
method: 'im.dialog.messages.get',
params: {
DIALOG_ID: 'chat1489',
FIRST_ID: 84869,
LIMIT: 10,
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info(result.chat_id, result.messages.length, result.messages)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function getDialogMessages() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'im.dialog.messages.get',
params: {
DIALOG_ID: 'chat1489',
FIRST_ID: 84869,
LIMIT: 10,
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info(result.chat_id, result.messages.length, result.messages)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', getDialogMessages)
</script>
try {
$response = $b24Service->core->call(
'im.dialog.messages.get',
[
'DIALOG_ID' => 'chat1489',
'FIRST_ID' => 84869,
'LIMIT' => 10,
]
);
$result = $response->getResponseData()->getResult();
print_r($result);
} catch (Throwable $e) {
error_log($e->getMessage());
}
BX24.callMethod(
'im.dialog.messages.get',
{
DIALOG_ID: 'chat1489',
FIRST_ID: 84869,
LIMIT: 10
},
function(result)
{
if (result.error())
{
console.error(result.error());
}
else
{
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'im.dialog.messages.get',
[
'DIALOG_ID' => 'chat1489',
'FIRST_ID' => 84869,
'LIMIT' => 10,
]
);
print_r($result);
// client and ctx are already created — see the Go SDK section
res, err := client.Core().Call(ctx, "im.dialog.messages.get", b24.Params{
"DIALOG_ID": "chat1489",
"FIRST_ID": 84869,
"LIMIT": 10,
}, b24.WithIdempotent())
if err != nil {
return fmt.Errorf("im.dialog.messages.get: %w", err)
}
// The response arrives as json.RawMessage — unmarshal it
// into a struct matching the response shape shown below on this page.
fmt.Printf("%s\n", res.Result)
Response Handling
HTTP status: 200
{
"result": {
"chat_id": 1489,
"messages": [
{
"id": 84877,
"chat_id": 1489,
"author_id": 503,
"date": "2026-03-04T09:43:26+03:00",
"text": "We are very happy to have you!",
"unread": false,
"uuid": "0c42a08f-4235-49fc-994f-c9bccd499ac1",
"replaces": [],
"params": {
"LIKE": [547]
},
"disappearing_date": null
},
{
"id": 84875,
"chat_id": 1489,
"author_id": 503,
"date": "2026-03-04T09:43:21+03:00",
"text": "Hello, Anna! We will discuss the project here.",
"unread": false,
"uuid": "db2e826a-dd18-4ab5-b76c-4084e106ee28",
"replaces": [],
"params": [],
"disappearing_date": null
},
{
"id": 84869,
"chat_id": 1489,
"author_id": 0,
"date": "2026-03-04T09:42:31+03:00",
"text": "[USER=503 REPLACE]Klaus Weber[/USER] invited [USER=547 REPLACE]Anna Weber[/USER] to the chat",
"unread": false,
"uuid": null,
"replaces": [],
"params": {
"CODE": ["CHAT_JOIN"],
"NOTIFY": "N"
},
"disappearing_date": null
}
],
"users": [
{
"id": 503,
"active": true,
"name": "Klaus Weber",
"first_name": "Klaus",
"last_name": "Weber",
"work_position": "admin",
"color": "#4ba984",
"avatar": "https://mysite.com/upload/resize_cache/main/avatar.jpg",
"avatar_hr": "https://mysite.com/upload/resize_cache/main/avatar.jpg",
"gender": "M",
"birthday": "",
"extranet": false,
"network": false,
"bot": false,
"connector": false,
"external_auth_id": "socservices",
"status": "online",
"idle": false,
"last_activity_date": "2026-03-04T10:13:14+03:00",
"mobile_last_date": false,
"desktop_last_date": false,
"absent": false,
"departments": [667],
"phones": false,
"bot_data": null,
"type": "user",
"website": "",
"email": "ivanov@mysite.com"
},
{
"id": 547,
"active": true,
"name": "Anna Weber",
"first_name": "Anna",
"last_name": "Weber",
"work_position": "Manager",
"color": "#df532d",
"avatar": "",
"avatar_hr": "",
"gender": "F",
"birthday": "",
"extranet": false,
"network": false,
"bot": false,
"connector": false,
"external_auth_id": "default",
"status": "online",
"idle": false,
"last_activity_date": "2026-03-04T10:11:02+03:00",
"mobile_last_date": false,
"desktop_last_date": false,
"absent": false,
"departments": [667],
"phones": false,
"bot_data": null,
"type": "user",
"website": "",
"email": "weber@mysite.com"
}
],
"files": [
{
"id": 5255,
"chatId": 1489,
"date": "2026-03-02T16:10:00+03:00",
"type": "image",
"name": "image.png",
"extension": "png",
"size": 2144,
"image": {
"height": 61,
"width": 72
},
"status": "done",
"progress": 100,
"authorId": 503,
"authorName": "Klaus Weber",
"urlPreview": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5255&exact=N&_esd=s6P3x5qDBEKU0NiS7sczr69Y%2FHHR8Za8EXa7STOAXIVOylYhMsnMj5nGU0VXeQ1PIsqm%2F0GNxOju5wR1jNj76d%2FZnVgpyqeIcJ4UiWXm8CJsrmARXWpxWe%2BgJ%2BpGqx0M5CxgjNzIopQp2cwM&fileName=image.png",
"urlShow": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.showImage&SITE_ID=s1&humanRE=1&fileId=5255&width=1280&height=1280&signature=4b6b2bbba680d3bccd8b70e398d94c1c3cfcb018f813089c32db3bb25df594f5&exact=N&_esd=s6P3x5qDBEKU0NiS7sczr69Y%2FHHR8Za8EXa7STOAXIVOylYhMsnMj5nGU0VXeQ1PIsqm%2F0GNxOju5wR1jNj76d%2FZnVgpyqeIcJ4UiWXm8CJsrmARXWpxWe%2BgJ%2BpGqx0M5CxgjNzIopQp2cwM&fileName=image.png",
"urlDownload": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5255&exact=N&_esd=s6P3x5qDBEKU0NiS7sczr69Y%2FHHR8Za8EXa7STOAXIVOylYhMsnMj5nGU0VXeQ1PIsqm%2F0GNxOju5wR1jNj76d%2FZnVgpyqeIcJ4UiWXm8CJsrmARXWpxWe%2BgJ%2BpGqx0M5CxgjNzIopQp2cwM&fileName=image.png",
"viewerAttrs": {
"viewer": "",
"viewerType": "image",
"src": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5255&exact=N&_esd=s6P3x5qDBEKU0NiS7sczr69Y%2FHHR8Za8EXa7STOAXIVOylYhMsnMj5nGU0VXeQ1PIsqm%2F0GNxOju5wR1jNj76d%2FZnVgpyqeIcJ4UiWXm8CJsrmARXWpxWe%2BgJ%2BpGqx0M5CxgjNzIopQp2cwM&fileName=image.png",
"viewerResized": "",
"objectId": "5255",
"viewerGroupBy": "1489",
"imChatId": 1489,
"title": "image.png",
"actions": "[{\"type\":\"download\"},{\"type\":\"copyToMe\",\"text\":\"Save to Disk\",\"action\":\"BXIM.disk.saveToDiskAction\",\"params\":{\"fileId\":\"5255\"},\"extension\":\"disk.viewer.actions\",\"buttonIconClass\":\"ui-btn-icon-cloud\"}]"
},
"mediaUrl": {
"preview": {
"250": "https://mysite.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5255&exact=N&_esd=s6P3x5qDBEKU0NiS7sczr69Y%2FHHR8Za8EXa7STOAXIVOylYhMsnMj5nGU0VXeQ1PIsqm%2F0GNxOju5wR1jNj76d%2FZnVgpyqeIcJ4UiWXm8CJsrmARXWpxWe%2BgJ%2BpGqx0M5CxgjNzIopQp2cwM&fileName=image.png"
}
},
"isTranscribable": false,
"isVideoNote": false,
"isVoiceNote": false
}
]
},
"time": {
"start": 1772608704,
"finish": 1772608704.545697,
"duration": 0.5456969738006592,
"processing": 0,
"date_start": "2026-03-04T10:18:24+03:00",
"date_finish": "2026-03-04T10:18:24+03:00",
"operating_reset_at": 1772609304,
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response (detailed description) |
|
time |
Information about the request execution time |
Result Object
|
Name |
Description |
|
chat_id |
Identifier of the chat |
|
messages |
Array of messages (detailed description). The method will return an empty array if a non-existent identifier is specified in |
|
users |
Users from the selection (detailed description). The method will return an empty array if a non-existent identifier is specified in |
|
files |
Files from the selection (detailed description). The method will return an empty array if a non-existent identifier is specified in |
Message Object
|
Name |
Description |
|
id |
Identifier of the message |
|
chat_id |
Identifier of the chat |
|
author_id |
Identifier of the author, |
|
date |
Date of the message in ISO 8601 format |
|
text |
Text of the message |
|
unread |
Indicator of unread message |
|
uuid |
Unique identifier of the message, |
|
replaces |
Array of text replacements for the message |
|
params |
Additional parameters of the message (detailed description). The set of fields in the object depends on the type of message: regular or system |
|
disappearing_date |
Date of disappearance of the message, |
Params Object
|
Name |
Description |
|
LIKE |
Identifiers of users who reacted to the message |
|
CODE |
Codes of system events:
|
|
NOTIFY |
Indicator of notification sending. Value |
User Object
|
Name |
Description |
|
id |
User identifier |
|
active |
Indicator of an active user |
|
name |
Full name |
|
first_name |
First Name |
|
last_name |
Last Name |
|
work_position |
Position |
|
color |
Avatar color in hex format |
|
avatar |
Link to avatar |
|
avatar_hr |
Link to the high-resolution avatar |
|
gender |
Gender.
|
|
birthday |
Date of birth |
|
extranet |
Extranet user status |
|
network |
Indicator of Bitrix24 network user |
|
bot |
Indicator of a bot |
|
connector |
Indicator of an Open Channels user |
|
external_auth_id |
Type of authentication |
|
status |
User's status |
|
idle |
Indicator of user inactivity |
|
last_activity_date |
Date of last activity |
|
mobile_last_date |
Date of last activity in the mobile app, |
|
desktop_last_date |
Date of last activity in the desktop app, |
|
absent |
Indicator of user absence |
|
departments |
Identifiers of user departments |
|
phones |
User phones, |
|
bot_data |
Bot data, |
|
type |
Type of user |
|
website |
User's website |
|
email |
User e-mail |
File Object
|
Name |
Description |
|
id |
Identifier of the file |
|
chatId |
Identifier of the chat |
|
date |
Date of file upload |
|
type |
Type of file: |
|
name |
File name |
|
extension |
File extension |
|
size |
Size in bytes |
|
image |
Dimensions of the image for files of type |
|
status |
Status of the file: |
|
progress |
Percentage of file upload |
|
authorId |
Identifier of the file author |
|
authorName |
Name of the file author |
|
urlPreview |
Link for file preview |
|
urlShow |
Link for displaying the file |
|
urlDownload |
Link for downloading the file |
|
viewerAttrs |
Attributes for file viewer (detailed description) |
|
mediaUrl |
Media file URL for preview (detailed description) |
|
isTranscribable |
Indicator of transcribability |
|
isVideoNote |
Indicator of video note |
|
isVoiceNote |
Indicator of voice note |
Image Object
|
Name |
Description |
|
height |
Height of the image in pixels |
|
width |
Width of the image in pixels |
viewerAttrs Object
|
Name |
Description |
|
viewer |
Type of viewer |
|
viewerType |
Type of file display |
|
src |
Link to the file |
|
viewerResized |
Link to the reduced version of the file |
|
objectId |
Identifier of the file object |
|
viewerGroupBy |
Identifier of the group for viewing files in the chat |
|
imChatId |
Identifier of the chat |
|
title |
File name |
|
actions |
Available actions with the file in JSON format |
mediaUrl Object
|
Name |
Description |
|
preview |
Links for file preview. The keys of the object are the dimensions of the image in pixels |
Error Handling
HTTP status: 400
{
"error": "DIALOG_ID_EMPTY",
"error_description": "Dialog ID can't be empty"
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Status |
Code |
Description |
Value |
|
|
|
Dialog ID can't be empty |
The |
|
|
|
First ID can't be string |
The |
|
|
|
Last ID can't be string |
The |
|
|
|
You do not have access to the specified dialog |
The user does not have access to the dialog |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not permitted for calls using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The HTTPS protocol is required for method calls |
|
|
|
The REST API is blocked due to overload. This is a manual individual block; please contact Bitrix24 technical support to lift it |
|
|
|
The REST API is only available on commercial plans |
|
|
|
The user associated with the access token or webhook used to call the method lacks the necessary permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the portal administrator has restricted access to this application to specific users only |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |