latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-1983295742.1 KB

060c53b503ce

analytics

Query gateway request data

A query can use only the public alias gateway_requests_v1. CTEs, subqueries, UNION, and EXCEPT are permitted. The root key must have the project.*.read_gateway_requests permission. Unkey limits each query to the workspace of the root key. To get the data for one project, app, or environment, add a filter on project_id, app_id, or environment_id. The workspace retention period and the workspace query limits apply. For the columns and more query examples, see the gateway request analytics documentation.

post/v2/analytics.getGatewayRequests

Request body

querystring required

The SQL query to run on your gateway request data. A query can use only the public alias gateway_requests_v1. The physical default.* table names are not permitted. Only SELECT queries are permitted. CTEs, subqueries, UNION, and EXCEPT are also permitted. Unkey limits each query to the workspace of the root key. To get the data for one project, app, or environment, add a filter on project_id, app_id, or environment_id. The workspace retention period and the workspace query limits apply.

Example request

{
  "query": "SELECT path, count() AS total FROM gateway_requests_v1 WHERE response_status >= 500 AND time >= toUnixTimestamp64Milli(now64(3) - INTERVAL 24 HOUR) GROUP BY path ORDER BY total DESC LIMIT 10"
}

Response

Query executed successfully

dataobject[] required

The gateway request rows that the query returned. The SELECT clause of the query controls the fields in each row.

Example response

{
  "meta": {
    "requestId": "req_123"
  },
  "data": [
    {
      "path": "/v1/orders",
      "total": 1234
    }
  ]
}