SQL API
Run SQL queries in your data warehouse.
Choosing an endpoint
About queryParameters and parameterized queries
sqlQuery: 'SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = @type AND revenue > @minRevenue'
queryParameters: { 'minRevenue': 100000, 'type': 'Supermarket' },sqlQuery: 'SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1'
queryParameters: [100000, "Supermarket"],sqlQuery: 'SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1...'
queryParameters: [100000, "Supermarket"],Endpoints
Runs a SQL query and returns the result.
Times out after 1 minute. For longer queries, create a job instead.
An API Access Token or an OAuth Access Token, sent as
Authorization: Bearer <token>.
Name of the connection to use.
carto_dwThe SQL query, or the name of a named source.
SELECT * FROM carto-demo-data.demo_tables.airportsValues for the parameters in the query, as a JSON string. Named object on BigQuery, positional array on Snowflake, Redshift and PostgreSQL.
{"minRevenue": 100000, "type": "Supermarket"}API version. From 3.3, spatialDataColumn and spatialDataType replace
geo_column.
3.0Possible values: The query result.
The rows returned by the query, plus the schema of the result set. Responses are capped at 200,000 rows.
The request is malformed or a parameter failed validation.
The token is missing, malformed or expired.
The token doesn't grant access to this resource.
The resource doesn't exist.
The query took longer than the 1 minute timeout.
You went over the rate limit for this API.
Same as the GET variant, for queries too long to fit in a URL.
This endpoint is not cached in CARTO's CDN, so every request reaches the data warehouse. Keep that in mind to avoid unnecessary compute cost.
An API Access Token or an OAuth Access Token, sent as
Authorization: Bearer <token>.
Name of the connection to use.
carto_dwThe SQL query, or the name of a named source.
Values for the parameters in the query. A named object on BigQuery, a positional array on Snowflake, Redshift and PostgreSQL.
The query result.
The rows returned by the query, plus the schema of the result set. Responses are capped at 200,000 rows.
The request is malformed or a parameter failed validation.
The token is missing, malformed or expired.
The token doesn't grant access to this resource.
The query took longer than the 1 minute timeout.
You went over the rate limit for this API.
Runs a query asynchronously. Use this for queries that would exceed the 1 minute timeout of the synchronous endpoints.
Available for BigQuery, Snowflake, Redshift, PostgreSQL and CARTO Data Warehouse connections.
Poll GET /v3/sql/{connectionName}/job/{jobId} with the
returned externalId to follow the execution.
An API Access Token or an OAuth Access Token, sent as
Authorization: Bearer <token>.
Name of the connection to use.
carto_dwThe SQL query, or the name of a named source. Note this field is
query, not q.
Values for the parameters in the query. A named object on BigQuery, a positional array on Snowflake, Redshift and PostgreSQL.
The job was created.
An asynchronous SQL job, as returned when it is created.
Use this to poll the job.
The request is malformed or a parameter failed validation.
The token is missing, malformed or expired.
The token doesn't grant access to this resource.
You went over the rate limit for this API.
Returns the current state of an asynchronous job.
An API Access Token or an OAuth Access Token, sent as
Authorization: Bearer <token>.
Name of the connection to use.
carto_dwThe job identifier.
job_h8UWzpdzX0s2XAAXQd3rdWCdPUT9The job.
The state of an asynchronous SQL job.
success, failure and cancelled are final states.
The token is missing, malformed or expired.
The token doesn't grant access to this resource.
The resource doesn't exist.
You went over the rate limit for this API.
Cancels a running job. Returns no content on success.
An API Access Token or an OAuth Access Token, sent as
Authorization: Bearer <token>.
Name of the connection to use.
carto_dwThe job identifier.
job_h8UWzpdzX0s2XAAXQd3rdWCdPUT9The job was cancelled.
No content
The token is missing, malformed or expired.
The token doesn't grant access to this resource.
The resource doesn't exist.
You went over the rate limit for this API.
No content
Lists the asynchronous jobs in your account.
Only userId, createdSince and client are accepted — any other query
parameter returns 400.
An API Access Token or an OAuth Access Token, sent as
Authorization: Bearer <token>.
Filter by user. Ignored when authenticating with an API Access Token, which is always scoped to its own user.
Only return jobs created after this date.
2026-07-01T00:00:00.000ZThe jobs.
A job as returned by the list endpoint. Note this shape uses state where
GET /v3/sql/{connectionName}/job/{jobId} uses status.
success, failure and cancelled are final states.
The request is malformed or a parameter failed validation.
The token is missing, malformed or expired.
The token doesn't grant access to this resource.
You went over the rate limit for this API.
Last updated
Was this helpful?
