SQL
Run SQL on one project
POST
One SELECT or WITH against the views in /v2/query/schema, limited to this project, as a read-only role with a 10-second timeout and 10,000 rows. :from, :to and :project come from params as bound values.
AuthorizationBearer <token>
An API token from POST /v2/tokens (at_live_...), or a project's secret key (sk_...) for server-side ingest.
In: header
Path Parameters
project*string
The project id, as listed by GET /v2/projects.
Length
1 <= lengthTypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v2/projects/string/query" \ -H "Content-Type: application/json" \ -d '{ "sql": "select route, count(*) as views from events where name = \'pageview\' and ts > now() - interval \'7 days\' group by 1 order by 2 desc limit 5" }'{ "columns": [ "route", "views" ], "rows": [ [ "/", 1011 ], [ "/blog/[slug]", 530 ] ], "rowCount": 2, "truncated": false, "durationMs": 41}