---
title: "Execute database operations. Do not use to modify the database schema, use /apis/migrate instead"
method: POST
path: "/v2/query"
---

# Execute database operations. Do not use to modify the database schema, use /apis/migrate instead

`POST /v2/query`

Execute SQL queries and other database operations

## Request body

- union
  - RunSqlRequest
    - `type` 'run_sql', required — Type of operation to execute SQL queries
    - `args` object, required
      - `source` string, required — The data source name
      - `sql` string, required — SQL statement to execute
      - `cascade` boolean — Whether to cascade the operation
      - `read_only` boolean — Whether the operation is read-only
  - BulkRequest
    - `type` 'bulk', required — Type of operation to execute multiple operations in a batch
    - `source` string, required — The data source name
    - `args` BulkRunSqlOperation[], required — Array of operations to execute
      - `type` 'run_sql', required — Type of operation to execute SQL queries
      - `args` object, required
        - `source` string, required — The data source name
        - `sql` string, required — SQL statement to execute
        - `cascade` boolean — Whether to cascade the operation
        - `read_only` boolean — Whether the operation is read-only

## Response `200`

Operation executed successfully

- union
  - TuplesOkResponse
    - `result_type` 'TuplesOk', required — Indicates a successful query that returns rows
    - `result` array[], required — The result set, with the first row containing column names
      - string[]
  - CommandOkResponse
    - `result_type` 'CommandOk', required — Indicates a successful command that doesn't return rows
    - `result` integer, required — Number of rows affected

## Other responses

- `400` — Bad request
- `500` — Internal server error

---

[API](https://skmtc.dev/nhost/apis/hasura-api.md) · [All operations](https://skmtc.dev/nhost/apis/hasura-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/nhost/hasura-api/revisions/e0cb77c2f8e2/schema)
