query_records
Search, filter, sort, paginate, and aggregate records in a collection. Use action='search' (default) for raw records, action='aggregate' for grouped analytics (count, sum, avg, min, max).
Filter and sort expressions use the Filter DSL syntax.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspace_id | string | Yes | Target workspace ID |
collection | string | Yes | Collection name or ID |
action | enum | Yes | 'search' returns records (default). 'aggregate' returns grouped aggregations. |
filter | object | No | |
sort | array | Yes | |
field | string | Yes | |
direction | enum: asc | desc | No | Sort order |
limit | number | No | Max records to return |
offset | number | No | Pagination offset |
fields | array | No | Subset of fields to return (search only) |
external_source | string | No | Query a specific external source (e.g. 'stripe'). Search only. |
aggregations | array | Yes | |
fn | enum: count | sum | avg | min | max | Yes | |
field | string | No | |
alias | string | No | Aggregation functions. Required when action='aggregate'. count needs no field; sum/avg/min/max require field. |
group_by | array | No | Fields to group by (e.g. ['data.status']). Used with action='aggregate'. |