Skip to main content
POST
Required scope: analytics:read This is the endpoint behind the numbers on your dashboards. Use it to pull daily gross revenue into a spreadsheet, rank UTM sources by new-customer revenue, or feed a BI tool on a schedule. Querying data walks through building a query step by step.

How the request shapes the response

  • Any granularity other than none returns a time series. data.primary has one row per bucket in the range, each with a dt field, including buckets with no data.
  • granularity: none returns one row per dimension combination, sorted by the first measure in measures, highest first.
  • Each row carries one value per measure, keyed by measure id, and one value per dimension, keyed by dimension id.
  • dateRange.end is inclusive. With timezone set, dates are read as local dates in that zone. Without it, they’re read as UTC. See Timezones.

Comparison periods

  • Send compareDateRange to get data.compare rows and comparison totals in measureDetails.
  • Leave it out and a time-series query still compares against the preceding period of the same length. measureDetails[].percentDiff uses that period, but the response leaves out compareDateRange and data.compare.
  • A compareDateRange that overlaps dateRange is dropped without an error, and a time-series query falls back to the preceding period.

Order settings aren’t applied for you

The web app applies your saved order settings (pending and voided orders, refund dating, exclusion filters) to every query. This endpoint only uses the orderSettings you send. To match the dashboard, read them with Get order settings and pass the returned object as orderSettings.

Errors and edge cases

  • A measure whose query fails comes back with success: false and zero totals in measureDetails. The request still returns 200, so check success before you treat a zero as real.
  • A malformed filters tree, or a filter field this endpoint doesn’t accept, returns 400 with the reason in errors. List filter fields shows which fields work here (query_measures).
  • currency is case-insensitive. A code that isn’t three letters falls back to USD without an error. See Reporting currency.
  • pixelId in the body must equal the x-pixel-id header, or the request returns 403.

Authorizations

x-api-key
string
header
required

Your Upstack API key. Starts with upstack_.

x-pixel-id
string
header
required

The pixel id the request targets.

Body

application/json
pixelId
string
required

Must match the x-pixel-id header (403 if it doesn't).

granularity
enum<string>
required

Time bucket for result rows. none returns one row per dimension combination instead of a time series.

Available options:
none,
second,
minute,
hour,
day,
week,
month,
quarter,
year
measures
object[]
required

The measures to compute. Each one runs as its own query, so one failing measure doesn't fail the others.

Maximum array length: 30
dateRange
object
required

Inclusive date range. A date-only end covers that whole day.

dimensions
string[]

Break results down by these dimensions, e.g. utm_source or country. Unknown dimension ids are rejected with 400.

Maximum array length: 5

Dimension id (see Measures and dimensions).

filters
All of (and) · object

Filter applied to the query. Fields must list query_measures in their applicableContexts in List filter fields.

compareDateRange
object

Optional comparison period. An overlapping range is ignored without an error. When it's absent and granularity isn't none, the server compares against the preceding period but leaves it out of the response.

timezone
string

IANA timezone (e.g. America/New_York) that dateRange and compareDateRange are read in. Defaults to UTC.

currency
string
default:USD

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.

orderSettings
object

Order settings to apply to this query. The query endpoints don't read the account's saved order settings, so pass them here to match the web app's numbers. The orderSettings object returned by Get order settings can be passed as-is.

Response

Query results.

results
object[]
required

Query results. A cohort analysis always returns exactly one entry.