Skip to main content
POST
Aggregate entity records

Authorizations

Authorization
string
header
required

Personal access token, sent as Authorization: Bearer <token>.

Path Parameters

app_id
string
required

ID of the app that owns the entity.

entity_name
string
required

Name of the entity, exactly as List entity schemas reports it. Don't pass User here. It doesn't fail, but it reads and writes a separate, disconnected set of records stored under that name, not the app's real user accounts, which are managed through their own endpoints.

Body

application/json

The wire body of POST /{entity}/aggregate. Keys are camelCase on the wire (the SDK's vocabulary).

query
Query · object

Filter selecting the records to aggregate, in the same form as q on List entity records. Leave it out to aggregate every record you can read.

Example:
group_by
string[]

Up to 4 fields to group by, as a list or a single field name. Each row holds one combination of their values. Leave it out, along with date_bucket, for one row over all matching records.

Example:
date_bucket
DateBucket · object | null

Also groups by the period a date falls in, such as the day or month a record was created.

count
boolean
default:true

Whether each row includes count, the number of records in the group.

Example:

true

sum
string[]

Number fields to total, as a list or a single field name. Each adds sum_<field> to the rows.

Example:
avg
string[]

Number fields to average, as a list or a single field name. Each adds avg_<field> to the rows.

Example:
min
string[]

Fields whose smallest value to return, as a list or a single field name. Each adds min_<field> to the rows.

Example:
max
string[]

Fields whose largest value to return, as a list or a single field name. Each adds max_<field> to the rows.

Example:
count_distinct
string | null

One field whose distinct values to count, leaving out null. Adds count_distinct_<field> to the rows.

Example:

"customer_email"

having
Having · object

Filter on the computed values, applied after grouping. Name count or a computed field such as sum_amount, with a value to match or with $eq, $ne, $gt, $gte, $lt, $lte, $in or $nin.

Example:
sort
string | null

Group field or computed field to sort the rows by, prefixed with - for descending. Without it, the order of the rows isn't defined.

Example:

"-sum_amount"

limit
integer
default:1000

Maximum number of rows to return, from 1 to 1000.

Required range: 1 <= x <= 1000
Example:

100

Response

The computed values.

The computed values, one row per group.

rows
Rows · object[]
required

One row per group. A row holds each group field and the date_bucket field under its own name, then count and the sum_<field>, avg_<field>, min_<field>, max_<field> and count_distinct_<field> values you asked for. In those computed names, a dot in the field name becomes _. Date values, such as a date_bucket or a min_created_date, are UTC timestamps in ISO 8601 format with an offset.

Example:
truncated
boolean
required

true when more groups matched than limit, so some were left out.

Example:

false