---
title: "Query analytics data"
method: POST
path: "/analytics/query"
tags: ["beta.Analytics"]
---

# Query analytics data

`POST /analytics/query`

Execute an analytics query with specified metrics, dimensions, filters, and time range. [Management key](/docs/guides/overview/auth/management-api-keys) required.

## Request body

- object
  - `classifier_dimensions` object — Group results by custom classifier tags, breaking down metrics by the specified dimension values. Requires an active classifier on the workspace.
    - `classifier_id` string, uuid, required — UUID of the classifier whose tags to group by.
    - `dimension_names` string[]
    - `include_nulls` boolean — When true, also include generations that have no tag from this classifier. Defaults to false, which returns only classified generations.
  - `classifier_filters` object — Filter results to generations with specific classifier tag values. Can be combined with classifier_dimensions (must use the same classifier_id) or used independently with standard dimensions.
    - `classifier_id` string, uuid, required — UUID of the classifier whose tags to filter by. Must match classifier_dimensions.classifier_id when both are specified.
    - `filters` object[], required
      - `field` string, required — Classifier dimension name to filter on (snake_case identifier, e.g. "department", "work_type").
      - `operator` string, required — Filter operator. Only equality/set operators are supported (eq, neq, in, not_in) — ordered comparisons are not available because classification values are strings.
      - `value` union, required — Filter value. Use a scalar (string or number) for eq/neq, or an array for in/not_in.
        - string
        - number, double
        - union[]
          - union
            - string
            - number, double
  - `dimensions` string[]
  - `filters` object[]
    - `field` string, required — Dimension to filter on. Use the /meta endpoint for available dimensions.
    - `include_unset` boolean — Include rows where the dimension has no value. Applies only to the `in` and `not_in` operators and dimensions that have an unset bucket.
    - `operator` string, required — Filter operator
    - `value` union, required — Filter value (scalar or array depending on operator). Several dimensions are enriched in responses (returned as human-readable labels), but filters must use the underlying ID: `api_key_id` — numeric ID (from generation metadata) or key hash (64-char hex from GET /api/v1/keys, resolved server-side); `user` — Clerk user ID (e.g. "user_abc123"), not the display name; `workspace` — workspace UUID, not the workspace name (filtering or grouping by the account default workspace also covers activity recorded before workspace resolution existed, which is attributed to that default workspace); `app` — numeric app ID, not the app title; `model` — permaslug (e.g. "openai/gpt-4o"), not the display name. Other dimensions (provider, origin, country, etc.) are not enriched and accept the value as returned.
      - string
      - number, double
      - union[]
        - union
          - string
          - number, double
  - `granularity` string — Time granularity
  - `group_limit` integer — Maximum rows per distinct combination of dimensions. When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified.
  - `limit` integer — Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations.
  - `metrics` string[], required
  - `order_by` object
    - `direction` 'asc' | 'desc', required
    - `field` string, required — Field to order by: a metric included in `metrics` (or "request_count", which may be ordered by without being requested), a requested dimension, or "date".
  - `time_range` object
    - `end` string, date-time, required
    - `start` string, date-time, required

## Response `200`

Analytics query results

- object
  - `data` object, required
    - `cachedAt` number, double
    - `data` object[], required
    - `metadata` object, required
      - `query_time_ms` number, double, required
      - `row_count` integer, required
      - `truncated` boolean, required
    - `warnings` string[] — Warnings about filter resolution issues (e.g. unresolvable api_key_id hashes). The query still runs normally; these inform the caller that some filter values could not be resolved.

## Other responses

- `400` — Bad Request - Invalid request parameters or malformed input
- `401` — Unauthorized - Authentication required or invalid credentials
- `403` — Forbidden - Authentication successful but insufficient permissions
- `408` — Request Timeout - Operation exceeded time limit
- `500` — Internal Server Error - Unexpected server error

---

[API](https://skmtc.net/openrouterteam/apis/openrouter-api.md) · [All operations](https://skmtc.net/openrouterteam/apis/openrouter-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openrouterteam/openrouter-api/versions/9d1da2c7d2c3/schema)
