[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-openlines\u002Fconfig\u002Faggregate":3,"docs-tabs-openlines\u002Fconfig\u002Faggregate":6},{"content":4,"lastmod":5},"\n## Aggregate Open Channel configurations\n\n`POST \u002Fv1\u002Fopenline-configs\u002Faggregate`\n\nCounts the number of Open Channel configurations with optional grouping by queue type and other schema fields.\n\n**Grouping.** `groupBy` accepts 2 fields: `active`, `queueType` — these are the `aggregatable` fields from [`GET \u002Fv1\u002Fopenline-configs\u002Ffields`](\u002Fdocs\u002Fopenlines\u002Fconfig\u002Ffields). The remaining fields (`id`, `name`, `workTimeFrom`, `workTimeTo`, and other camelCase response fields) are rejected with `400 INVALID_PARAMS` when passed in `groupBy` — details in [Known specifics](#known-specifics).\n\n**Numeric aggregations (`sum`\u002F`avg`\u002F`min`\u002F`max`) do not apply.** Open Channel configuration fields are categorical or identifier fields. Only the `count` function with `field: \"*\"` is supported.\n\n## Request fields (body)\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `aggregate` | array | no | Array of aggregations. Each element: `{ \"field\": \"*\", \"function\": \"count\" }`. The `count` function requires `field: \"*\"`. Without the parameter — only `count` |\n| `filter` | object | no | Filtering. [Filtering syntax](\u002Fdocs\u002Ffiltering). Example: `{\"active\": false}` |\n| `groupBy` | string \\| string[] | no | Field or array of fields to group by. Allowed values: `active`, `queueType` — see [Known specifics](#known-specifics) |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenline-configs\u002Faggregate\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"groupBy\": \"queueType\"\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenline-configs\u002Faggregate\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"groupBy\": \"queueType\"\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenline-configs\u002Faggregate', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    groupBy: 'queueType',\n  }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Total configurations:', data.count)\nconsole.log('By queue type:', data.groups)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fopenline-configs\u002Faggregate', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    groupBy: 'queueType',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n> To group by multiple fields, pass an array: `\"groupBy\": [\"queueType\", \"active\"]`. Combinations of the 2 allowed fields are accepted: `active`, `queueType`.\n\n## Other scenarios\n\nThe blocks below are request bodies.\n\nThe total number of configurations — the fastest query, without fetching records:\n\n```json\n{}\n```\n\nPassing `count` explicitly via `aggregate`:\n\n```json\n{\n  \"aggregate\": [{ \"field\": \"*\", \"function\": \"count\" }]\n}\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.count` | number | Total number of configurations in the result set (after applying the filter, if it took effect). This is the primary metric for your application |\n| `data.aggregates` | object | Numeric-function results grouped by field name. Open Channel configurations have no numeric fields, so the object is always empty |\n| `data.groups` | array | Groups (only when `groupBy` is set). Each element: the grouping field + `count` + `aggregates` |\n| `data.meta.totalRecords` | number | Total number of configurations — the same number as `data.count` |\n| `data.meta.recordsProcessed` | number | How many records were actually processed during grouping. `0` if `groupBy` is not set |\n| `data.meta.truncated` | boolean | `true` when the numbers were computed over only some of the records that match the filter: fewer records were read than `data.count` promised — including when more than 5000 matched the filter — or the slice was cut short by a sub-page error. The size of the gap is reported in `data.meta.recordsShortfall`, the interrupted slice in `data.meta.pageErrorSample`. Always present, and `false` on a complete response. If the request has neither `groupBy` nor a numeric function, no records are fetched and the flag is always `false` |\n| `data.meta.groupTotal` | number | Number of groups in the result (only when `groupBy` is set) |\n| `data.meta.groupsTruncated` | boolean | Whether the group list was truncated (only when `groupBy` is set) |\n\n## Response example\n\nResponse to the main query (`groupBy: \"queueType\"`):\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"count\": 10,\n    \"aggregates\": {},\n    \"groups\": [\n      { \"queueType\": \"all\", \"count\": 9, \"aggregates\": {} },\n      { \"queueType\": \"evenly\", \"count\": 1, \"aggregates\": {} }\n    ],\n    \"meta\": {\n      \"totalRecords\": 10,\n      \"recordsProcessed\": 10,\n      \"truncated\": false,\n      \"groupTotal\": 2,\n      \"groupsTruncated\": false\n    }\n  }\n}\n```\n\nWithout `groupBy` the `data.groups` field is absent from the response.\n\n## Error response example\n\n400 — the `count` function with an invalid field name:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"count aggregate requires field \\\"*\\\"\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | The `count` function was passed with `field` not equal to `\"*\"`, or `groupBy` referenced a field outside the Vibecode schema |\n| 401 | `TOKEN_MISSING` | The API key has no configured tokens |\n| 403 | `SCOPE_DENIED` | The API key lacks the `imopenlines` scope |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**The `filter` parameter is ignored in aggregation.** Passing `{\"filter\": {\"active\": false}}` has no effect on the result — the method returns the `count` across all configurations in your Bitrix24 account. To get counts for a subset, use `groupBy` (for example, `groupBy: [\"active\"]` splits the result by the activity flag) or process the result of [`POST \u002Fv1\u002Fopenline-configs\u002Fsearch`](\u002Fdocs\u002Fopenlines\u002Fconfig\u002Fsearch) on the client side.\n\n**The `count` function requires `field: \"*\"`.** Passing `{\"field\": \"id\", \"function\": \"count\"}` returns `400 INVALID_PARAMS`. The only correct format: `{\"field\": \"*\", \"function\": \"count\"}`.\n\n**`groupBy` accepts only 2 fields from the Vibecode schema:** `active`, `queueType`. These are the `aggregatable` fields from the [`GET \u002Fv1\u002Fopenline-configs\u002Ffields`](\u002Fdocs\u002Fopenlines\u002Fconfig\u002Ffields) response. The remaining fields (`id`, `name`, `workTimeFrom`, `workTimeTo`, `queueTime`, `crm`, ...) are rejected with `400 INVALID_PARAMS` when passed in `groupBy`, with the message \"groupBy field 'X' is not aggregatable on this entity. Available: active, queueType\".\n\n**The truncation marker travels with the number itself.** When a response arrives with `meta.truncated: true`, the marker `truncated: true` sits inside every field object in `data.aggregates` and on every element of `data.groups`, and `data.meta.warnings` gains a warning with the code `AGGREGATE_TRUNCATED`. A client that reads only the number itself therefore sees that it was computed over only some of the records. None of these markers appear on a complete response. Full details — [Aggregation POST — the 5000-record ceiling](\u002Fdocs\u002Fentity-api#aggregation-post-the-5000-record-ceiling).\n\n## See also\n\n- [List configurations](\u002Fdocs\u002Fopenlines\u002Fconfig\u002Flist)\n- [Filtering syntax](\u002Fdocs\u002Ffiltering)\n- [Limits and optimization](\u002Fdocs\u002Foptimization)\n","2026-09-22",{},1794739593993]