Records

Aggregate records

POST
/api/records/aggregate

Computes count and sum metrics over the records matching filter, optionally grouped. When there are more than 100 groups, the response has meta.next; send it back as next (alone) to get the next batch.

Authorization

bearerAuth
AuthorizationBearer <token>

Access token from POST /oauth2/token (valid for 300 seconds).

In: header

Request Body

application/json

next?string

Cursor from meta.next of the previous response. When set, send only this field.

metrics?

Metrics to compute, keyed by your own metric name (e.g. total_revenue).

filter?

Filter criteria. Every record field can be used; all conditions must match.

group_by?
options?

Response Body

application/json

curl -X POST "https://example.com/api/records/aggregate" \  -H "Content-Type: application/json" \  -d '{    "metrics": {      "total_revenue": {        "func": "sum",        "key": "range_key3"      },      "transaction_count": {        "func": "count"      }    },    "filter": {      "range_key2": {        "$gte": 1000,        "$lte": 4000      },      "key4": "Order with Shipping"    },    "group_by": {      "limit": 100,      "keys": [        "key4"      ]    }  }'
{  "data": {    "property1": {      "group": {        "keys": {          "property1": "string",          "property2": "string"        }      },      "metrics": {        "property1": 0,        "property2": 0      }    },    "property2": {      "group": {        "keys": {          "property1": "string",          "property2": "string"        }      },      "metrics": {        "property1": 0,        "property2": 0      }    }  },  "meta": {    "next": "string"  },  "errors": [    "string"  ]}