---
title: "Generate View Aggregation Data"
method: POST
path: "/v3/views/aggregation-data"
tags: ["Views"]
---

# Generate View Aggregation Data

`POST /v3/views/aggregation-data`

**Generate aggregation results for a view.**

Executes each aggregation declared on the view against the
`transformations` rows produced by the named functions inside the
supplied `timeWindow`, applying the view's filters. Supported
aggregation functions: `count`, `count_distinct`, `sum`, `average`,
`min`, `max`. Grouped aggregations return up to 200 groups per
aggregation; non-grouped aggregations return a single group with an
empty `groupName`.

As with table-data, the `functions` field is required.

## Request body

- ViewAggregationDataRequest
  - `name` string, required — Name of the view
  - `description` string — Description of the view
  - `columns` ViewColumn[], required — List of columns in the view
    - `name` string, required — Name of the column
    - `valueSchemaPath` string[], required — JSON path to the value in the transformation output schema (e.g., ["invoiceDetails", "invoiceNumber"])
    - `displayOrderIndex` integer, required — Order in which this column should be displayed (0-based index)
  - `filters` ViewFilter[], required — List of filters applied to the view
    - `columnName` string, required — Name of the column to filter on
    - `filterType` 'equals_string' | 'equals_number' | 'less_than_number' | 'less_than_equal_number' | 'greater_than_number' | 'greater_than_equal_number' | 'is_null' | 'is_not_null', required — Type of filter to apply to a view column
    - `string` string, nullable — String value for the filter (required for string filter types)
    - `number` number, float, nullable — Numeric value for the filter (required for number filter types)
  - `aggregations` ViewAggregation[], required — List of aggregations defined for the view
    - `name` string, required — Name of the aggregation
    - `function` 'count' | 'count_distinct' | 'sum' | 'average' | 'min' | 'max', required — Aggregation function to apply to a view column
    - `aggregateColumnName` string, nullable — Name of the column to aggregate (required for count_distinct, sum, average, min, max functions)
    - `groupByColumnName` string, nullable — Name of the column to group by (optional, for grouped aggregations)
    - `displayType` 'table' | 'bar_chart' | 'pie_chart' — How to display the aggregation results
  - `functions` FunctionIdentifier[], required — List of functions that this view queries transformations from
    - `id` string — Unique identifier of function. Provide either id or name, not both.
    - `name` string — Name of function. Must be UNIQUE on a per-environment basis. Provide either id or name, not both.
  - `timeWindow` TimeWindow, required — Time window for filtering transformations in a view
    - `start` string, date-time, required — Start of the time window in ISO 8601 (RFC 3339) format in UTC
    - `end` string, date-time, required — End of the time window in ISO 8601 (RFC 3339) format in UTC

## Response `200`

The request has succeeded.

- ViewAggregationDataResponse — Response containing aggregation data for a view
  - `aggregations` ViewAggregationDataResponseAggregation[], required — Array of aggregation results
    - `name` string, required — Name of the aggregation
    - `groups` ViewAggregationDataResponseGroup[], required — Array of group results (single group for non-grouped aggregations)
      - `groupName` string, required — Name of the group (empty string for non-grouped aggregations)
      - `value` number, float, required — Aggregated value for this group

## Other responses

- `400` — The server could not understand the request due to invalid syntax.

---

[API](https://skmtc.dev/bem-team/apis/bem-api.md) · [All operations](https://skmtc.dev/bem-team/apis/bem-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/bem-team/bem-api/revisions/a6e4624117c6/schema)
