---
title: "Submits a SQL statement for execution."
method: POST
path: "/api/v2/statements"
tags: ["statements"]
---

# Submits a SQL statement for execution.

`POST /api/v2/statements`

Submits one or more statements for execution. You can specify that the statement should be executed asynchronously.

## Request body

- object
  - `statement` string — SQL statement or batch of SQL statements to execute. You can specify query, DML and DDL statements. The following statements are not supported: PUT, GET, USE, ALTER SESSION, BEGIN, COMMIT, ROLLBACK, statements that set session variables, and statements that create temporary tables and stages.
  - `timeout` integer — Timeout in seconds for statement execution. If the execution of a statement takes longer than the specified timeout, the execution is automatically canceled. To set the timeout to the maximum value (604800 seconds), set timeout to 0.
  - `database` string — Database in which the statement should be executed. The value in this field is case-sensitive.
  - `schema` string — Schema in which the statement should be executed. The value in this field is case-sensitive.
  - `warehouse` string — Warehouse to use when executing the statement. The value in this field is case-sensitive.
  - `role` string — Role to use when executing the statement. The value in this field is case-sensitive.
  - `bindings` object — Values of bind variables in the SQL statement. When executing the statement, Snowflake replaces placeholders ('?' and ':name') in the statement with these specified values.
  - `parameters` object — Session parameters that should be set before executing the statement.
    - `timezone` string — Time zone to use when executing the statement.
    - `query_tag` string — Query tag that you want to associate with the SQL statement.
    - `binary_output_format` string — Output format for binary values.
    - `date_output_format` string — Output format for DATE values.
    - `time_output_format` string — Output format for TIME values.
    - `timestamp_output_format` string — Output format for TIMESTAMP values.
    - `timestamp_ltz_output_format` string — Output format for TIMESTAMP_LTZ values.
    - `timestamp_ntz_output_format` string — Output format for TIMESTAMP_NTZ values.
    - `timestamp_tz_output_format` string — Output format for TIMESTAMP_TZ values.
    - `multi_statement_count` integer — Number of statements to execute when using multi-statement capability. 0 implies variable number of statements. Negative numbers are not allowed.

## Response `200`

The statement was executed successfully, and the response includes any data requested.

- ResultSet
  - `code` string
  - `sqlState` string
  - `message` string
  - `statementHandle` string, uuid
  - `createdOn` integer — Timestamp that specifies when the statement execution started.‌ The timestamp is expressed in milliseconds since the epoch.‌
  - `statementStatusUrl` string, uri
  - `resultSetMetaData` object
    - `format` 'jsonv2' — For v2 endpoints the only possible value for this field is jsonv2.
    - `numRows` integer — The total number of rows of results.
    - `rowType` object[]
      - `name` string
      - `type` string
      - `length` integer
      - `precision` integer
      - `scale` integer
      - `nullable` boolean
    - `partitionInfo` object[] — Partition information
      - `rowCount` integer — Number of rows in the partition.
      - `compressedSize` integer — the partition size before the decompression. This may or may not be present in the partitionInfo. Uncompressed size would always be there.
      - `uncompressedSize` integer — the partition size after the decompression
    - `nullable` boolean — false if null is replaced with a string 'null' otherwise false
    - `parameters` object
      - `binary_output_format` string
      - `date_output_format` string
      - `time_output_format` string
      - `timestamp_output_format` string
      - `timestamp_ltz_output_format` string
      - `timestamp_ntz_output_format` string
      - `timestamp_tz_output_format` string
      - `multi_statement_count` integer
  - `data` array[] — Result set data.
    - string[]
  - `stats` object — these stats might not be available for each request.
    - `numRowsInserted` integer — Number of rows that were inserted.
    - `numRowsUpdated` integer — Number of rows that were updated.
    - `numRowsDeleted` integer — Number of rows that were deleted.
    - `numDuplicateRowsUpdated` integer — Number of duplicate rows that were updated.

## Other responses

- `202` — The execution of the statement is still in progress. Use GET /statements/ and specify the statement handle to check the status of the statement execution.
- `400` — Bad Request. The request payload is invalid or malformed. This happens if the application didn't send the correct request payload. The response body may include the error code and message indicating the actual cause. The application must reconstruct the request body for retry.
- `401` — Unauthorized. The request is not authorized. This happens if the attached access token is invalid or missing. The response body may include the error code and message indicating the actual cause, e.g., expired, invalid token. The application must obtain a new access token for retry.
- `403` — Forbidden. The request is forbidden. This happens if the request is made even if the API is not enabled.
- `404` — Not Found. The request endpoint is not valid. This happens if the API endpoint is wrong. For example, if the application hits /api/api/hello which doesn't exist, it will receive this code.
- `405` — Method Not Allowed. The request method doesn't match the supported API. This happens, for example, if the application calls the API with GET method but the endpoint accepts only POST. The application must change a method for retry.
- `408` — The execution of the statement exceeded the timeout period. The execution of the statement was cancelled.
- `415` — The request header Content-Type includes unsupported media type. The API supports application/json only. If none specified, the request payload is taken as JSON, but if any other media type is specified, this error is returned.
- `422` — An error occurred when executing the statement. Check the error code and error message for details.
- `429` — Limit Exceeded. The number of requests hit the rate limit. The application must slow down the frequency of hitting the API endpoints.
- `500` — Internal Server Error. The server hits an unrecoverable system error. The response body may include the error code and message for further guidance. The application owner may need to reach out the customer support.
- `503` — Service Unavailable. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
- `504` — Gateway Timeout. The request was not processed due to server side timeouts. The application may retry with backoff. The jittered backoff is recommended. https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

---

[API](https://skmtc.dev/snowflakedb/apis/snowflake-sql-api.md) · [All operations](https://skmtc.dev/snowflakedb/apis/snowflake-sql-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/snowflakedb/snowflake-sql-api/revisions/28b780dd0569/schema)
