---
title: "Query gateway request data"
method: POST
path: "/v2/analytics.getGatewayRequests"
tags: ["analytics"]
---

# Query gateway request data

`POST /v2/analytics.getGatewayRequests`

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.

## Request body

- V2AnalyticsGetGatewayRequestsRequestBody
  - `query` string, 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.

## Response `200`

Query executed successfully

- V2AnalyticsGetGatewayRequestsResponseBody
  - `meta` Meta, required — Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The `requestId` is particularly important when troubleshooting issues with the Unkey support team.
    - `requestId` string, required — A unique id for this request. Always include this ID when contacting support about a specific API request. This identifier allows Unkey's support team to trace the exact request through logs and diagnostic systems to provide faster assistance.
  - `data` object[], required — The gateway request rows that the query returned. The SELECT clause of the query controls the fields in each row.

## Other responses

- `400` — Invalid SQL query, blocked operation, or missing required authentication
- `401` — Invalid authentication credentials
- `403` — Insufficient permissions
- `412` — Analytics is not configured for the workspace
- `422` — Query exceeds workspace query limits
- `429` — Query quota exceeded
- `500` — Query execution failed
- `503` — Connection to the database failed

---

[API](https://skmtc.net/unkeyed/apis/unkey-api.md) · [All operations](https://skmtc.net/unkeyed/apis/unkey-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/unkeyed/unkey-api/revisions/060c53b503ce/schema)
