---
title: "Submit a SQL query"
method: POST
path: "/v1/{organization}/admin/sql_query"
tags: ["Admin"]
---

# Submit a SQL query

`POST /v1/{organization}/admin/sql_query`

Execute a read-only SQL query on Amigo's databases for the specified organization.

#### Permissions
This endpoint requires the authenticated user to have greater privileges than the `DefaultAdministratorRole`.

## Path parameters

- `organization` string, required

## Headers

- `x-mongo-cluster-name` string, nullable — The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.
- `Sec-WebSocket-Protocol` string[]

## Request body

- SrcAppEndpointsAdminSubmitSqlQueryRequest
  - `sql_query` string, required
  - `async_query` false, required — Whether the query is asynchronous. If true, a signed URL will be returned to download the results once the query is complete. If false, the results will be returned in the response, but at most 1000 rows will be returned, and the query is subject to a 30 second execution timeout.

## Response `200`

Succeeded.

- SrcAppEndpointsAdminSubmitSqlQueryResponse
  - `execution_time_ms` integer, required — The time taken to execute the query in milliseconds.
  - `result` array[], required — The result of the query as a list of rows, where each row is a list of column values.
    - unknown[]
      - unknown
  - `truncated` boolean, required — Whether the result was truncated due to the row limit.
  - `columns` Column[], required — Description of the columns in the result.
    - `name` string, required — The name of the column.
    - `type` string, required — The data type of the column.

## Other responses

- `400` — This endpoint is not supported in the current environment, or the SQL query is invalid.
- `401` — Invalid authorization credentials.
- `403` — Missing required permissions.
- `404` — The specified organization does not exist.
- `408` — The supplied query cannot be executed within the time limit.
- `422` — Invalid request path parameter or request body failed validation.
- `429` — The user has exceeded the rate limit of 6 requests per minute for this endpoint.
- `503` — The service is going through temporary maintenance.

---

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