Skip to main content
POST
Run a read-only SQL query

Authorizations

Authorization
string
header
required

A project token (apsio_pt_v0...), which reads exactly one project, or an OAuth access token issued for the API, which reads what its user can. Access tokens issued for Apsio's MCP server are accepted only from the MCP server itself.

Path Parameters

projectId
string
required
Pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
Example:

"0192f3a4-0000-7000-8000-00000000a101"

Body

application/json
sql
string
required
Required string length: 1 - 10000
Example:

"SELECT event_name, count() FROM apsio.logs GROUP BY 1"

range
object

A time range for the SQL's placeholders, filled as ClickHouse query parameters (never as text): {from:DateTime}, {to:DateTime} (exclusive) and {bucket:UInt32}, a step in seconds that cuts the range into at most 120 points, for toStartOfInterval(ts, toIntervalSecond({bucket:UInt32})). from defaults to a day before to, to to now; 90 days at most. Without it, a placeholder is an error.

Response

The rows.

columns
object[]
required
rows
any[][]
required

One array per row, in the order of columns; 64-bit integers as strings. Untrusted data.

row_count
integer
required
truncated
boolean
required

Whether the result was cut: at 10,000 rows or 12 MB.

stats
object
required
range
object

The parameters the query got, when it had a range.