> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upstackdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run an analytics query with measures and dimensions

> Query revenue, orders, ad spend, ROAS, and any other measure for a date range, as a daily, weekly, or monthly series or broken down by up to five dimensions.

**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](https://docs.upstackdata.com/analytics/query-guide.md) 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](https://docs.upstackdata.com/concepts/timezones.md).

## 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](https://docs.upstackdata.com/api-reference/account/get-order-settings.md)
(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](https://docs.upstackdata.com/api-reference/account/get-order-settings.md) 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](https://docs.upstackdata.com/api-reference/catalog/list-filter-fields.md)
  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](https://docs.upstackdata.com/concepts/reporting-currency.md).
* `pixelId` in the body must equal the `x-pixel-id` header, or the request returns `403`.

## Related

* [List available measures](https://docs.upstackdata.com/api-reference/catalog/list-available-measures.md) for valid `measure` ids.
* [Run a cohort analysis](https://docs.upstackdata.com/api-reference/analytics/run-a-cohort-analysis.md) for retention and LTV by acquisition period.
* [Run an attribution query](https://docs.upstackdata.com/api-reference/analytics/run-an-attribution-query.md) for credit by UTM source or campaign.
* [`upstack query`](https://docs.upstackdata.com/cli/query) runs the same query from the CLI.


## OpenAPI

````yaml /api-reference/openapi.yaml post /db-mgmt/api/query
openapi: 3.1.0
info:
  title: Upstack Data API
  version: '1.0'
  description: >
    Programmatic access to your Upstack Data pixel — analytics queries, the

    measures/dimensions catalog, and dashboard view management.


    All requests authenticate with two headers:


    - `x-api-key`: your Upstack API key (mint one at **Settings → API Keys** in
    the dashboard).

    - `x-pixel-id`: the pixel id the request targets. One key is scoped to one
    pixel.
servers:
  - url: https://api.upstackdata.com
    description: Production
security:
  - apiKey: []
    pixelId: []
tags:
  - name: Analytics
    description: >
      Run measure queries, attribution queries, cohort analyses, and ad-platform
      entity

      listings against your pixel's orders, events, and ad spend. Every query
      endpoint

      takes the same `filters` tree. [List filter
      fields](/api-reference/catalog/list-filter-fields)

      tells you which fields each endpoint accepts.
  - name: Catalog
    description: >
      Look up the ids the query and dashboard endpoints accept: the built-in
      measures, and

      the filter fields with the operators and endpoints each one supports.
  - name: Dashboards
    description: >
      Create, read, copy, update, and delete the dashboard views shown in the
      Upstack web app.

      A view belongs to the pixel in the `x-pixel-id` header, and a key can only
      see its own

      pixel's views.
  - name: Account
    description: >
      Read the account that owns the API key, rename it, and read or replace its
      order

      settings: whether pending and voided orders count, how refunds are dated,
      and which

      orders are excluded from reporting.
  - name: Costs
    description: >
      Read and update cost settings: product defaults, the shipping method, and
      cost lines

      for order fees, payment processing fees, shipping profiles, variable
      costs, and

      recurring expenses. Changes to costs that apply per order recalculate the
      past orders

      they affect, the same as an edit in the web app.
  - name: Products
    description: >
      Search the product variants synced from Shopify and manage per-variant
      costs: manual

      COG lines with effective dates, and handling fees.
  - name: Events
    description: >-
      Upstack Conversion API (CAPI) — send server-side tracking events from your
      backend.
paths:
  /db-mgmt/api/query:
    post:
      tags:
        - Analytics
      summary: Run an analytics query
      description: >-
        Query revenue, orders, ad spend, ROAS, and any other measure for a date
        range, as a daily, weekly, or monthly series or broken down by up to
        five dimensions.
      operationId: query
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - pixelId
                - granularity
                - measures
                - dateRange
              properties:
                pixelId:
                  type: string
                  description: Must match the `x-pixel-id` header (403 if it doesn't).
                granularity:
                  $ref: '#/components/schemas/Granularity'
                measures:
                  type: array
                  maxItems: 30
                  description: >-
                    The measures to compute. Each one runs as its own query, so
                    one failing measure doesn't fail the others.
                  items:
                    $ref: '#/components/schemas/MeasureConfig'
                dimensions:
                  type: array
                  maxItems: 5
                  description: >-
                    Break results down by these dimensions, e.g. `utm_source` or
                    `country`. Unknown dimension ids are rejected with `400`.
                  items:
                    type: string
                    description: >-
                      Dimension id (see [Measures and
                      dimensions](/data-dictionary/measures-and-dimensions)).
                filters:
                  $ref: '#/components/schemas/Filter'
                  description: >
                    Filter applied to the query. Fields must list
                    `query_measures` in

                    their `applicableContexts` in [List filter
                    fields](/api-reference/catalog/list-filter-fields).
                dateRange:
                  $ref: '#/components/schemas/DateRange'
                compareDateRange:
                  $ref: '#/components/schemas/DateRange'
                  description: >
                    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:
                  type: string
                  description: >-
                    IANA timezone (e.g. `America/New_York`) that `dateRange` and
                    `compareDateRange` are read in. Defaults to UTC.
                currency:
                  type: string
                  default: USD
                  description: >
                    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:
                  $ref: '#/components/schemas/OrderSettings'
            examples:
              minimal:
                summary: Daily gross revenue and purchases
                value:
                  pixelId: 5f1e6a4f-2b7c-4d1e-9a3f-8c6b2e0d4a71
                  granularity: day
                  measures:
                    - measure: orders.gross_revenue
                    - measure: tracked.purchases
                  dateRange:
                    start: '2026-04-01'
                    end: '2026-04-03'
              byUtmSource:
                summary: Net revenue by UTM source for April, ranked
                value:
                  pixelId: 5f1e6a4f-2b7c-4d1e-9a3f-8c6b2e0d4a71
                  granularity: none
                  measures:
                    - measure: orders.net_revenue
                  dimensions:
                    - utm_source
                  dateRange:
                    start: '2026-04-01'
                    end: '2026-04-30'
                  timezone: America/New_York
                  currency: EUR
              withFilter:
                summary: Scope to web and POS orders from new customers
                value:
                  pixelId: 5f1e6a4f-2b7c-4d1e-9a3f-8c6b2e0d4a71
                  granularity: day
                  measures:
                    - measure: orders.gross_revenue
                  dateRange:
                    start: '2026-04-01'
                    end: '2026-04-30'
                  filters:
                    and:
                      - field: orders.source_name
                        op: in
                        value:
                          - web
                          - pos
                      - field: orders.customer_type
                        op: equals
                        value: new_customer
              withOrderSettings:
                summary: Apply the account's exclusion filter to match the dashboard
                value:
                  pixelId: 5f1e6a4f-2b7c-4d1e-9a3f-8c6b2e0d4a71
                  granularity: week
                  measures:
                    - measure: orders.gross_revenue
                  dateRange:
                    start: '2026-04-01'
                    end: '2026-04-30'
                  orderSettings:
                    countPendingOrders: false
                    countVoidedOrders: false
                    refundDateAttribution: refund_date
                    exclusionFilters:
                      - id: 3f6c1e2a-8b4d-4c7e-9f10-2a5b6c7d8e90
                        name: Exclude POS
                        enabled: true
                        conditionGroups:
                          - id: 7a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                            logic: and
                            conditions:
                              - id: c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f
                                field: sourceName
                                operator: equals
                                value: pos
      responses:
        '200':
          description: Query results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryResponse'
              examples:
                dailySeries:
                  summary: Response to the daily gross revenue and purchases request
                  value:
                    results:
                      - granularity: day
                        dimensions: []
                        dateRange:
                          start: '2026-04-01'
                          end: '2026-04-03T23:59:59.999'
                        measureDetails:
                          - measure: orders.gross_revenue
                            isAverage: false
                            isPercentage: false
                            calculatedAverage: false
                            success: true
                            primaryAvg: 4126.5
                            compareAvg: 3890.12
                            primarySum: 12379.5
                            compareSum: 11670.36
                            percentDiff: 6.08
                            hasPacing: false
                            preferredTrendDirection: up
                          - measure: tracked.purchases
                            isAverage: false
                            isPercentage: false
                            calculatedAverage: false
                            success: true
                            primaryAvg: 43
                            compareAvg: 40.33
                            primarySum: 129
                            compareSum: 121
                            percentDiff: 6.61
                            hasPacing: false
                            preferredTrendDirection: up
                        data:
                          primary:
                            - dt: '2026-04-01T00:00:00.000'
                              orders.gross_revenue: 3980.25
                              tracked.purchases: 41
                            - dt: '2026-04-02T00:00:00.000'
                              orders.gross_revenue: 4412.1
                              tracked.purchases: 46
                            - dt: '2026-04-03T00:00:00.000'
                              orders.gross_revenue: 3987.15
                              tracked.purchases: 42
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    Granularity:
      type: string
      enum:
        - none
        - second
        - minute
        - hour
        - day
        - week
        - month
        - quarter
        - year
      description: >
        Time bucket for result rows. `none` returns one row per dimension
        combination

        instead of a time series.
    MeasureConfig:
      type: object
      required:
        - measure
      description: |
        A measure entry in a query request. Pass the canonical measure id and an
        optional `pacing` flag.
      properties:
        measure:
          type: string
          description: >
            Canonical measure id (e.g. `orders.gross_revenue`) from

            [List available
            measures](/api-reference/catalog/list-available-measures).

            [Run an analytics
            query](/api-reference/analytics/run-an-analytics-query) also

            accepts the id of a [custom measure](/analytics/custom-measures).
          example: orders.gross_revenue
        pacing:
          type: boolean
          default: false
          description: When `true`, include pacing data for this measure.
    Filter:
      $ref: '#/components/schemas/FilterGroup'
      description: |
        Top-level canonical filter. Alias of `FilterGroup` — every request that
        carries a `filters` field at the body level uses this shape. Example:

        ```json
        {
          "and": [
            { "field": "orders.source_name", "op": "in", "value": ["web", "pos"] },
            { "field": "orders.customer_type", "op": "equals", "value": "new_customer" }
          ]
        }
        ```
    DateRange:
      type: object
      required:
        - start
        - end
      description: Inclusive date range. A date-only `end` covers that whole day.
      properties:
        start:
          type: string
          format: date
          description: First day of the range, as an ISO 8601 date.
          example: '2026-04-01'
        end:
          type: string
          format: date
          description: Last day of the range, as an ISO 8601 date. Included in the results.
          example: '2026-04-30'
    OrderSettings:
      type: object
      description: >
        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](/api-reference/account/get-order-settings)

        can be passed as-is.
      properties:
        countPendingOrders:
          type: boolean
          description: Include pending orders.
        countVoidedOrders:
          type: boolean
          description: Include voided orders.
        refundDateAttribution:
          $ref: '#/components/schemas/RefundDateAttribution'
        exclusionFilters:
          type: array
          description: >
            Orders matching any enabled filter are left out of the query. On
            this path every

            filter, condition group, and condition must carry its `id`, and
            every condition

            needs a `value`, including `exists` and `not_exists`.
          items:
            $ref: '#/components/schemas/OrderExclusionFilter'
    QueryResponse:
      type: object
      required:
        - results
      properties:
        results:
          type: array
          description: Query results. A cohort analysis always returns exactly one entry.
          items:
            $ref: '#/components/schemas/QueryResult'
    FilterGroup:
      type: object
      description: |
        Group node — exactly one of `and` / `or` / `not` is set. `and` and `or`
        carry an array of child nodes (leaf or nested group); `not` carries a
        single child node. Nesting depth is capped at 3.
      oneOf:
        - title: All of (and)
          type: object
          required:
            - and
          properties:
            and:
              type: array
              minItems: 1
              items:
                $ref: '#/components/schemas/FilterNode'
        - title: Any of (or)
          type: object
          required:
            - or
          properties:
            or:
              type: array
              minItems: 1
              items:
                $ref: '#/components/schemas/FilterNode'
        - title: Not
          type: object
          required:
            - not
          properties:
            not:
              $ref: '#/components/schemas/FilterNode'
    RefundDateAttribution:
      type: string
      enum:
        - refund_date
        - order_date
      description: >
        Which date a refund is counted on.

        - `refund_date`: the day the refund was processed, matching Shopify. The
        default.

        - `order_date`: the date of the original order.
    OrderExclusionFilter:
      type: object
      required:
        - name
        - enabled
        - conditionGroups
      description: |
        A single exclusion filter. An order that matches any enabled filter is
        left out of reporting. The server assigns `id` and `createdAt` when you
        leave them out, and sets `updatedAt` on every save. Max 20 condition
        groups per filter.
      properties:
        id:
          type: string
          format: uuid
          description: >-
            Filter id. Omit on new filters; send it back to keep the filter's
            identity.
        name:
          type: string
          minLength: 1
          maxLength: 100
          example: Exclude POS
          description: |
            Display name. Control / zero-width / bidi characters rejected;
            unicode letters, marks, digits, punctuation, and emoji accepted.
        enabled:
          type: boolean
          description: >-
            Only enabled filters exclude orders. Must be a JSON boolean, not a
            string.
        conditionGroups:
          type: array
          minItems: 1
          maxItems: 20
          description: The order is excluded when any one group matches.
          items:
            $ref: '#/components/schemas/ConditionGroup'
        createdAt:
          type: string
          format: date-time
          description: >-
            When the filter was created. Send it back unchanged to keep it; omit
            it and it resets to the time of the request.
        updatedAt:
          type: string
          format: date-time
          description: >-
            Set by the server to the time of the last save. Any value you send
            is overwritten.
    QueryResult:
      type: object
      properties:
        granularity:
          $ref: '#/components/schemas/Granularity'
        dimensions:
          type: array
          description: >-
            The dimensions the rows are broken down by. Empty when none were
            requested.
          items:
            type: string
        dateRange:
          $ref: '#/components/schemas/DateRange'
          description: >-
            The range queried. A date-only `end` comes back with its end-of-day
            time.
        compareDateRange:
          $ref: '#/components/schemas/DateRange'
          description: >-
            The comparison range queried. Absent when the server picked the
            period itself.
        measureDetails:
          type: array
          nullable: true
          description: One entry per requested measure.
          items:
            $ref: '#/components/schemas/MeasureDetail'
        data:
          allOf:
            - $ref: '#/components/schemas/QueryData'
          nullable: true
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable error message.
        errors:
          type: array
          description: Per-field validation errors (present on 400 responses).
          items:
            type: object
            properties:
              message:
                type: string
              key:
                type: string
              path:
                type: array
                items:
                  type: string
    FilterNode:
      description: Either a `FilterCondition` leaf or a nested `FilterGroup`.
      oneOf:
        - title: Condition
          allOf:
            - $ref: '#/components/schemas/FilterCondition'
        - title: Nested group
          allOf:
            - $ref: '#/components/schemas/FilterGroup'
    ConditionGroup:
      type: object
      required:
        - logic
        - conditions
      description: |
        Group of conditions joined by `logic`. Within a filter, groups
        are OR'd; within a group, conditions are joined by the group's
        `logic`. Max 20 conditions per group.
      properties:
        id:
          type: string
          format: uuid
          description: Group id. Omit on new groups; the server assigns one.
        logic:
          $ref: '#/components/schemas/ConditionLogic'
        conditions:
          type: array
          minItems: 1
          maxItems: 20
          items:
            $ref: '#/components/schemas/Condition'
    MeasureDetail:
      type: object
      description: Totals and formatting hints for one requested measure.
      properties:
        measure:
          type: string
          description: The measure id this entry describes.
        isAverage:
          type: boolean
          description: >-
            The measure is an average, so read `primaryAvg` rather than
            `primarySum` as its headline value.
        isPercentage:
          type: boolean
          description: The value is a percentage.
        calculatedAverage:
          type: boolean
          description: >-
            The average is calculated from the period's totals rather than
            averaged across rows.
        success:
          type: boolean
          description: >
            Whether this measure was computed. When `false`, the measure's query
            failed

            and its totals are all `0`, so check this before treating a zero as
            real. The

            request still returns `200` and the other measures still carry their
            data.
        primaryAvg:
          type: number
          description: Average value over `dateRange`.
        compareAvg:
          type: number
          description: Average value over the comparison period.
        primarySum:
          type: number
          description: Total over `dateRange`.
        compareSum:
          type: number
          description: Total over the comparison period.
        percentDiff:
          type: number
          description: Percent change from the comparison period to `dateRange`.
        hasPacing:
          type: boolean
          description: >-
            Pacing data is included. `true` only when you asked for `pacing` and
            the measure supports it.
        preferredTrendDirection:
          type: string
          enum:
            - up
            - down
          description: Whether higher (`up`) or lower (`down`) values are favorable.
    QueryData:
      type: object
      properties:
        primary:
          type: array
          description: Rows for `dateRange`.
          items:
            $ref: '#/components/schemas/MeasureDataRow'
        compare:
          type: array
          description: >
            Rows for `compareDateRange`. Left out of time-series responses when
            you didn't

            send a `compareDateRange`.
          items:
            $ref: '#/components/schemas/MeasureDataRow'
    FilterCondition:
      type: object
      required:
        - field
        - op
        - value
      description: Leaf node of a canonical filter — a single `field op value` predicate.
      properties:
        field:
          $ref: '#/components/schemas/FilterFieldId'
        op:
          $ref: '#/components/schemas/FilterOperator'
        value:
          $ref: '#/components/schemas/FilterValue'
    ConditionLogic:
      type: string
      enum:
        - and
        - or
    Condition:
      type: object
      required:
        - field
        - operator
      description: >
        Single condition inside a group. The server assigns `id` (a UUID) when
        you

        leave it out; send it back on later updates to keep the condition's
        identity.

        `value` is required for every operator except `exists` and `not_exists`.
      properties:
        id:
          type: string
          format: uuid
          description: Condition id. Omit on new conditions.
        field:
          $ref: '#/components/schemas/OrderExclusionField'
        operator:
          $ref: '#/components/schemas/ConditionOperator'
        value:
          description: >
            The value to compare against. Use a list of strings with `in`,
            `not_in`, and the

            `array_includes*` operators; a number with `value`; a string
            otherwise.
          oneOf:
            - title: String
              type: string
            - title: Number
              type: number
            - title: Boolean
              type: boolean
            - title: List of strings
              type: array
              items:
                type: string
    MeasureDataRow:
      type: object
      description: >
        One row of query data. Carries the requested dimension values keyed by
        dimension

        id, and one numeric value per measure keyed by measure id. Time-series
        queries

        (`granularity` other than `none`) add a `dt` bucket.
      additionalProperties: true
      properties:
        dt:
          type: string
          description: >-
            Start of the time bucket, e.g. `2026-04-01T00:00:00.000`. Present
            when `granularity` isn't `none`.
        start:
          type: string
        end:
          type: string
    FilterFieldId:
      type: string
      description: >
        Canonical filter field id (`<scope>.<snake_case_id>`). Each id is only

        valid on certain endpoints. [List filter
        fields](/api-reference/catalog/list-filter-fields)

        returns the full set and where each one applies.
      enum:
        - orders.source_name
        - orders.customer_type
        - orders.order_type
        - orders.value
        - orders.payment_gateway
        - orders.tags
        - channel.resource_name
        - channel.resource_source
        - channel.resource_status
        - channel.resource_configured_status
        - channel.resource_effective_status
        - channel.account_id
        - channel.campaign_id
        - channel.adset_id
        - channel.ad_id
        - channel.account_name
        - channel.campaign_name
        - channel.adset_name
        - channel.ad_name
        - attribution.utm_source
        - attribution.utm_medium
        - attribution.utm_campaign
        - attribution.utm_adset
        - attribution.utm_term
        - attribution.utm_ad
        - attribution.utm_content
        - events.event_name
        - emq.dataset_id
        - emq.event_name
        - emq.diagnostic_name
    FilterOperator:
      type: string
      description: >
        Operator on a filter condition. Each field accepts its own subset,
        listed in

        `supportedOperators` by [List filter
        fields](/api-reference/catalog/list-filter-fields).
      enum:
        - equals
        - not_equals
        - greater_than
        - less_than
        - greater_than_or_equals
        - less_than_or_equals
        - contains
        - not_contains
        - starts_with
        - ends_with
        - in
        - not_in
        - array_includes
        - array_includes_all
        - array_includes_any
    FilterValue:
      description: |
        Scalar (`string` / `number` / `boolean`) for equality / comparison /
        `contains` operators. Array of scalars for `in`, `not_in`, and
        `array_includes_*` operators.
      oneOf:
        - title: String
          type: string
        - title: Number
          type: number
        - title: Boolean
          type: boolean
        - title: List of strings
          type: array
          items:
            type: string
        - title: List of numbers
          type: array
          items:
            type: number
        - title: List of booleans
          type: array
          items:
            type: boolean
    OrderExclusionField:
      type: string
      enum:
        - sourceName
        - tags
        - value
        - paymentGateway
      description: |
        Order field a condition is evaluated against. Each field accepts only
        the operators that suit its type, listed under `ConditionOperator`.
    ConditionOperator:
      type: string
      enum:
        - equals
        - not_equals
        - in
        - not_in
        - contains
        - not_contains
        - starts_with
        - ends_with
        - greater_than
        - less_than
        - greater_than_or_equals
        - less_than_or_equals
        - exists
        - not_exists
        - array_includes
        - array_includes_all
        - array_includes_any
      description: >
        Comparison operator. It has to suit the field's type

        (string / array / number) — a numeric operator on a string field, such
        as

        `greater_than` on `sourceName`, is rejected with 400.
  responses:
    BadRequest:
      description: Validation error. Includes an `errors` array with per-field detail.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: >
        The `x-api-key` or `x-pixel-id` header is missing. The request is
        rejected

        before it reaches the API, and the body is `{"message":
        "Unauthorized"}`.

        A key that is present but not accepted returns `403`, not `401`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >
        The key was rejected, or it is valid but not allowed to do this. Either:


        - the key is unknown, revoked, or expired, or the pixel is inactive —
        the body is
          `{"Message": "User is not authorized to access this resource with an explicit deny
          in an identity-based policy"}` (note the capital `M`);
        - the key doesn't carry the scope this endpoint needs, or the body
        `pixelId` doesn't
          match the `x-pixel-id` header — the body is `{"message": "…"}` as described below.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: |
        The query failed. The body carries the underlying failure message.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Your Upstack API key. Starts with `upstack_`.
    pixelId:
      type: apiKey
      in: header
      name: x-pixel-id
      description: The pixel id the request targets.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.