Execute an analytics query
POST /v1/query
Execute a SQL-like analytics query against telemetry data stored in ClickHouse.
Only SELECT statements are allowed. Queries are validated, rewritten to enforce
tenant isolation, and executed against a read-only connection.
Requires the data:admin scope. Also accepts query:read.
Use a key with query:read (the Read-only + SQL preset) for SQL queries, keeping data:admin keys for data export and erasure.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
The project ID to query.
SQL query (SELECT only).
Positive integer row limit; values above 10000 are clamped to 10000. Not applied when sql has its own top-level LIMIT, which is kept as written, also when it is above this value.
Responses
Section titled “ Responses ”Query results.
object
object
Result rows; each object maps column name to value. 64-bit integer columns (for example count()) arrive as decimal strings, the ClickHouse JSON encoding of 64-bit integers.
object
Number of rows returned.
Headers
Section titled “Headers ”Maximum number of requests allowed per hour.
Number of requests remaining in the current window.
Unix timestamp in milliseconds when the rate limit window resets.
Rejected query. Returned for a malformed request body and for user SQL that the database rejects (unknown column, table, or function; syntax errors; type mismatches; forbidden operations). The ClickHouse diagnostic is included in the error message.
RFC 9457 Problem Details. Served with the application/problem+json
media type. error_category, retryable, and retry_after are
Framedash extension members. type always defaults to about:blank,
so it is always present; detail and the extension members are present
only when applicable.
object
Problem type URI; about:blank when no specific type applies.
Short, human-readable summary of the problem type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Extension member categorizing the error.
Extension member; true when retrying may succeed (e.g. 429, 503).
Extension member; suggested retry delay in seconds, when applicable.
Missing or invalid API key.
RFC 9457 Problem Details. Served with the application/problem+json
media type. error_category, retryable, and retry_after are
Framedash extension members. type always defaults to about:blank,
so it is always present; detail and the extension members are present
only when applicable.
object
Problem type URI; about:blank when no specific type applies.
Short, human-readable summary of the problem type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Extension member categorizing the error.
Extension member; true when retrying may succeed (e.g. 429, 503).
Extension member; suggested retry delay in seconds, when applicable.
API key with query:read or data:admin scope required.
RFC 9457 Problem Details. Served with the application/problem+json
media type. error_category, retryable, and retry_after are
Framedash extension members. type always defaults to about:blank,
so it is always present; detail and the extension members are present
only when applicable.
object
Problem type URI; about:blank when no specific type applies.
Short, human-readable summary of the problem type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Extension member categorizing the error.
Extension member; true when retrying may succeed (e.g. 429, 503).
Extension member; suggested retry delay in seconds, when applicable.
The request rate limit was exceeded, or the tenant already had three
queries running and none finished within 10 seconds. The X-RateLimit-*
headers are present only when the request rate limit was exceeded. Wait
the number of seconds in Retry-After before retrying. For the request
rate limit, the value comes from a sliding window, so honor it on each
response.
RFC 9457 Problem Details. Served with the application/problem+json
media type. error_category, retryable, and retry_after are
Framedash extension members. type always defaults to about:blank,
so it is always present; detail and the extension members are present
only when applicable.
object
Problem type URI; about:blank when no specific type applies.
Short, human-readable summary of the problem type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Extension member categorizing the error.
Extension member; true when retrying may succeed (e.g. 429, 503).
Extension member; suggested retry delay in seconds, when applicable.
Headers
Section titled “Headers ”Number of seconds to wait before retrying. Present on 429 responses and
on the 503 response of POST /v1/query. For the request rate limit, the
value comes from a sliding window, so honor it on each response rather than
scheduling the retry for the reset time.
Maximum number of requests allowed per hour.
Number of requests remaining in the current window.
Unix timestamp in milliseconds when the rate limit window resets.
Infrastructure failure (for example, the database is unreachable). Errors in the submitted SQL are returned as 400, not 500.
RFC 9457 Problem Details. Served with the application/problem+json
media type. error_category, retryable, and retry_after are
Framedash extension members. type always defaults to about:blank,
so it is always present; detail and the extension members are present
only when applicable.
object
Problem type URI; about:blank when no specific type applies.
Short, human-readable summary of the problem type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Extension member categorizing the error.
Extension member; true when retrying may succeed (e.g. 429, 503).
Extension member; suggested retry delay in seconds, when applicable.
The query service is at capacity. Wait the number of seconds given in
Retry-After before retrying. This is separate from the request rate limit
and from the 500 infrastructure failure.
RFC 9457 Problem Details. Served with the application/problem+json
media type. error_category, retryable, and retry_after are
Framedash extension members. type always defaults to about:blank,
so it is always present; detail and the extension members are present
only when applicable.
object
Problem type URI; about:blank when no specific type applies.
Short, human-readable summary of the problem type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Extension member categorizing the error.
Extension member; true when retrying may succeed (e.g. 429, 503).
Extension member; suggested retry delay in seconds, when applicable.
Headers
Section titled “Headers ”Number of seconds to wait before retrying. Present on 429 responses and
on the 503 response of POST /v1/query. For the request rate limit, the
value comes from a sliding window, so honor it on each response rather than
scheduling the retry for the reset time.