Get the List of Recent Messages im.dialog.messages.get
Scope:
imWho can execute the method: chat participant
The method im.dialog.messages.get retrieves messages from the specified dialog, including system messages. It does not support standard pagination due to the potential large volume of data.
Messages can only be retrieved without participating in the chat for Open Line chats via the method imopenlines.session.history.get.
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 |
Identifier of the message older than which messages need to be loaded. The method will return messages with identifiers less than the specified one. |
|
FIRST_ID |
Identifier of the message newer than which messages need to be loaded. The method will return messages with identifiers greater than the specified one. To load the very first messages of the dialog — pass |
|
LIMIT |
Limit on the number of messages in the response. If Default is |
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
try
{
const response = await $b24.callMethod(
'im.dialog.messages.get',
{
DIALOG_ID: 'chat1489',
FIRST_ID: 84869,
LIMIT: 10
}
);
console.log(response.getData().result);
}
catch (error)
{
console.error(error);
}
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);
Response Handling
HTTP Status: 200
{
"result": {
"chat_id": 1489,
"messages": [
{
"id": 84877,
"chat_id": 1489,
"author_id": 503,
"date": "2026-03-04T09:43:26+02:00",
"text": "We are very glad to see 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+02:00",
"text": "Hello, Anna! Here we will discuss the project.",
"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+02:00",
"text": "[USER=503 REPLACE]John Smith[/USER] invited to the chat [USER=547 REPLACE]Anna Johnson[/USER]",
"unread": false,
"uuid": null,
"replaces": [],
"params": {
"CODE": ["CHAT_JOIN"],
"NOTIFY": "N"
},
"disappearing_date": null
},
...
],
"users": [
{
"id": 503,
"active": true,
"name": "John Smith",
"first_name": "John",
"last_name": "Smith",
"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+02:00",
"mobile_last_date": false,
"desktop_last_date": false,
"absent": false,
"departments": [667],
"phones": false,
"bot_data": null,
"type": "user",
"website": "",
"email": "smith@mysite.com"
},
{
"id": 547,
"active": true,
"name": "Anna Johnson",
"first_name": "Anna",
"last_name": "Johnson",
...
}
],
"files": [
{
"id": 5255,
"chatId": 1489,
"date": "2026-03-02T16:10:00+02:00",
"type": "image",
"name": "image.png",
"extension": "png",
"size": 2144,
"image": {
"height": 61,
"width": 72
},
"status": "done",
"progress": 100,
"authorId": 503,
"authorName": "John Smith",
"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 Drive\",\"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+02:00",
"date_finish": "2026-03-04T10:18:24+02: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 |
Object result
|
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 |
Object message
|
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, |
Object params
|
Name |
Description |
|
LIKE |
Identifiers of users who reacted to the message |
|
CODE |
Codes of system events:
|
|
NOTIFY |
Indicator of notification sending. Value |
Object user
|
Name |
Description |
|
id |
Identifier of the user |
|
active |
Indicator of active user |
|
name |
Full name |
|
first_name |
First name |
|
last_name |
Last name |
|
work_position |
Job title |
|
color |
Avatar color in hex format |
|
avatar |
Link to the avatar |
|
avatar_hr |
Link to the high-resolution avatar |
|
gender |
Gender.
|
|
birthday |
Date of birth |
|
extranet |
Indicator of extranet user |
|
network |
Indicator of Bitrix24 network user |
|
bot |
Indicator of bot |
|
connector |
Indicator of Open Lines user |
|
external_auth_id |
Type of authentication |
|
status |
User 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 |
User type |
|
website |
User website |
|
email |
User e-mail |
Object file
|
Name |
Description |
|
id |
Identifier of the file |
|
chatId |
Identifier of the chat |
|
date |
Date of file upload |
|
type |
Type of file: |
|
name |
Name of the file |
|
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 |
Object image
|
Name |
Description |
|
height |
Height of the image in pixels |
|
width |
Width of the image in pixels |
Object viewerAttrs
|
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 |
Name of the file |
|
actions |
Available actions with the file in JSON format |
Object mediaUrl
|
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 allowed to be called using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The methods must be called using the HTTPS protocol |
|
|
|
The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support |
|
|
|
The REST API is available only on commercial plans |
|
|
|
The user whose access token or webhook was used to call the method lacks 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 account administrator has allowed access to this application only for specific users |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Find Message in Chat im.dialog.messages.search
- Set the "read" flag for messages im.dialog.read
- Set the "unread" flag for messages im.dialog.unread
- Send "User is typing" indicator im.dialog.writing