For AI agents: markdown of this page — /docs-content-en/openlines/sessions/stats.md documentation index — /llms.txt
Per-session metrics
The method ships in the
imopenlines 26.700.0update and is not yet available on all Bitrix24 accounts. If the update has not reached your Bitrix24 account yet, the API returns422 METHOD_NOT_YET_AVAILABLE— this means the method has not been released on the account yet, not that the integration is broken.
POST /v1/openlines/sessions/stats
Batch metrics for specific sessions — time to answer and to close, message counters, number of transfers, rating.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
FieldsessionId |
Typenumber[] | Requiredyes | DescriptionArray of session identifiers, up to 100 elements. Source: POST /v1/openlines/sessions/search. A single number is also accepted and wrapped in an array |
Duplicates in sessionId are counted once: each unique identifier is returned once. A sessionId that does not exist, belongs to someone else, or is not accessible does not cause an error — the response contains an object with that sessionId and null in every metric.
Examples
curl — personal key
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/sessions/stats" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "sessionId": [1024, 1025, 999999] }'
curl — OAuth application
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/sessions/stats" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "sessionId": [1024, 1025, 999999] }'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/sessions/stats', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ sessionId: [1024, 1025, 999999] }),
})
const { data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/sessions/stats', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ sessionId: [1024, 1025, 999999] }),
})
const { data } = await res.json()
Response fields
The response is { "success": true, "data": { "sessions": [...] } }. One object per unique requested sessionId, including inaccessible ones (with null fields).
| Key | Description |
|---|---|
KeysessionId |
DescriptionSession identifier |
KeywaitAnswer / waitClose |
DescriptionTime to the first answer and to closing, seconds |
KeymessagesCount |
DescriptionNumber of messages in the session |
KeymessagesOperatorCount / messagesClientCount |
DescriptionOperator and client messages |
KeytransfersCount |
DescriptionNumber of reassignments |
KeykpiFirstAnswer |
DescriptionWhether the first-answer time target (SLA) was met |
Keyvote |
DescriptionClient rating |
KeyvoteHead |
DescriptionSupervisor rating (null if there is no permission) |
Response example
The third session is inaccessible or does not exist — it is returned as an object with null fields:
{
"success": true,
"data": {
"sessions": [
{ "sessionId": 1024, "waitAnswer": 65, "waitClose": 1330, "messagesCount": 14, "messagesOperatorCount": 6, "messagesClientCount": 8, "transfersCount": 1, "kpiFirstAnswer": true, "vote": "like", "voteHead": 5 },
{ "sessionId": 1025, "waitAnswer": 12, "waitClose": 340, "messagesCount": 5, "messagesOperatorCount": 2, "messagesClientCount": 3, "transfersCount": 0, "kpiFirstAnswer": true, "vote": "none", "voteHead": null },
{ "sessionId": 999999, "waitAnswer": null, "waitClose": null, "messagesCount": null, "messagesOperatorCount": null, "messagesClientCount": null, "transfersCount": null, "kpiFirstAnswer": null, "vote": null, "voteHead": null }
]
}
}
Error response example
400 — more than 100 identifiers in the request:
{
"success": false,
"error": { "code": "BATCH_LIMIT_EXCEEDED", "message": "sessionId batch must not exceed 100 unique ids" }
}
Errors
| HTTP | Code | When |
|---|---|---|
| HTTP403 | CodeB24_TARIFF_RESTRICTION |
WhenThe plan does not include Open Channels statistics (report_open_lines) |
| HTTP400 | CodeINVALID_JSON_BODY |
WhenThe request body did not parse as JSON. JSON is parsed before the fields are checked, so the response says nothing about missing parameters |
| HTTP400 | CodeMISSING_PARAMS |
WhensessionId is an empty array or is missing |
| HTTP400 | CodeINVALID_PARAMS |
WhenA non-numeric element in sessionId |
| HTTP400 | CodeBATCH_LIMIT_EXCEEDED |
WhenMore than 100 unique identifiers (duplicates are counted once) |
| HTTP422 | CodeMETHOD_NOT_YET_AVAILABLE |
WhenThe imopenlines 26.700.0 update has not reached the Bitrix24 account yet. The response contains an error.release field set to imopenlines 26.700.0 |
Full list of system codes — API errors.