[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fcatalog-skus\u002Faggregate":3,"docs-tabs-entities\u002Fcatalog-skus\u002Faggregate":6},{"content":4,"lastmod":5},"## Aggregate SKUs\n\n`POST \u002Fv1\u002Fcatalog-skus\u002Faggregate`\n\nCounts the parent products of a product catalog with filtering and grouping by section via `groupBy`.\n\nThe `dateCreate`, `timestampX`, `dateActiveFrom`, and `dateActiveTo` fields are not accepted in `filter`: the request returns `400 UNKNOWN_FILTER_FIELD` before calling Bitrix24. This endpoint does not support date-range filtering. Calculate aggregates for a specific period in your integration using records from the list endpoint, where these dates are available in `select` and responses.\n\n**Standard fields.** One field is available for grouping — `iblockSectionId`, the catalog section. The numeric functions `sum`, `avg`, `min`, `max` accept fields of type `number`, but on a parent product these are identifiers, `sort` and `type`, so the primary use case is counting products with `count` and grouping the results.\n\n## Request fields (body)\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `filter` | object | yes | Filtering by parent product fields. The `iblockId` key is required — the product catalog from [`GET \u002Fv1\u002Fcatalogs`](\u002Fdocs\u002Fentities\u002Fcatalogs). The `type` key accepts one exact number, `3` or `6`.\u003Cbr>[Filtering syntax](\u002Fdocs\u002Ffiltering) |\n| `aggregate` | array | no | Aggregations: `[{ \"field\": \"*\", \"function\": \"count\" }]`. Functions: `count`, `sum`, `avg`, `min`, `max`. For `count`, the field is `\"*\"`. Without the parameter — `count` only |\n| `groupBy` | string \\| string[] | no | Field or array of fields to group by (up to 5). Allowed value — `iblockSectionId` |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcatalog-skus\u002Faggregate\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"filter\": { \"iblockId\": 25 },\n    \"aggregate\": [{ \"field\": \"*\", \"function\": \"count\" }],\n    \"groupBy\": \"iblockSectionId\"\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcatalog-skus\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    \"filter\": { \"iblockId\": 25 },\n    \"aggregate\": [{ \"field\": \"*\", \"function\": \"count\" }],\n    \"groupBy\": \"iblockSectionId\"\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcatalog-skus\u002Faggregate', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    filter: { iblockId: 25 },\n    aggregate: [{ field: '*', function: 'count' }],\n    groupBy: 'iblockSectionId',\n  }),\n})\n\nconst { success, data } = await res.json()\nconsole.log(data.groups)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcatalog-skus\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    filter: { iblockId: 25 },\n    aggregate: [{ field: '*', function: 'count' }],\n    groupBy: 'iblockSectionId',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Other scenarios\n\nThe blocks below are request bodies.\n\nCount parent products without grouping — the fastest request, no records are fetched:\n\n```json\n{ \"filter\": { \"iblockId\": 25 } }\n```\n\nCount parent products without offers — `type` equals `6`:\n\n```json\n{ \"filter\": { \"iblockId\": 25, \"type\": 6 } }\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 parent products matching the filter |\n| `data.aggregates` | object | Results of numeric functions by field: `{ \"sort\": { \"max\": 500 } }`. Without numeric functions — an empty object |\n| `data.groups` | array | Groups — present only with `groupBy`. Each element: grouping fields + `count` + `aggregates` |\n| `data.meta.totalRecords` | number | Total number of records |\n| `data.meta.recordsProcessed` | number | Number of processed records (up to 5000). For a request without `groupBy` and numeric functions — `0` |\n| `data.meta.truncated` | boolean | `true` when the groups or 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 record shortfall is reported in `data.meta.recordsShortfall`, and details of the interrupted slice are reported 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. Present only with `groupBy` |\n| `data.meta.groupsTruncated` | boolean | `true` if the number of groups was limited. Present only with `groupBy` |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"count\": 14,\n    \"aggregates\": {},\n    \"groups\": [\n      { \"iblockSectionId\": null, \"count\": 11, \"aggregates\": {} },\n      { \"iblockSectionId\": 85, \"count\": 1, \"aggregates\": {} },\n      { \"iblockSectionId\": 19, \"count\": 2, \"aggregates\": {} }\n    ],\n    \"meta\": {\n      \"totalRecords\": 14,\n      \"recordsProcessed\": 14,\n      \"truncated\": false,\n      \"groupTotal\": 3,\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 — a field outside the list available for grouping:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"groupBy field 'nonexistent' is not aggregatable on this entity. Available: iblockSectionId.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `MISSING_REQUIRED_FILTER` | The required `filter.iblockId` filter was not passed — checked before the Bitrix24 call (an example body is in the message) |\n| 400 | `UNKNOWN_FILTER_FIELD` | Unknown filter field or a date field: `dateCreate`, `timestampX`, `dateActiveFrom`, `dateActiveTo`. The message contains the list of available fields |\n| 400 | `UNSUPPORTED_FILTER` | The `filter.type` key was passed as something other than one number, `3` or `6` |\n| 400 | `INVALID_PARAMS` | The `groupBy` field is outside the available list — the message lists the allowed ones |\n| 400 | `INVALID_PARAMS` | A numeric function over a field that is not among the numeric fields of a parent product — the message lists them: `Field '\u003Cname>' not found. Available numeric fields: ...` |\n| 400 | `INVALID_PARAMS` | Unknown function — `Invalid aggregate function '\u003Cname>'. Supported: count, sum, avg, min, max` |\n| 400 | `INVALID_PARAMS` | More than 5 fields passed in `groupBy` |\n| 422 | `BITRIX_ERROR` | `iblockId` points to an offer catalog (`productType is not allowed for this catalog`) |\n| 403 | `SCOPE_DENIED` | The API key does not have the `catalog` scope |\n| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |\n| 429 | `RATE_LIMITED` | Rate limit exceeded: 300 requests per minute per portal. All API keys of the portal share one limit. The current limit is returned in the `x-ratelimit-limit` header. Retry after the delay in the `Retry-After` header |\n\nFor the full list of common API errors, see [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**`count` is resolved in one request, grouping and numeric functions are not.** A request without `groupBy` and numeric functions is counted in a single call regardless of the size of the result set. With `groupBy` or the `sum`, `avg`, `min`, `max` functions, records are loaded page by page — up to 5000 — and counted on the server side. If more than 5000 records match the filter, `meta.truncated` is `true`, and the groups and aggregates are built over the first 5000. The ceiling is not the only reason for this marker: it also appears when fewer records were read than `data.count` promised, and the size of the gap is reported in `data.meta.recordsShortfall`.\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 SKUs](\u002Fdocs\u002Fentities\u002Fcatalog-skus\u002Flist)\n- [Search SKUs](\u002Fdocs\u002Fentities\u002Fcatalog-skus\u002Fsearch)\n- [SKU fields](\u002Fdocs\u002Fentities\u002Fcatalog-skus\u002Ffields)\n- [Filtering syntax](\u002Fdocs\u002Ffiltering)\n- [Limits and optimization](\u002Fdocs\u002Foptimization)\n","2026-10-23",{},1795415203918]