curl --request POST \
--url https://api.upstackdata.com/db-mgmt/api/query \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-pixel-id: <api-key>' \
--data '
{
"pixelId": "5f1e6a4f-...",
"granularity": "day",
"measures": [
{
"measure": "orders.gross_revenue"
},
{
"measure": "tracked.purchases"
}
],
"dateRange": {
"start": "2026-04-01",
"end": "2026-04-30"
}
}
'{
"results": [
{
"granularity": "none",
"dimensions": [
"<string>"
],
"dateRange": {
"start": "2026-04-01",
"end": "2026-04-30"
},
"compareDateRange": {
"start": "2026-04-01",
"end": "2026-04-30"
},
"measureDetails": [
{
"measure": "<string>",
"isAverage": true,
"isPercentage": true,
"calculatedAverage": true,
"success": true,
"primaryAvg": 123,
"compareAvg": 123,
"primarySum": 123,
"compareSum": 123,
"percentDiff": 123,
"hasPacing": true,
"preferredTrendDirection": "up"
}
],
"data": {
"primary": [
{
"dt": "<string>",
"start": "<string>",
"end": "<string>"
}
],
"compare": [
{
"dt": "<string>",
"start": "<string>",
"end": "<string>"
}
]
}
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}Run an analytics query
Execute a measures-and-dimensions query against your event stream. Mirrors the in-app query builder.
Required scope: analytics:read.
See Querying Data for a guided walkthrough.
curl --request POST \
--url https://api.upstackdata.com/db-mgmt/api/query \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-pixel-id: <api-key>' \
--data '
{
"pixelId": "5f1e6a4f-...",
"granularity": "day",
"measures": [
{
"measure": "orders.gross_revenue"
},
{
"measure": "tracked.purchases"
}
],
"dateRange": {
"start": "2026-04-01",
"end": "2026-04-30"
}
}
'{
"results": [
{
"granularity": "none",
"dimensions": [
"<string>"
],
"dateRange": {
"start": "2026-04-01",
"end": "2026-04-30"
},
"compareDateRange": {
"start": "2026-04-01",
"end": "2026-04-30"
},
"measureDetails": [
{
"measure": "<string>",
"isAverage": true,
"isPercentage": true,
"calculatedAverage": true,
"success": true,
"primaryAvg": 123,
"compareAvg": 123,
"primarySum": 123,
"compareSum": 123,
"percentDiff": 123,
"hasPacing": true,
"preferredTrendDirection": "up"
}
],
"data": {
"primary": [
{
"dt": "<string>",
"start": "<string>",
"end": "<string>"
}
],
"compare": [
{
"dt": "<string>",
"start": "<string>",
"end": "<string>"
}
]
}
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}Authorizations
Your Upstack API key. Starts with upstack_.
The pixel id the request targets.
Body
Must match the x-pixel-id header (403 if it doesn't).
none, second, minute, hour, day, week, month, quarter, year 1 - 30 elementsShow child attributes
Show child attributes
Show child attributes
Show child attributes
5Dimension id (see Measures & Dimensions).
Canonical filter applied to the query. Discover valid
fields with GET /api/filters.
- All of (and)
- Any of (or)
- Not
Show child attributes
Show child attributes
Optional comparison period. Must not overlap dateRange; the server picks the preceding period if omitted (and granularity ≠ none).
Show child attributes
Show child attributes
IANA timezone (e.g. America/New_York).
ISO 4217 code to convert money measures to (e.g. EUR). Each
amount converts at the rate for the day it occurred, so
historical results stay stable across reruns.
Defaults to USD when omitted — if your store sells in
another currency, pass this explicitly.
Order-level query settings — exclusion filters, pending/voided handling.
Show child attributes
Show child attributes
Response
Query results.
Show child attributes
Show child attributes
Was this page helpful?