---
title: "Run a query (POST)"
method: POST
path: "/v3/sql/{connectionName}/query"
tags: ["SQL"]
---

# Run a query (POST)

`POST /v3/sql/{connectionName}/query`

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.

## Path parameters

- `connectionName` string, required

## Request body

- object
  - `q` string, required — The SQL query, or the name of a named source.
  - `queryParameters` union — Values for the parameters in the query. A named object on BigQuery, a positional array on Snowflake, Redshift and PostgreSQL.
    - object
    - unknown[]
      - unknown

## Response `200`

The query result.

- SqlResponse — The rows returned by the query, plus the schema of the result set. Responses are capped at 200,000 rows.
  - `rows` object[] — The result rows. Geometry columns are returned as GeoJSON.
  - `schema` SchemaField[]
    - `name` string, required
    - `type` 'number' | 'bigint' | 'string' | 'geometry' | 'timestamp' | 'object' | 'boolean' | 'variant' | 'unknown' | 'array', required
  - `meta` object — Provider-specific metadata.

## Other responses

- `400` — The request is malformed or a parameter failed validation.
- `401` — The token is missing, malformed or expired.
- `403` — The token doesn't grant access to this resource.
- `408` — The query took longer than the 1 minute timeout.
- `429` — You went over the [rate limit](#rate-limits) for this API.

---

[API](https://skmtc.net/gitbookio/apis/carto-api.md) · [All operations](https://skmtc.net/gitbookio/apis/carto-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gitbookio/carto-api/revisions/019f79ecdd6c/schema)
