Get Message History of the Dialogue imopenlines.session.history.get
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to 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
// 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 SessionHistoryResult = {
chatId: number
canJoin: string
canVoteHead: string
sessionId: number
sessionVoteHead: number
sessionCommentHead: string | null
userId: string
message: Record<string, {
id: string
chatid: string
senderid: string
recipientid: string
date: ISODate
text: string
textlegacy: string
params: Record<string, unknown>
}>
usersMessage: Record<string, string[]>
users: Record<string, {
id: string
name: string
firstName: string
lastName: string
workPosition: string | null
avatar: string
avatarId: string | null
gender: string
extranet: boolean
connector: boolean
profile: string
externalAuthId: string
status: string | null
lastActivityDate: ISODate
departments: number[]
type: string
}>
openlines: Record<string, Record<string, boolean>>
userInGroup: Record<string, { id: number; users: string[] }>
woUserInGroup: string[]
chat: Record<string, {
id: string
name: string
owner: string
entityType: string
entityId: string
entityData1: string
entityData2: string
entityData3: string
messageCount: number
public: string
muteList: Record<string, boolean>
managerList: number[]
dateCreate: ISODate
type: string
entityLink: Record<string, unknown>
permissions: Record<string, string>
textFieldEnabled: boolean
backgroundId: number | null
messageType: string
isNew: boolean
}>
userBlockChat: Record<string, Record<string, boolean>>
userInChat: Record<string, number[]>
files: Record<string, {
id: number
chatid: number
date: ISODate
type: string
name: string
extension: string
size: number
status: string
progress: number
authorid: number
authorname: string
urlpreview: string
urlshow: string
urldownload: string
}>
}
try {
const response = await $b24.actions.v2.call.make<SessionHistoryResult>({
method: 'imopenlines.session.history.get',
params: {
SESSION_ID: 321,
},
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.sessionId, result.chatId, Object.keys(result.message).length)
}
} 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 getSessionHistory() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'imopenlines.session.history.get',
params: {
SESSION_ID: 321,
},
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.sessionId, result.chatId, Object.keys(result.message).length)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', getSessionHistory)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.imopenlines.session.history.get(
session_id=321,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Bitrix API error",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Bitrix SDK error: {error.message}")
except Exception as error:
print(f"Unexpected 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);
}
// client and ctx are already created — see the Go SDK section
res, err := client.Core().Call(ctx, "imopenlines.session.history.get", b24.Params{
"SESSION_ID": 321,
}, b24.WithIdempotent())
if err != nil {
return fmt.Errorf("imopenlines.session.history.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": {
"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 consists of digits, Latin letters, and underscores. It may arrive empty — in that case only |
|
error_description |
Error message for the developer. Do not show it to the end user without processing |
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: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it 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