Get Message History of the Dialogue imopenlines.session.history.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:
imopenlinesWho can execute the method: any user
The method imopenlines.session.history.get returns the message history of an open line session.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
SESSION_ID |
Identifier of the open line session. The identifier can be obtained using the imopenlines.dialog.get method from the |
|
CHAT_ID |
Numeric identifier of the open line chat without the The identifier can be obtained using the imopenlines.dialog.get or imopenlines.crm.chat.get methods |
The method accepts one of the parameters: SESSION_ID or CHAT_ID.
- If
SESSION_IDis provided, the method operates based on it. - If
SESSION_IDis not provided, the method attempts to determine the last session byCHAT_IDwith sortingID DESC.
In practice, for stable results, it is recommended to provide SESSION_ID.
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"SESSION_ID":321}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/imopenlines.session.history.get
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"SESSION_ID":321,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/imopenlines.session.history.get
try {
const response = await $b24.callMethod(
'imopenlines.session.history.get',
{
SESSION_ID: 321,
}
);
const { result } = response.getData();
console.log(result);
} catch (error) {
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'imopenlines.session.history.get',
[
'SESSION_ID' => 321,
]
);
$result = $response
->getResponseData()
->getResult();
if ($result->error()) {
echo 'Error: ' . $result->error();
} else {
echo 'Success: ' . print_r($result->data(), true);
}
} catch (Throwable $exception) {
error_log($exception->getMessage());
echo 'Error getting session history: ' . $exception->getMessage();
}
BX24.callMethod(
'imopenlines.session.history.get',
{
SESSION_ID: 321,
},
function(result) {
if (result.error()) {
console.error(result.error().ex);
} else {
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'imopenlines.session.history.get',
[
'SESSION_ID' => 321,
]
);
if (!empty($result['error'])) {
echo 'Error: ' . $result['error_description'];
} else {
echo 'Success: ' . print_r($result['result'], true);
}
Response Handling
HTTP Status: 200
{
"result": {
"chatId": 1763,
"canJoin": "Y",
"canVoteHead": "Y",
"sessionId": 321,
"sessionVoteHead": 0,
"sessionCommentHead": null,
"userId": "chat1763",
"message": {
"85851": {
"id": "85851",
"chatid": "1763",
"senderid": "103",
"recipientid": "chat1763",
"date": "2026-03-11T13:12:46+01:00",
"text": "Open the task card and click Observers",
"textlegacy": "Open the task card and click Observers",
"params": {
"connectorMid": ["85853"],
"fileId": [5437]
}
},
"85833": {
"id": "85833",
"chatid": "1763",
"senderid": "0",
"recipientid": "chat1763",
"date": "2026-03-11T13:09:25+01:00",
"text": "[b]A new lead has been created[/b]",
"textlegacy": "<b>A new lead has been created</b>",
"params": {
"attach": [
{
"id": 1773223765,
"blocks": [
{
"link": [
{
"name": "Filling out the CRM form \"Contact Data Form for Open Lines\"",
"link": "/crm/lead/details/1205/"
}
]
},
{
"grid": [
{
"display": "ROW",
"name": "Name",
"value": "John",
"colorToken": "base"
},
{
"display": "LINE",
"name": "Phone",
"value": "+11234567890",
"height": 20,
"colorToken": "base"
}
]
}
],
"description": "",
"color": "#df532d"
}
]
}
},
... // description for each message
},
"usersMessage": {
"chat1763": [
"85851",
"85833",
]
},
"users": {
"103": {
"id": "103",
"name": "Samantha Johnson",
"active": true,
"firstName": "Samantha",
"lastName": "Johnson",
"workPosition": "IT Department Head",
"color": "#4ba984",
"avatar": "https://example.bitrix24.com/upload/main/avatar.png",
"avatarId": "8644",
"birthday": "08-03",
"gender": "F",
"phoneDevice": false,
"phones": false,
"extranet": false,
"network": false,
"bot": false,
"connector": false,
"profile": "/company/personal/user/103/",
"externalAuthId": "socservices",
"status": "online",
"idle": false,
"lastActivityDate": "2026-03-11T13:14:35+01:00",
"mobileLastDate": false,
"desktopLastDate": false,
"departments": [1, 7],
"absent": false,
"type": "user",
"services": null,
"botData": null
},
... // description for each user
},
"openlines": {
"canvoteashead": {
"22": true
}
},
"userInGroup": {
"1": {
"id": 1,
"users": ["103"]
},
... // description for each department
},
"woUserInGroup": [],
"chat": {
"1763": {
"id": "1763",
"parentChatId": 0,
"parentMessageId": 0,
"name": "John - Bitrix24 Documentation",
"owner": "103",
"color": "#ba9c7b",
"extranet": false,
"avatar": "/bitrix/js/im/images/blank.gif",
"call": "0",
"callNumber": "",
"entityType": "LINES",
"entityId": "livechat|22|1761|587",
"entityData1": "Y|LEAD|1205|N|N|321|1773223732|0|0|0",
"entityData2": "LEAD|1205|COMPANY|0|CONTACT|0|DEAL|0",
"entityData3": "",
"messageCount": 14,
"public": "",
"muteList": {
"103": false,
"587": false
},
"managerList": [103],
"dateCreate": "2026-03-11T12:08:52+01:00",
"type": "lines",
"entityLink": {
"type": "LINES",
"url": "",
"id": "livechat|22|1761|587"
},
"permissions": {
"manageUsersAdd": "member",
"manageUsersDelete": "manager",
"manageUi": "member",
"manageSettings": "owner",
"manageMessages": "member",
"canPost": "member"
},
"textFieldEnabled": true,
"backgroundId": null,
"messageType": "L",
"isNew": false
}
},
"userBlockChat": {
"1763": {
"103": false,
"587": false
}
},
"userInChat": {
"1763": [103, 587]
},
"files": {
"5437": {
"id": 5437,
"chatid": 1763,
"date": "2026-03-11T13:12:46+01:00",
"type": "image",
"name": "2311.png",
"extension": "png",
"size": 70855,
"image": {
"height": 615,
"width": 646
},
"status": "done",
"progress": 100,
"authorid": 103,
"authorname": "Samantha Johnson",
"urlpreview": "https://some-domain.bitrix24.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5437&exact=N&_esd=oYQLNdHU%3D&fileName=2311.png",
"urlshow": "https://some-domain.bitrix24.com/bitrix/services/main/ajax.php?action=disk.api.file.showImage&SITE_ID=s1&humanRE=1&fileId=5437&width=1280&height=1280&signature=d1007a9ed47599e2160b993ca&exact=N&_esd=oYQLNdHU%3D&fileName=2311.png",
"urldownload": "https://some-domain.bitrix24.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5437&exact=N&_esd=oYQLNdHU%3D&fileName=2311.png",
"viewerattrs": {
"viewer": "",
"viewertype": "image",
"src": "https://some-domain.bitrix24.com/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=5437&exact=N&_esd=oYQLNdHU%3D&fileName=2311.png",
"viewerresized": "",
"objectid": "5437",
"viewergroupby": "1763",
"imchatid": 1763,
"title": "2311.png",
"actions": "[{\"type\":\"download\"},{\"type\":\"copyToMe\",\"text\":\"Save to Drive\",\"action\":\"BXIM.disk.saveToDiskAction\",\"params\":{\"fileId\":\"5437\"},\"extension\":\"disk.viewer.actions\",\"buttonIconClass\":\"ui-btn-icon-cloud\"}]"
},
"mediaurl": {
"preview": {
"250": "https://some-domain.bitrix24.com/bitrix/services/main/ajax.php?action=disk.api.file.showImage&SITE_ID=s1&humanRE=1&fileId=5437&width=250&height=250&signature=c28f11fbae0ee5a0c40970c4e8e554&exact=Y&_esd=oYQLNdHU%3D&fileName=2311.png"
}
},
"istranscribable": false,
"isvideonote": false,
"isvoicenote": false
}
}
},
"time": {
"start": 1773224138,
"finish": 1773224138.143344,
"duration": 0.14334392547607422,
"processing": 0,
"date_start": "2026-03-11T13:15:38+01:00",
"date_finish": "2026-03-11T13:15:38+01:00",
"operating_reset_at": 1773224738,
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root object of the response. The structure of the object is described in detail below |
|
time |
Information about the execution time of the request |
Result Object
|
Name |
Description |
|
chatId |
Identifier of the chat |
|
canJoin |
Flag indicating the ability to join the dialogue: |
|
canVoteHead |
Flag indicating the ability to evaluate operators by the supervisor: |
|
sessionId |
Identifier of the session |
|
sessionVoteHead |
Rating given by the supervisor |
|
sessionCommentHead |
Supervisor's comment on the rating or |
|
userId |
Identifier of the chat in the format |
|
message |
Chat messages indexed by message identifier. The structure of the object is described in detail below |
|
usersMessage |
Relationship between the chat and the list of message identifiers. The structure of the object is described in detail below |
|
users |
Object of chat participants, where the key is the user identifier. The structure of the object is described in detail below |
|
openlines |
Open line data. The structure of the object is described in detail below |
|
userInGroup |
Users grouped by departments, or an empty array The structure of the object is described in detail below |
|
woUserInGroup |
Users not included in the departments from |
|
chat |
Chat data by its identifier. The structure of the object is described in detail below |
|
userBlockChat |
Flags for blocking the chat by users. The structure of the object is described in detail below |
|
userInChat |
Composition of chat participants or an empty array. The structure of the chat participants is described in detail below |
|
files |
Files associated with messages, or an empty array. The structure of the files object is described in detail below |
Message Object
|
Name |
Description |
|
Message object. The structure of the message object is described in detail below |
Message Item Object
|
Name |
Description |
|
id |
Identifier of the message |
|
chatid |
Identifier of the chat |
|
senderid |
Identifier of the sender |
|
recipientid |
Recipient of the message in the format |
|
date |
Date and time of the message in ISO 8601 format (RFC3339) |
|
text |
Text of the message |
|
textlegacy |
Text of the message in legacy format |
|
params |
Service parameters of the message |
Users Message Object
|
Name |
Description |
|
chat<chatId> |
Array of message identifiers related to the chat |
Users Object
|
Name |
Description |
|
<userId> |
User data. The structure of the user object is described in detail below |
User Item Object
|
Name |
Description |
|
id |
Identifier of the user |
|
name |
User's full name |
|
firstName |
User's first name |
|
lastName |
User's last name |
|
workPosition |
Position or |
|
avatar |
Link to the user's avatar |
|
avatarId |
Identifier of the avatar file or |
|
gender |
User's gender |
|
extranet |
Extranet user flag |
|
connector |
Connector user flag |
|
profile |
Link to the profile |
|
externalAuthId |
External authentication type |
|
status |
Online status or |
|
lastActivityDate |
Date and time of the last activity in ISO 8601 format (RFC3339) |
|
departments |
Identifiers of departments |
|
type |
Type of user |
Open Lines Object
|
Name |
Description |
|
canvoteashead |
Object of the form |
User In Group Object
|
Name |
Description |
|
<departmentId> |
Department data. The structure of the department object is described in detail below |
Group Item Object
|
Name |
Description |
|
id |
Identifier of the department |
|
users |
List of user identifiers that belong to the department |
Chat Object
|
Name |
Description |
|
<chatId> |
Chat data. The structure of the department object is described in detail below |
Chat Item Object
|
Name |
Description |
|
id |
Identifier of the chat |
|
name |
Name of the chat |
|
owner |
Identifier of the chat owner |
|
entityType |
Type of the chat object |
|
entityId |
External identifier of the chat |
|
entityData1 |
String with chat metadata |
|
entityData2 |
Additional chat metadata |
|
entityData3 |
Additional chat metadata |
|
messageCount |
Number of messages in the chat |
|
public |
Public flag of the chat |
|
muteList |
Object where the key is the user identifier, and the value |
|
managerList |
List of identifiers of operator-managers |
|
dateCreate |
Date and time of chat creation in ISO 8601 format (RFC3339) |
|
type |
Type of chat |
|
entityLink |
Data linking the chat to the open line |
|
permissions |
Access rights in the chat |
|
textFieldEnabled |
Flag indicating the availability of the message input field |
|
backgroundId |
Identifier of the chat background or |
|
messageType |
Type of chat messages |
|
isNew |
Flag indicating a new chat |
User Block Chat Object
|
Name |
Description |
|
<chatId> |
Object with flags for blocking users in the chat: key — user identifier, value — |
User In Chat Object
|
Name |
Description |
|
<chatId> |
Array of user identifiers that are in the chat |
Files Object
|
Name |
Description |
|
<fileId> |
File data. The structure of the object is described in detail below |
File Item Object
|
Name |
Description |
|
id |
Identifier of the file |
|
chatid |
Identifier of the chat |
|
date |
Date and time of upload in ISO 8601 format (RFC3339) |
|
type |
Type of file |
|
name |
Name of the file |
|
extension |
File extension |
|
size |
Size of the file in bytes |
|
image |
Image parameters ( |
|
status |
Status of file processing |
|
progress |
Processing progress in percentage |
|
authorid |
Identifier of the file author |
|
authorname |
Name of the file author |
|
urlpreview |
URL of the file preview |
|
urlshow |
URL of the file view |
|
urldownload |
URL of the file download |
|
viewerattrs |
Viewing parameters of the file in the interface |
|
mediaurl |
URL of the media file |
|
istranscribable |
Flag indicating the availability of file transcription |
|
isvideonote |
Flag indicating a video note |
|
isvoicenote |
Flag indicating a voice note |
Error Handling
HTTP Status: 400
{
"error": "MISSING_REQUIRED_PARAM",
"error_description": "Session ID or Chat ID must be provided"
}
|
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
|
Code |
Description |
Value |
|
|
Session ID or Chat ID must be provided |
|
|
|
Unable to determine session ID from provided parameters |
Unable to determine session from the provided parameters |
|
|
You cannot open this conversation as you do not have sufficient rights |
Insufficient rights to view history, session not found or unavailable |
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 |
Continue Learning
- Get Chat by User Code imopenlines.session.open
- Start a New Dialogue imopenlines.session.start
- Join the Dialogue imopenlines.session.join
- Take Over the Dialogue from the Current Operator imopenlines.session.intercept
- Pin or Unpin a Dialog imopenlines.session.mode.pin
- Pin All Available Dialogs to the Operator imopenlines.session.mode.pinAll
- Unpin All Operator Dialogs imopenlines.session.mode.unpinAll
- Switch the dialog to silent mode imopenlines.session.mode.silent
- Rate Employee Performance in the imopenlines.session.head.vote Dialog
- Start a New Dialogue Based on the Message imopenlines.message.session.start
- Create a Lead Based on the Dialogue imopenlines.crm.lead.create
- Get Information About the Operator's Dialog imopenlines.dialog.get