Skip to content

API reference

Export a query as a file

POST
/v1/query/export

Plans the export and answers 202 with its status. The body is the query of POST /v1/query (the workspace is the key’s own and is never in the body) plus the file options. The query is validated, authorized and pinned to the published snapshots it reads before the answer: a window that is not fully published is refused data_not_ready or data_incomplete with the missing dates, exactly as the query route does. The file never gets a snapshot that lands after this call.

Idempotency-Key is optional. Sent again with the same request, it returns the same export: 202 when this call created it, 200 with the export’s current status, whatever its state, when it already existed. Changed intent needs a new key (idempotency_conflict). A workspace may have one export running and three pending; a further create is refused export_limit_reached.

The published limits of a file are 5,000,000 rows and 2 GiB, and a result beyond them ends failed with export_too_large. This version does not deliver that size: the reader stops earlier, at about 5,000,000 source rows scanned per statement (about half that for a profile that also checks completeness) and 20 seconds per statement under the query role. A result it cannot read ends failed with export_too_large, or query_unavailable when a read runs out of time.

Idempotency-Key
string
/^[A-Za-z0-9._:-]{8,128}$/

8–128 characters from A-Za-z0-9._:-. Identifies one logical export.

object
format
required
Allowed value: parquet
Example
{
"query": {
"profile": "ga4.sessions_daily",
"connectionId": "your_connection",
"accounts": [
"123456789"
],
"metrics": [
"sessions"
],
"dimensions": [
"date"
],
"dateRange": {
"start": "2026-08-31",
"end": "2026-09-04"
}
},
"format": "csv",
"csv": {
"bom": true
}
}

The Idempotency-Key was used before with the same request. This is the export’s current status, in any state: a replay after the export failed, expired or was erased reads that state and does not start a second export.

The export row as a caller may see it. Closed, so a field not listed here is not returned.

object
exportId
required
string
/^[A-Za-z0-9_-]{1,128}$/
state
required

pending and running are in progress. succeeded has a file. failed has none and names errorCode. expired is a file removed after 7 days. erased is a file removed because a field it carries was switched off for output.

string
Allowed values: pending running succeeded failed expired erased
format
required
string
Allowed values: csv parquet
requestId
required

The X-Request-Id of the create call.

string format: uuid
createdAt
required
string format: date-time
expiresAt
required

When the file is removed. null until the export succeeds.

string | null format: date-time
rows
required

Rows written, header excluded. null until the export succeeds. Equal to the rows the pinned query returns, or the export fails.

integer | null
bytes
required
integer | null
sha256
required

Digest of the file, as written.

string | null
/^[0-9a-f]{64}$/
errorCode
required

Why a failed export failed; null in every other state.

string | null
Allowed values: export_too_large data_superseded query_unavailable export_unavailable forbidden export_integrity_failed
fields
required

The field ids of the file’s columns, in order. They are the header row.

Array<string>
freshness
required

From the extraction instants of the pinned snapshots, copied from the query result at plan time; null when the publication carries none. Over several sources one record spans them: the oldest and newest extraction of any source, stale when any source is stale by its own threshold, and the smallest of their thresholds.

object
oldestExtractedAt
required
string format: date-time
newestExtractedAt
required
string format: date-time
stale
required

True when the oldest snapshot is older than thresholdHours.

boolean
thresholdHours
required

Hours after which the oldest snapshot is stale: two effective refresh cadences plus the source finality lag.

number
> 0
flags
required

The profile’s limitations, then the pinned generation’s history limitations (Shopify commerce, sorted), then, over several sources, account_local_dates when the accounts’ time zones differ, then stale_source_snapshot when the pinned snapshot is stale (for any source). Surface them wherever the number is shown.

Array<string>
sourceAttribution

Present on an export of a YouTube profile only, copied from the query result at plan time. The CSV has no room for it (its first line is the header row), so show it with the file wherever the file is offered.

object
source
required
string
Allowed value: youtube
label
required
string
Allowed value: YouTube
notice
required
string
Allowed value: Data from YouTube. Values exactly as the YouTube Analytics API returned them.
channelId
required

The channel the values were read from (the request’s account).

string
/^UC[A-Za-z0-9_-]{22}$/
channelUrl
required

The channel’s public YouTube page.

string format: uri
/^https://www\.youtube\.com/channel/UC[A-Za-z0-9_-]{22}$/
analyticsUrl
required

The channel’s analytics page in YouTube Studio.

string format: uri
/^https://studio\.youtube\.com/channel/UC[A-Za-z0-9_-]{22}/analytics$/
csv
required

The CSV options of a CSV export; null for a Parquet export.

object
bom
required
boolean
formulaNeutralization
required

Text columns only; a value starting with =, +, -, @, a tab or a carriage return is prefixed with a single quote.

string
Allowed value: text-columns-single-quote

The export is planned. Poll GET /v1/exports/{exportId}.

object
exportId
required
string
/^[A-Za-z0-9_-]{1,128}$/
state
required

pending and running are in progress. succeeded has a file. failed has none and names errorCode. expired is a file removed after 7 days. erased is a file removed because a field it carries was switched off for output.

string
Allowed values: pending running succeeded failed expired erased
format
required
string
Allowed values: csv parquet
requestId
required

The X-Request-Id of the create call.

string format: uuid
createdAt
required
string format: date-time
expiresAt
required

When the file is removed. null until the export succeeds.

string | null format: date-time
rows
required

Rows written, header excluded. null until the export succeeds. Equal to the rows the pinned query returns, or the export fails.

integer | null
bytes
required
integer | null
sha256
required

Digest of the file, as written.

string | null
/^[0-9a-f]{64}$/
errorCode
required

Why a failed export failed; null in every other state.

string | null
Allowed values: export_too_large data_superseded query_unavailable export_unavailable forbidden export_integrity_failed
fields
required

The field ids of the file’s columns, in order. They are the header row.

Array<string>
freshness
required

From the extraction instants of the pinned snapshots, copied from the query result at plan time; null when the publication carries none. Over several sources one record spans them: the oldest and newest extraction of any source, stale when any source is stale by its own threshold, and the smallest of their thresholds.

object
oldestExtractedAt
required
string format: date-time
newestExtractedAt
required
string format: date-time
stale
required

True when the oldest snapshot is older than thresholdHours.

boolean
thresholdHours
required

Hours after which the oldest snapshot is stale: two effective refresh cadences plus the source finality lag.

number
> 0
flags
required

The profile’s limitations, then the pinned generation’s history limitations (Shopify commerce, sorted), then, over several sources, account_local_dates when the accounts’ time zones differ, then stale_source_snapshot when the pinned snapshot is stale (for any source). Surface them wherever the number is shown.

Array<string>
sourceAttribution

Present on an export of a YouTube profile only, copied from the query result at plan time. The CSV has no room for it (its first line is the header row), so show it with the file wherever the file is offered.

object
source
required
string
Allowed value: youtube
label
required
string
Allowed value: YouTube
notice
required
string
Allowed value: Data from YouTube. Values exactly as the YouTube Analytics API returned them.
channelId
required

The channel the values were read from (the request’s account).

string
/^UC[A-Za-z0-9_-]{22}$/
channelUrl
required

The channel’s public YouTube page.

string format: uri
/^https://www\.youtube\.com/channel/UC[A-Za-z0-9_-]{22}$/
analyticsUrl
required

The channel’s analytics page in YouTube Studio.

string format: uri
/^https://studio\.youtube\.com/channel/UC[A-Za-z0-9_-]{22}/analytics$/
csv
required

The CSV options of a CSV export; null for a Parquet export.

object
bom
required
boolean
formulaNeutralization
required

Text columns only; a value starting with =, +, -, @, a tab or a carriage return is prefixed with a single quote.

string
Allowed value: text-columns-single-quote
state
Allowed value: pending
Example
{
"exportId": "exp_8d2c41f0a6",
"state": "pending",
"format": "csv",
"requestId": "7b6b8f4e-3d0b-4f64-9a43-2f8f5f1d2a10",
"createdAt": "2026-10-26T09:30:00.000Z",
"expiresAt": null,
"rows": null,
"bytes": null,
"sha256": null,
"errorCode": null,
"fields": [
"date",
"sessions"
],
"freshness": {
"oldestExtractedAt": "2026-09-05T01:02:03.000Z",
"newestExtractedAt": "2026-09-05T01:02:03.000Z",
"stale": false,
"thresholdHours": 26
},
"flags": [
"provider_may_revise_recent_data",
"not_independently_reconciled"
],
"csv": {
"bom": true,
"formulaNeutralization": "text-columns-single-quote"
}
}
Location
required
string
/^/v1/exports/[A-Za-z0-9_-]{1,128}$/

The status resource of the new export.

invalid_json — the body is absent, not valid JSON, or not valid UTF-8.

invalid_query — the query is not supported by POST /v1/query (a sources list over the export’s 10 pairs included, fewer than the 25 of POST /v1/query; this envelope carries no detail), or the URL carried a query delimiter.

invalid_export_request — the file options are not supported: an unknown field, a format other than csv or parquet, a csv.bom that is not a boolean, or csv options with the format parquet.

invalid_idempotency_key — the header, when sent, is not 8–128 characters from A-Za-z0-9._:-.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed values: invalid_json invalid_query invalid_export_request invalid_idempotency_key

unauthorized — missing, unknown, expired or revoked key.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed value: unauthorized
WWW-Authenticate
required
string
Allowed value: Bearer

forbidden — the key lacks query:read, the profile is not served for this workspace, or the workspace has no entitlement to export. A connection that is not the key’s workspace’s is 404 connection_unavailable, as for one that does not exist.

workspace_paused — reserved: a workspace an operator paused is refused at authentication (401) before this route runs, and a trial or subscription pause still allows creating and downloading exports. This version does not return it.

field_not_enabled — reserved: this version serves the same fields as POST /v1/query and does not return it.

history_not_entitled — reserved: the contract lists it for a window that reaches back further than the plan’s history. This version does not return it.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed values: forbidden workspace_paused field_not_enabled history_not_entitled

connection_unavailable — the connection does not exist for this workspace, or is not available to query.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed value: connection_unavailable

method_not_allowed — Allow names the method this route accepts.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed value: method_not_allowed
Allow
required
string
Allowed value: POST

data_not_ready when nothing in the window is published, data_incomplete when some days are; both name the missing dates, in ascending order (at most 31; missingDatesTruncated is true when there are more). Never a short file.

timezone_conflict — published dates use different source timezones, or several sources summed by date are in different time zones (then the message says to group by account, as on POST /v1/query). It carries no missing dates.

currency_conflict — a money metric over several sources summed by date spans more than one currency; group by account.

idempotency_conflict — the Idempotency-Key was used for a different request.

export_limit_reached — the workspace already has one export running and three pending.

One of:

The two missing-publication 409 forms; timezone_conflict, currency_conflict and attribution_conflict have no missingDates. This is a separate closed object because composing Error with allOf would reject missingDates under Error.properties.error.additionalProperties.

object
error
required
object
code
required
string
Allowed values: data_not_ready data_incomplete
message
required
string
missingDates
required

The dates with no published snapshot, in ascending order, so a truncated list is the earliest 31. Never empty: a list the gateway cannot vouch for is a 503.

Array<string>
>= 1 items <= 31 items unique items
missingDatesTruncated

Present, and true, only when more than 31 dates are missing and missingDates lists the earliest 31.

boolean
Examples
{
"error": {
"code": "data_incomplete",
"message": "The window is not fully published.",
"missingDates": [
"2026-09-03",
"2026-09-04"
]
}
}

request_too_large — REST bodies are capped at 4 KiB.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed value: request_too_large

unsupported_media_type unless the body is application/json, or unsupported_encoding for any Content-Encoding other than identity.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed values: unsupported_media_type unsupported_encoding

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
error
required
object
code
required
string
message
required
string
error
object
code
Allowed value: rate_limited
Retry-After
required
string
/^[1-9][0-9]*$/
RateLimit-Limit
required
string
/^[1-9][0-9]*$/

export_unavailable — the export could not be planned. Retry with backoff.

object
error
required
object
code
required
string
message
required
string
error
object
code
Allowed value: export_unavailable