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

# Run a query

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

Runs a SQL query and returns the result.

Times out after 1 minute. For longer queries, create a job instead.

## Path parameters

- `connectionName` string, required

## Query parameters

- `q` string, required
- `queryParameters` string
- `v` '3.0' | '3.1' | '3.2' | '3.3' | '3.4'

## 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.
- `404` — The resource doesn't exist.
- `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)
