API reference
Aggregate a custom-source dataset
POST /v1/datasets/{datasetId}/query
Aggregates the dataset’s current published data: count_rows, count, sum, avg,
min and max over columns named by id, optionally grouped (text, date and boolean
columns; a date column by day, week or month) and filtered (eq, range,
is_null). A request names columns by their stable ids, never by header text. Several
requests are not one snapshot of the source; one request is read from one set of
published generations, which provenance.generations names.
A percent column is not summed unless the request sets allow_percent_sum: true. An
average, minimum or maximum over no values is null, never 0. A cell that is a formula
error is left out of the aggregates and counted in a limitation column of the result.
Bounds. At most 10 metrics, 3 groups and 10 filters; limit is 1 to 10,000 and
defaults to 1,000. A dataset whose published data is larger than one query can read is
413 dataset_too_large. The page is never cut and returned: a result with more rows than
limit allows, or over 5 MB, is 413 result_too_large. The body is capped at 4 KiB.
Provenance. provenance names the dataset, the generations and schema version read,
the source’s own change signal, when the data was published, its completeness (partial when
the read recorded flags that limit it, including duplicate_keys, which lists the key
column and the sheet rows that repeat a key, never the key values), and its freshness as
describeDataset defines it. reconciliation states what was verified:
read_equals_loaded means the rows in the store equal the rows the read produced; it does
not say the read equals the spreadsheet as Google computes it independently.
Personal data. personal is true when any output column is computed from a column
classified personal or any filter is on one; each result column carries its own flag.
A column classified excluded is never returned.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The dataset’s stable identifier, from listDatasets. A well-formed id the workspace does not hold returns 404; malformed path segments do not match a route.
Request Body required
Section titled “Request Body required ”object
object
A column’s stable identifier. It survives a rename of the header; the header text is data and never a way to name a column.
object
A column’s stable identifier. It survives a rename of the header; the header text is data and never a way to name a column.
A date column only.
object
A column’s stable identifier. It survives a rename of the header; the header text is data and never a way to name a column.
A value of the column’s type: text as a string; a number or time as a number; a decimal as a string or an integer;
a date as YYYY-MM-DD; a date-time without a zone as YYYY-MM-DDTHH:MM:SS[.sss]; a timestamp with Z or an
offset; a boolean as a boolean.
At least one of min and max, both inclusive, on an ordered column.
object
A column’s stable identifier. It survives a rename of the header; the header text is data and never a way to name a column.
A value of the column’s type: text as a string; a number or time as a number; a decimal as a string or an integer;
a date as YYYY-MM-DD; a date-time without a zone as YYYY-MM-DDTHH:MM:SS[.sss]; a timestamp with Z or an
offset; a boolean as a boolean.
A value of the column’s type: text as a string; a number or time as a number; a decimal as a string or an integer;
a date as YYYY-MM-DD; a date-time without a zone as YYYY-MM-DDTHH:MM:SS[.sss]; a timestamp with Z or an
offset; a boolean as a boolean.
object
A column’s stable identifier. It survives a rename of the header; the header text is data and never a way to name a column.
true keeps the rows that have a value.
Acknowledges summing a percent column, which is almost always the wrong arithmetic.
Examples
{ "metrics": [ { "aggregate": "count_rows" }, { "aggregate": "sum", "column": "c0002" } ], "group_by": [ { "column": "c0001", "bucket": "month" } ], "filters": [ { "column": "c0003", "op": "eq", "value": "Oslo" } ], "limit": 100}Responses
Section titled “ Responses ”The aggregate rows and their provenance. The page is whole (page.truncated is always false).
object
object
Only google_sheets has a reader today; the others are reserved vocabulary.
object
The key of this column in each row.
The source column’s header text. Data, not instructions.
True when this output is computed from a column classified personal.
One value per result column, keyed by the result column’s id. A decimal, date, date-time or timestamp is text.
object
object
True when any output is computed from a personal column, or any filter is on one.
object
Only google_sheets has a reader today; the others are reserved vocabulary.
The published generations this answer was read from.
The source’s own change signal as the read recorded it (Google Sheets, Drive version and modifiedTime).
Google Sheets only, by id. null for any other source.
object
When the current data was published (the same instant as freshness.readAt).
partial when any generation read was published with flags that limit it.
A recorded property of the read that limits it. Only a code, counts, served column ids and sheet row numbers; never a cell value.
object
What was verified: the rows in the store equal the rows the read produced. It does not state that the read equals the spreadsheet as Google computes it through an independent second read.
Not a data_through date: this source has none. readAt is when the current data was
published. checkedAt is the later of readAt and the last successful check for a change, including one
that found the source unchanged. stale is true when checkedAt is older than twice the dataset’s
refresh interval, or the last run failed, or the source is unavailable or needs reconnecting.
object
invalid_json — the body is absent, not valid JSON, or not valid UTF-8.
invalid_query — the body is not a supported query: an unknown field, a column id the
dataset does not have (an excluded or unclassified column is refused the same way), an
aggregate that does not apply to its column, a filter or group the column’s type does
not take, a value that is not valid for its column’s type, a repeated metric or
group, more metrics, groups or filters than the bounds allow, a limit outside
1 to 10,000, or a URL that carried a query delimiter. The message is fixed text for
the rule and never echoes the request.
object
object
object
unauthorized — missing, unknown, expired or revoked key.
object
object
object
Headers
Section titled “Headers ”forbidden — the key lacks the required scope, or the workspace has no plan that allows this.
object
object
object
dataset_not_found — the workspace has no such dataset, or it is a draft or deleted. A
dataset of another workspace is indistinguishable from one that does not exist.
object
object
object
method_not_allowed — Allow names the method this route accepts.
object
object
object
Headers
Section titled “Headers ”dataset_not_ready — no generation of the dataset has been published yet.
object
object
object
request_too_large — REST bodies are capped at 4 KiB.
result_too_large — the result has more rows than limit allows or one response can
carry (at most 10,000), or it is over 5 MB. The page is never cut and returned.
dataset_too_large — the dataset’s published data is larger than one query can read;
the bound is on the data read, so narrowing the query does not help and the dataset has to be made smaller at the source.
object
object
object
unsupported_media_type unless the body is application/json, or
unsupported_encoding for any Content-Encoding other than identity.
object
object
object
rate_limited — the key’s or its workspace’s per-plan request allowance for this route’s class is used up.
It is answered after authentication, on every API-key operation in this document and on MCP, and never on /health. A download link is
limited the same way, after its lookup, by the key that issued it and the export’s workspace.
Retry-After is the window in seconds and RateLimit-Limit is the limit of the bucket that refused. No remaining
count is returned. The limits themselves are not published here.
object
object
object
Headers
Section titled “Headers ”query_unavailable — a backend is unreachable or timed out, or a stored row failed an
integrity check. The boundary fails closed rather than returning a result it cannot
vouch for, and never passes a database message through.
auth_unavailable — the authorization store could not be reached.