Understand the SQL API request and response
The SQL API submits SQL over authenticated HTTPS and exposes execution status.
Understand the idea
REST describes an HTTP-oriented interface style. The SQL API is one specific API surface. Other Snowflake REST endpoints manage different resources, so use the endpoint and authentication documentation for the operation you intend.
| Concept | What it means |
|---|---|
| Submit | POST /api/v2/statements with SQL, context and supported authentication. |
| Wait | Use the returned statement handle/status URL when execution is asynchronous. |
| Retrieve | Read the result and any indicated additional partitions. |
| Retry | Follow request-ID semantics and inspect uncertain executions before retrying writes. |
A concrete example
A request for SELECT 101 AS ORDER_ID should eventually return one value, 101. A running response still needs status handling.
Remember: Track request and statement identity from submission through completion.
Explain it step by step · full theory
An HTTP caller can submit a SQL statement
The Snowflake SQL API exposes statement execution through authenticated HTTPS requests. A caller sends a request describing SQL and its context, then inspects the execution status and retrieves the result.
REST describes an HTTP-oriented interface style. The SQL API is one specific API surface. Other Snowflake REST endpoints manage different resources, so use the endpoint and authentication documentation for the operation you intend.
Prepare the request contract
For this conceptual exercise, the caller needs the account host and a supported token-based authentication setup, such as properly configured OAuth or key-pair JWT. A token must be valid for the account and permissions required by the request.
POST /api/v2/statements submits a statement. The JSON body can specify statement, timeout, warehouse, database, schema and role. Use actual authorized context values and the case expected by the API. The body example below is a request template for SELECT 101, with placeholders clearly identified.
An HTTP Content-Type of application/json describes the request encoding. Authorization carries the credential. Keep tokens outside committed JSON examples and avoid logging them with request diagnostics.
Handle asynchronous execution and retrieval
A caller must handle a statement that is still running. Inspect the response status and returned statementHandle or status URL. Poll using the documented status operation until a terminal outcome is reached, then process the returned data and any result partitions.
A submitted request is only the beginning of execution. A network timeout can leave the caller uncertain whether the server accepted the request. Follow the API’s request-ID and retry semantics and inspect the statement status before retrying operations that write data.
For SELECT 101, expect one result row representing ORDER_ID 101 after success. Preserve statement identity and error details for failure analysis. If the response indicates additional result partitions for a larger query, retrieve them according to the response metadata.
Your Level 0 completion exercise
Choose one interface you can use in an authorized learning account. Explain its account identifier format, authentication setup and role/warehouse context, then describe how to submit a query, inspect its result and find execution evidence.
You have now followed all 27 source topics. Continue into architecture with an understanding of the user interface, account boundaries and client lifecycle. The earlier foundation modules remain available for deeper guided practice.
Words used in this lesson
- REST
- An HTTP-oriented approach to service interfaces.
- Statement handle
- An identifier used to inspect a SQL API statement.
- Polling
- Requesting updated status while an operation is still in progress.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Understand the SQL API request and response
Submit
Send SQL and context through an authenticated request.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Submit
Send SQL and context through an authenticated request.
- Observe
Follow the execution status.
- Retrieve
Read the result and preserve evidence.
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
Optional connectivity path for learners familiar with HTTP requests and authentication. You can finish the SQL learning path in Snowsight before practising this API. No request is sent by this website.
SQL API request body template
{"statement":"SELECT 101 AS ORDER_ID","timeout":60,"warehouse":"YOUR_ALLOWED_WAREHOUSE","role":"YOUR_ALLOWED_ROLE"}What to expect and why
Send this adapted body to the account’s /api/v2/statements endpoint with the required authentication headers. Replace both placeholders. This body alone is not a complete authenticated HTTP request.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Describe the complete request-to-result workflow for the SQL API.
Compare your reasoning
Authenticate, submit SQL with the intended context, inspect the response, follow asynchronous status when needed, retrieve all indicated result data and preserve the execution identity.
Official sources and curriculum
Module 01 · See module scope