CSV generator
Combine one or more metric queries into a single CSV, returned as a signed S3 download URL.
Long-running export route that runs one or more metric queries, combines the results into a single CSV, and returns a signed S3 URL to download it. Use it for scheduled exports, BI ingestion, or anywhere a file beats a stream.
Signed URL expiry: the URL returned has a short expiry. Fetch the file promptly; you’ll need to issue a fresh export request to refresh.
Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
csvFormat.columns | object[] | yes | Array of column descriptors — see below |
csvFormat.sortBy | number[] | yes | Array of column indices (integers into columns) to sort the CSV by — not an array of objects |
csvFormat.rowFilters | string[] | yes | Non-empty array of dimension enum strings (e.g. ["entity"], ["entity", "age"]) controlling which dimensions become rows |
metricRequests | object[] | yes | Array of metric request bodies — same shape as any standard metric route |
csvFormat.columns shape
Each column has:
| Field | Type | Required | Description |
|---|---|---|---|
heading | string | yes | Column label written to the CSV |
metricId | string | no | Binds this column to a value in one of the metricRequests |
fetchValue | string | no | Which field of the metric result to read (e.g. "sales_volume") |
field | string | no | Specific field within complex metric results |
filter | object | no | Restrict to a slice, e.g. { "taxonomy": "Products:Clothing" } |
metricRequests shape
Each entry uses the standard metric body (start, end, entities, etc.) plus two optional labelling fields:
| Field | Type | Description |
|---|---|---|
metricId | string | Used to bind columns back to this request |
name | string | Human-readable, used in the CSV |
Multiple metric requests in one call are combined into a single CSV.
Example request
{
"action": "external-service",
"data": {
"id": "req-csv-001",
"route": "external-service/csv-generator",
"body": {
"csvFormat": {
"columns": [
{ "heading": "Date" },
{ "heading": "Entries", "metricId": "entries-by-day", "fetchValue": "entries" }
],
"sortBy": [0],
"rowFilters": ["entity"]
},
"metricRequests": [
{
"metricId": "entries-by-day",
"name": "Entries by day",
"start": "2024-04-01T00:00:00.000Z",
"end": "2024-04-30T23:59:59.000Z",
"entities": ["64a1b2c3d4e5f6a7b8c9d0e3"],
"entityType": "location",
"facets": ["segments"],
"aggregationPeriod": "day"
}
]
}
}
}
Example response
req-csv-001|0|0|{
"body": [
{
"bucket": "aura-exports",
"key": "exports/64a1b2c3d4e5f6a7b8c9d0e2/2024-04-15T10-15-00.csv",
"signedUrl": "https://aura-exports.s3.amazonaws.com/exports/64a1b2c3d4e5f6a7b8c9d0e2/2024-04-15T10-15-00.csv?X-Amz-Signature=…"
}
]
}
Fetch signedUrl directly with GET to retrieve the file. bucket + key are exposed if you have direct S3 access via your own AWS credentials.
Related
- Entries — typical metric input
- Area entries
- Transactions
- Metrics API overview