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. Up to 100 identifiers per call.
Request fields (body)
| Field | Type | Req. | Description |
|---|---|---|---|
sessionId |
number[] | yes | Array 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 collapsed: 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 still contains an object for it 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 |
|---|---|
sessionId |
Session identifier |
waitAnswer / waitClose |
Time to first answer and to close, seconds |
messagesCount |
Number of messages in the session |
messagesOperatorCount / messagesClientCount |
Operator and customer messages |
transfersCount |
Number of reassignments |
kpiFirstAnswer |
Whether the first-answer SLA was met |
vote |
Customer rating |
voteHead |
Supervisor rating (null if the user lacks permission) |
Response example
The third session is inaccessible or does not exist — 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 batch:
{
"success": false,
"error": { "code": "BATCH_LIMIT_EXCEEDED", "message": "sessionId batch must not exceed 100 unique ids" }
}
Errors
| HTTP | Code | When |
|---|---|---|
| 403 | B24_TARIFF_RESTRICTION |
The Bitrix24 plan does not include Open Channels statistics (report_open_lines) |
| 400 | INVALID_JSON_BODY |
The request body did not parse as JSON. The check runs before field validation, so the response says nothing about missing parameters |
| 400 | MISSING_PARAMS |
sessionId is an empty array or missing |
| 400 | INVALID_PARAMS |
A non-numeric element in sessionId |
| 400 | BATCH_LIMIT_EXCEEDED |
More than 100 unique identifiers (after collapsing duplicates) |
| 422 | METHOD_NOT_YET_AVAILABLE |
The imopenlines 26.700.0 update has not reached the portal yet. The response contains an error.release field set to imopenlines 26.700.0 |
The full list of system codes — API errors.