لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/openlines/stats.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Channel aggregates for a period
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/stats
Summary metrics of Open Channels for a period — session counters, average time to first answer and average session duration, customer satisfaction (CSAT), and breakdowns by connector, hour, and operator. The main method for the summary widgets of a statistics dashboard. The request is resource-intensive: call it no more than once every 30–60 seconds and cache the result.
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
FielddateFrom |
Typestring | Requiredyes | DescriptionPeriod start, ISO 8601. The dateFrom..dateTo period must not exceed 1 year |
FielddateTo |
Typestring | Requiredyes | DescriptionPeriod end, ISO 8601 |
FieldconfigId |
Typenumber | Requiredno | DescriptionOpen Channel identifier. Source: GET /v1/openline-configs |
FieldconfigIdList |
Typenumber[] | Requiredno | DescriptionList of Open Channel identifiers. Source: GET /v1/openline-configs |
Fieldsource |
Typestring | Requiredno | DescriptionConnector code, for example livechat. Values: the sessionsBySource[].source field in the response of this method or sessions[].source in the response of POST /v1/openlines/sessions/search |
FieldsourceList |
Typestring[] | Requiredno | DescriptionList of connector codes |
FieldoperatorId |
Typenumber | Requiredno | DescriptionOperator identifier. Source: GET /v1/users |
FieldoperatorIdList |
Typenumber[] | Requiredno | DescriptionList of operator identifiers. Source: GET /v1/users |
If none of configId*/source*/operatorId* is set, aggregates are computed over all Open Channels available to the current user.
Examples
curl — personal key
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/stats" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"dateFrom": "2026-10-01T00:00:00+00:00",
"dateTo": "2026-10-19T23:59:59+00:00",
"configId": 59
}'
curl — OAuth application
curl -X POST "https://vibecode.bitrix24.com/v1/openlines/stats" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dateFrom": "2026-10-01T00:00:00+00:00",
"dateTo": "2026-10-19T23:59:59+00:00",
"configId": 59
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/stats', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
dateFrom: '2026-10-01T00:00:00+00:00',
dateTo: '2026-10-19T23:59:59+00:00',
configId: 59,
}),
})
const { data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/openlines/stats', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
dateFrom: '2026-10-01T00:00:00+00:00',
dateTo: '2026-10-19T23:59:59+00:00',
configId: 59,
}),
})
const { data } = await res.json()
Response fields
When there is no data for the period, numeric metrics are returned as 0, not null. In that case the sessionsBySource and sessionsByOperator breakdowns arrive as empty arrays.
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue on a successful request |
Fielddata |
Typeobject | DescriptionMetrics for the period |
Fielddata.totalSessions |
Typenumber | DescriptionNumber of sessions in the period |
Fielddata.closedSessions |
Typenumber | DescriptionNumber of closed sessions |
Fielddata.spamSessions |
Typenumber | DescriptionNumber of sessions marked as spam |
Fielddata.avgWaitAnswer |
Typenumber | DescriptionAverage time to first answer, seconds |
Fielddata.avgSessionDuration |
Typenumber | DescriptionAverage session duration, seconds |
Fielddata.likeCount |
Typenumber | DescriptionNumber of "like" customer ratings |
Fielddata.dislikeCount |
Typenumber | DescriptionNumber of "dislike" customer ratings |
Fielddata.votedSessions |
Typenumber | DescriptionNumber of sessions with a customer rating |
Fielddata.positiveRate |
Typenumber | DescriptionShare of positive ratings among rated sessions, from 0 to 1 |
Fielddata.kpiFirstAnswerOk |
Typenumber | DescriptionNumber of sessions where the first answer met the response-time target (SLA) |
Fielddata.kpiFirstAnswerFail |
Typenumber | DescriptionNumber of sessions where the first answer missed the response-time target |
Fielddata.sessionsBySource |
Typeobject[] | DescriptionBreakdown by connector |
Fielddata.sessionsBySource[].source |
Typestring | DescriptionConnector code, for example livechat |
Fielddata.sessionsBySource[].count |
Typenumber | DescriptionNumber of sessions from the connector |
Fielddata.sessionsByHour |
Typenumber[] | DescriptionExactly 24 numbers — sessions by hour 0–23 in the server time zone of the Bitrix24 account. The element index is the hour |
Fielddata.sessionsByOperator |
Typeobject[] | DescriptionBreakdown by operator |
Fielddata.sessionsByOperator[].operatorId |
Typenumber | DescriptionOperator identifier. Employee data: GET /v1/users |
Fielddata.sessionsByOperator[].count |
Typenumber | DescriptionNumber of the operator's sessions |
Fielddata.sessionsByOperator[].avgWaitAnswer |
Typenumber | DescriptionAverage time to first answer, seconds |
Fielddata.sessionsByOperator[].positiveRate |
Typenumber | DescriptionShare of positive ratings among the operator's rated sessions, from 0 to 1 |
Response example
{
"success": true,
"data": {
"totalSessions": 6,
"closedSessions": 5,
"spamSessions": 1,
"avgWaitAnswer": 0,
"avgSessionDuration": 0,
"likeCount": 0,
"dislikeCount": 0,
"votedSessions": 0,
"positiveRate": 0,
"kpiFirstAnswerOk": 0,
"kpiFirstAnswerFail": 0,
"sessionsBySource": [
{ "source": "doccheck", "count": 6 }
],
"sessionsByHour": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,0,0,0,0],
"sessionsByOperator": [
{ "operatorId": 1295, "count": 4, "avgWaitAnswer": 0, "positiveRate": 0 },
{ "operatorId": 1, "count": 2, "avgWaitAnswer": 0, "positiveRate": 0 }
]
}
}
Error response example
400 — the period is missing:
{
"success": false,
"error": { "code": "MISSING_PARAMS", "message": "Required: dateFrom, dateTo (ISO 8601 strings)" }
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_JSON_BODY |
DescriptionThe request body did not parse as JSON. JSON is parsed before field validation, so the response says nothing about missing parameters |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionThe request body is not an object |
| HTTP400 | CodeMISSING_PARAMS |
DescriptiondateFrom and/or dateTo is missing, or the value is not a string or is an empty string |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe key has no configured tokens |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe key has no imopenlines scope |
| HTTP403 | CodeB24_TARIFF_RESTRICTION |
DescriptionThe Bitrix24 plan does not include Open Channels statistics (report_open_lines) |
| HTTP422 | CodeBITRIX_ERROR (error.b24Code: INVALID_FILTER) |
DescriptionAn invalid filter value or date format |
| HTTP422 | CodeBITRIX_ERROR (error.b24Code: PERIOD_TOO_LARGE) |
DescriptionThe period exceeds 1 year |
| HTTP422 | CodeMETHOD_NOT_YET_AVAILABLE |
DescriptionThe imopenlines 26.700.0 update has not reached the portal yet. The response contains an error.release field set to imopenlines 26.700.0 |
Full list of common API errors — Errors.