コンテンツにスキップ

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.

object
project_id
required

The project ID to query.

string format: uuid
sql
required

SQL query (SELECT only).

string
limit

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.

integer
default: 1000 >= 1

Query results.

object
success
boolean
data
object
rows

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.

Array<object>
object
key
additional properties
any
rowCount

Number of rows returned.

integer
X-RateLimit-Limit
integer

Maximum number of requests allowed per hour.

X-RateLimit-Remaining
integer

Number of requests remaining in the current window.

X-RateLimit-Reset
integer

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
type
required

Problem type URI; about:blank when no specific type applies.

string format: uri
default: about:blank
title
required

Short, human-readable summary of the problem type.

string
status
required

HTTP status code.

integer
detail

Human-readable explanation specific to this occurrence.

string
error_category

Extension member categorizing the error.

string
Allowed values: authentication authorization validation rate_limit not_found conflict payload internal
retryable

Extension member; true when retrying may succeed (e.g. 429, 503).

boolean
retry_after

Extension member; suggested retry delay in seconds, when applicable.

integer

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
type
required

Problem type URI; about:blank when no specific type applies.

string format: uri
default: about:blank
title
required

Short, human-readable summary of the problem type.

string
status
required

HTTP status code.

integer
detail

Human-readable explanation specific to this occurrence.

string
error_category

Extension member categorizing the error.

string
Allowed values: authentication authorization validation rate_limit not_found conflict payload internal
retryable

Extension member; true when retrying may succeed (e.g. 429, 503).

boolean
retry_after

Extension member; suggested retry delay in seconds, when applicable.

integer

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
type
required

Problem type URI; about:blank when no specific type applies.

string format: uri
default: about:blank
title
required

Short, human-readable summary of the problem type.

string
status
required

HTTP status code.

integer
detail

Human-readable explanation specific to this occurrence.

string
error_category

Extension member categorizing the error.

string
Allowed values: authentication authorization validation rate_limit not_found conflict payload internal
retryable

Extension member; true when retrying may succeed (e.g. 429, 503).

boolean
retry_after

Extension member; suggested retry delay in seconds, when applicable.

integer

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
type
required

Problem type URI; about:blank when no specific type applies.

string format: uri
default: about:blank
title
required

Short, human-readable summary of the problem type.

string
status
required

HTTP status code.

integer
detail

Human-readable explanation specific to this occurrence.

string
error_category

Extension member categorizing the error.

string
Allowed values: authentication authorization validation rate_limit not_found conflict payload internal
retryable

Extension member; true when retrying may succeed (e.g. 429, 503).

boolean
retry_after

Extension member; suggested retry delay in seconds, when applicable.

integer
Retry-After
integer

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.

X-RateLimit-Limit
integer

Maximum number of requests allowed per hour.

X-RateLimit-Remaining
integer

Number of requests remaining in the current window.

X-RateLimit-Reset
integer

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
type
required

Problem type URI; about:blank when no specific type applies.

string format: uri
default: about:blank
title
required

Short, human-readable summary of the problem type.

string
status
required

HTTP status code.

integer
detail

Human-readable explanation specific to this occurrence.

string
error_category

Extension member categorizing the error.

string
Allowed values: authentication authorization validation rate_limit not_found conflict payload internal
retryable

Extension member; true when retrying may succeed (e.g. 429, 503).

boolean
retry_after

Extension member; suggested retry delay in seconds, when applicable.

integer

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
type
required

Problem type URI; about:blank when no specific type applies.

string format: uri
default: about:blank
title
required

Short, human-readable summary of the problem type.

string
status
required

HTTP status code.

integer
detail

Human-readable explanation specific to this occurrence.

string
error_category

Extension member categorizing the error.

string
Allowed values: authentication authorization validation rate_limit not_found conflict payload internal
retryable

Extension member; true when retrying may succeed (e.g. 429, 503).

boolean
retry_after

Extension member; suggested retry delay in seconds, when applicable.

integer
Retry-After
integer

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.