---
title: "Aggregate table rows"
method: POST
path: "/v1/tables/{tableId}/rows/aggregate"
tags: ["Tables"]
---

# Aggregate table rows

`POST /v1/tables/{tableId}/rows/aggregate`

## Request

- Base URL: `https://api.banksync.io`
- URL: `https://api.banksync.io/v1/tables/{tableId}/rows/aggregate`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Sum, count, average, min or max a field, optionally grouped by up to three fields and filtered. Set `computed: true` to read the derived document instead of the stored one. A read, expressed as POST because the filter set does not fit a query string. Prefer `POST /{tableId}/rows/query`, which answers rows, groups and calculations over one filtered set.

## Path parameters

- `tableId` string, required: Table ID

## Request body

- object
  - `fieldKey` string
  - `computed` boolean
  - `op` 'sum' | 'count' | 'avg' | 'min' | 'max', required
  - `groupBy` string[]
  - `filters` object[]
    - `fieldKey` string, required
    - `computed` boolean
    - `op` 'eq' | 'neq' | 'contains' | 'gt' | 'gte' | 'lt' | 'lte' | 'is_null' | 'not_null', required
    - `value` unknown
  - `limit` integer

## Response `200`

Aggregate groups

- object
  - `success` true, required
  - `groups` object[], required
    - `key` object, required
    - `value` number, nullable, required

## Other responses

- `400`: Validation failed, or a read-only field was written — `code` names the refusal and `details[]` the offending field or cell
- `401`: Unauthorized
- `403`: Forbidden — missing scope, insufficient role, or plan limit reached
- `404`: Not found

---

[API](https://skmtc.dev/banksync/apis/banksync-api.md) · [All operations](https://skmtc.dev/banksync/apis/banksync-api/llms.txt) · [OpenAPI document](https://skmtc.dev/banksync/apis/banksync-api/revisions/94465f5ee922?raw)
