---
title: "Aggregate Agent Data"
method: POST
path: "/api/v1/beta/agent-data/:aggregate"
tags: ["Beta", "Agent Data"]
---

# Aggregate Agent Data

`POST /api/v1/beta/agent-data/:aggregate`

Aggregate agent data with grouping and optional counting/first item retrieval.

## Query parameters

- `project_id` string, uuid, nullable
- `organization_id` string, uuid, nullable

## Cookies

- `session` string, nullable

## Request body

- AggregateRequest — API request body for aggregating agent data
  - `page_size` integer, nullable — The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum.
  - `page_token` string, nullable — A page token, received from a previous list call. Provide this to retrieve the subsequent page.
  - `filter` object, nullable — A filter object or expression that filters resources listed in the response.
  - `order_by` string, nullable — A comma-separated list of fields to order by, sorted in ascending order. Use 'field_name desc' to specify descending order.
  - `deployment_name` string, required — The agent deployment's name to aggregate data for
  - `collection` string — The logical agent data collection to aggregate data for
  - `group_by` string[], nullable — The fields to group by. If empty, the entire dataset is grouped on. e.g. if left out, can be used for simple count operations
  - `count` boolean, nullable — Whether to count the number of items in each group
  - `first` boolean, nullable — Whether to return the first item in each group (Sorted by created_at)
  - `offset` integer, nullable — The offset to start from. If not provided, the first page is returned

## Response `200`

Successful Response

- PaginatedResponseAggregateGroup
  - `items` AggregateGroup[], required — The list of items.
    - `group_key` object, required
    - `count` integer, nullable
    - `first_item` object, nullable
  - `next_page_token` string, nullable — A token, which can be sent as page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.
  - `total_size` integer, nullable — The total number of items available. This is only populated when specifically requested. The value may be an estimate and can be used for display purposes only.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/run-llama/apis/llama-platform.md) · [All operations](https://skmtc.net/run-llama/apis/llama-platform/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/run-llama/llama-platform/versions/b17341164de9/schema)
