## Aggregate Agent Data

`AgentDataAggregatePage beta().agentData().aggregate(AgentDataAggregateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/api/v1/beta/agent-data/:aggregate`

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

### Parameters

- `AgentDataAggregateParams params`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `String deploymentName`

    The agent deployment's name to aggregate data for

  - `Optional<String> collection`

    The logical agent data collection to aggregate data for

  - `Optional<Boolean> count`

    Whether to count the number of items in each group

  - `Optional<Filter> filter`

    A filter object or expression that filters resources listed in the response.

    - `Optional<Eq> eq`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<List<Exclude>> excludes`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<Gt> gt`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<Gte> gte`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<List<Include>> includes`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<Lt> lt`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<Lte> lte`

      - `double`

      - `String`

      - `LocalDateTime`

    - `Optional<Ne> ne`

      - `double`

      - `String`

      - `LocalDateTime`

  - `Optional<Boolean> first`

    Whether to return the first item in each group (Sorted by created_at)

  - `Optional<List<String>> groupBy`

    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

  - `Optional<Long> offset`

    The offset to start from. If not provided, the first page is returned

  - `Optional<String> orderBy`

    A comma-separated list of fields to order by, sorted in ascending order. Use 'field_name desc' to specify descending order.

  - `Optional<Long> pageSize`

    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.

  - `Optional<String> pageToken`

    A page token, received from a previous list call. Provide this to retrieve the subsequent page.

### Returns

- `class AgentDataAggregateResponse:`

  API Result for a single group in the aggregate response

  - `GroupKey groupKey`

  - `Optional<Long> count`

  - `Optional<FirstItem> firstItem`

### Example

```java
package com.llamacloud_prod.api.example;

import com.llamacloud_prod.api.client.LlamaCloudClient;
import com.llamacloud_prod.api.client.okhttp.LlamaCloudOkHttpClient;
import com.llamacloud_prod.api.models.beta.agentdata.AgentDataAggregatePage;
import com.llamacloud_prod.api.models.beta.agentdata.AgentDataAggregateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        AgentDataAggregateParams params = AgentDataAggregateParams.builder()
            .deploymentName("deployment_name")
            .build();
        AgentDataAggregatePage page = client.beta().agentData().aggregate(params);
    }
}
```

#### Response

```json
{
  "items": [
    {
      "group_key": {
        "foo": "bar"
      },
      "count": 0,
      "first_item": {
        "foo": "bar"
      }
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```
