---
title: "Run a backend-neutral, multi-dimensional API traffic aggregation."
method: POST
path: "/projects/{project_id}/api-analytics/query"
tags: ["Proxy Logs"]
---

# Run a backend-neutral, multi-dimensional API traffic aggregation.

`POST /projects/{project_id}/api-analytics/query`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/api-analytics/query`
- Auth: HTTP bearer

## Path parameters

- `project_id` integer, required

## Request body

- TrafficAggregationRequest
  - `dimensions` TrafficDimension[], required: Zero to four grouping dimensions. Zero returns one overall rollup; multiple dimensions form a tuple.
  - `end_time` string, date-time, required
  - `environment_id` integer, nullable
  - `filters` TrafficFilter[]
    - `dimension` 'client_ip' | 'method' | 'path' | 'host' | 'status_code' | 'status_class' | 'environment_id' | 'deployment_id' | 'request_source' | 'is_bot' | 'browser' | 'operating_system' | 'device_type' | 'cache_status' | 'referrer', required
    - `operator` 'eq' | 'not_eq' | 'contains' | 'starts_with' | 'in', required
    - `values` string[], required: One value for scalar operators; one or more values for `in`.
  - `include_synthetic` boolean: Include Temps status-monitor requests. They are excluded by default.
  - `metrics` TrafficMetric[], required: Aggregates to calculate. Unrequested response fields remain null.
  - `order_by` TrafficOrderBy[]: Ordered sort keys. Multiple keys provide stable pagination when the primary metric ties. Every field must be requested/grouped.
    - `direction` 'asc' | 'desc', required
    - `field` union, required
      - object
        - `field` 'client_ip' | 'method' | 'path' | 'host' | 'status_code' | 'status_class' | 'environment_id' | 'deployment_id' | 'request_source' | 'is_bot' | 'browser' | 'operating_system' | 'device_type' | 'cache_status' | 'referrer', required
        - `kind` 'dimension', required
      - object
        - `field` 'requests' | 'errors' | 'error_rate' | 'latency_avg' | 'latency_min' | 'latency_max' | 'latency_p50' | 'latency_p95' | 'latency_p99' | 'unique_ips' | 'unique_paths' | 'bot_requests' | 'robots_txt_requests' | 'last_seen', required
        - `kind` 'metric', required
  - `page` integer
  - `page_size` integer
  - `start_time` string, date-time, required

## Response `200`

Aggregated API traffic

- TrafficAggregationResponse
  - `dimensions` TrafficDimension[], required
  - `metrics` TrafficMetric[], required
  - `page` integer, required
  - `page_size` integer, required
  - `rows` TrafficAggregationRow[], required
    - `dimensions` TrafficDimensionValue[], required
      - `dimension` 'client_ip' | 'method' | 'path' | 'host' | 'status_code' | 'status_class' | 'environment_id' | 'deployment_id' | 'request_source' | 'is_bot' | 'browser' | 'operating_system' | 'device_type' | 'cache_status' | 'referrer', required
      - `value` string, nullable: Dimensions are serialized as display-safe strings across both storage backends. Null database values remain null rather than becoming empty.
    - `metrics` TrafficMetricValues, required
      - `bot_requests` integer, nullable
      - `error_rate` number, double, nullable
      - `errors` integer, nullable
      - `last_seen` string, date-time, nullable
      - `latency_avg_ms` number, double, nullable
      - `latency_max_ms` number, double, nullable
      - `latency_min_ms` number, double, nullable
      - `latency_p50_ms` number, double, nullable
      - `latency_p95_ms` number, double, nullable
      - `latency_p99_ms` number, double, nullable
      - `requests` integer, nullable
      - `robots_txt_requests` integer, nullable
      - `unique_ips` integer, nullable
      - `unique_paths` integer, nullable
  - `synthetic_excluded` boolean, required
  - `total_groups` integer, required
  - `total_pages` integer, required

## Other responses

- `400`: Invalid dimensions, metrics, filters, or time range
- `401`: Unauthorized
- `403`: Insufficient permissions
- `429`: Aggregation request budget exceeded
- `500`: Storage query failed
- `504`: Aggregation query timed out

## Changes

- **2026-11-20** `1a920722ba7e`: 2 warning, 3 info
  - added the new `referrer` enum value to the `dimensions/items/` response property for the response status `200`
  - added the new `referrer` enum value to the `rows/items/dimensions/items/dimension` response property for the response status `200`
  - added the new `referrer` enum value to the request property `dimensions/items/`
  - added the new `referrer` enum value to the request property `filters/items/dimension`
  - …1 more
- **2026-11-09** `12896146b193`: 6 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
  - removed the required property `extensions` from the response with the `429` status
  - …2 more
- **2026-10-05** `4b228ebed583`: 6 info
  - added the optional property `status` to the response with the `400` status
  - added the optional property `status` to the response with the `401` status
  - added the optional property `status` to the response with the `403` status
  - added the optional property `status` to the response with the `429` status
  - …2 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/api-analytics/query/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
