---
title: "Aggregate cases"
method: POST
path: "/api/v2/cases/aggregate"
tags: ["Case Management"]
---

# Aggregate cases

`POST /api/v2/cases/aggregate`

Performs an aggregation query over cases, grouping results by specified fields and returning counts per group along with a total. Useful for dashboards and analytics.

## Request body

- CaseAggregateRequest — Request payload for aggregating case counts with grouping. Use this to get faceted breakdowns of cases (for example, count of cases grouped by priority and status).
  - `data` CaseAggregateRequestData, required — Data object wrapping the aggregation query type and attributes.
    - `attributes` CaseAggregateRequestAttributes, required — Attributes for the aggregation request, including the search query and grouping configuration.
      - `group_by` CaseAggregateGroupBy, required — Configuration for grouping aggregated results by one or more case fields.
        - `groups` string[], required — Fields to group by.
        - `limit` integer, required — Maximum number of groups to return.
      - `query_filter` string, required — A search query to filter which cases are included in the aggregation. Uses the same syntax as the Case Management search bar.
    - `type` 'aggregate', required — JSON:API resource type for case aggregation requests.

## Response `200`

OK

- CaseAggregateResponse — Response containing aggregated case counts grouped by the requested fields.
  - `data` CaseAggregateResponseData, required — Data object containing the aggregation results, including total count and per-group breakdowns.
    - `attributes` CaseAggregateResponseAttributes, required — Attributes of the aggregation result, including the total count across all groups and the per-group breakdowns.
      - `groups` CaseAggregateGroup[], required — Aggregated groups.
        - `group` string, required — The value of the field being grouped on (for example, `OPEN` when grouping by status).
        - `value` number[], required — The count of cases in this group.
      - `total` number, double, required — Total count of aggregated cases.
    - `id` string, required — Aggregate response identifier.
    - `type` string, required — Aggregate resource type.

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `429` — Too many requests

---

[API](https://skmtc.net/datadog/apis/api-v2.md) · [All operations](https://skmtc.net/datadog/apis/api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/datadog/api-v2/versions/da68bf029e4c/schema)
