---
search:
  tags:
    - database-services
    - POST
seo:
  description: >-
    Run a SQL query against a database… Reference for the POST
    /api/v1/database-services/{id}/sql/api/executeQuery endpoint in the
    TimescaleDB Enterprise API.
  noindex: true
sidebar:
  label: Run a SQL query
  badge: POST
title: Run a SQL query
type: openapi-operation
---
Run a SQL query against a database service, streaming NDJSON status.

`POST /api/v1/database-services/{id}/sql/api/executeQuery`

**Request body** (`application/json`, required)

- `projectId` (string)
- `query` (string)
- `runId` (string, required)
- `serviceId` (string)
- `statements` (string[])
- `timeout` (string) — The timeout of the run as a duration, for example 30s or 5m. The default is 30s. The maximum is 2m in read-only mode and 15m in write mode; a longer value gets the maximum.

Request body example:

```json
{
  "projectId": "string",
  "query": "string",
  "runId": "string",
  "serviceId": "string",
  "statements": [
    "string"
  ],
  "timeout": "string"
}
```

**Responses**

- `200` — OK
- `default` — Error
