Submit a statement
curl --request POST \
--url https://{host}/api/v2/sql/statements \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'cluster-name: <cluster-name>' \
--data '
{
"statement": "SELECT * FROM sales LIMIT 1000",
"catalog": "<CATALOG>",
"schema": "<SCHEMA>",
"wait_timeout": "30s",
"format": "JSON_ARRAY"
}
'import requests
url = "https://{host}/api/v2/sql/statements"
payload = {
"statement": "SELECT * FROM sales LIMIT 1000",
"catalog": "<CATALOG>",
"schema": "<SCHEMA>",
"wait_timeout": "30s",
"format": "JSON_ARRAY"
}
headers = {
"cluster-name": "<cluster-name>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'cluster-name': '<cluster-name>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
statement: 'SELECT * FROM sales LIMIT 1000',
catalog: '<CATALOG>',
schema: '<SCHEMA>',
wait_timeout: '30s',
format: 'JSON_ARRAY'
})
};
fetch('https://{host}/api/v2/sql/statements', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/v2/sql/statements",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'statement' => 'SELECT * FROM sales LIMIT 1000',
'catalog' => '<CATALOG>',
'schema' => '<SCHEMA>',
'wait_timeout' => '30s',
'format' => 'JSON_ARRAY'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"cluster-name: <cluster-name>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/v2/sql/statements"
payload := strings.NewReader("{\n \"statement\": \"SELECT * FROM sales LIMIT 1000\",\n \"catalog\": \"<CATALOG>\",\n \"schema\": \"<SCHEMA>\",\n \"wait_timeout\": \"30s\",\n \"format\": \"JSON_ARRAY\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cluster-name", "<cluster-name>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/api/v2/sql/statements")
.header("cluster-name", "<cluster-name>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"statement\": \"SELECT * FROM sales LIMIT 1000\",\n \"catalog\": \"<CATALOG>\",\n \"schema\": \"<SCHEMA>\",\n \"wait_timeout\": \"30s\",\n \"format\": \"JSON_ARRAY\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/v2/sql/statements")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cluster-name"] = '<cluster-name>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"statement\": \"SELECT * FROM sales LIMIT 1000\",\n \"catalog\": \"<CATALOG>\",\n \"schema\": \"<SCHEMA>\",\n \"wait_timeout\": \"30s\",\n \"format\": \"JSON_ARRAY\"\n}"
response = http.request(request)
puts response.read_body{
"statement_id": "stmt-…",
"status": {
"state": "RUNNING"
},
"session_id": "eyJ…"
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}Submit a statement
Submit a SQL statement for execution. Submission is asynchronous: the response contains a
statement_id to poll and a session_id you can reuse via the X-Session-Id header.
If the cluster is suspended, it auto-resumes on the first statement and the request waits (about 30–90 seconds).
POST
/
api
/
v2
/
sql
/
statements
Submit a statement
curl --request POST \
--url https://{host}/api/v2/sql/statements \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'cluster-name: <cluster-name>' \
--data '
{
"statement": "SELECT * FROM sales LIMIT 1000",
"catalog": "<CATALOG>",
"schema": "<SCHEMA>",
"wait_timeout": "30s",
"format": "JSON_ARRAY"
}
'import requests
url = "https://{host}/api/v2/sql/statements"
payload = {
"statement": "SELECT * FROM sales LIMIT 1000",
"catalog": "<CATALOG>",
"schema": "<SCHEMA>",
"wait_timeout": "30s",
"format": "JSON_ARRAY"
}
headers = {
"cluster-name": "<cluster-name>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'cluster-name': '<cluster-name>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
statement: 'SELECT * FROM sales LIMIT 1000',
catalog: '<CATALOG>',
schema: '<SCHEMA>',
wait_timeout: '30s',
format: 'JSON_ARRAY'
})
};
fetch('https://{host}/api/v2/sql/statements', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/v2/sql/statements",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'statement' => 'SELECT * FROM sales LIMIT 1000',
'catalog' => '<CATALOG>',
'schema' => '<SCHEMA>',
'wait_timeout' => '30s',
'format' => 'JSON_ARRAY'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"cluster-name: <cluster-name>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/v2/sql/statements"
payload := strings.NewReader("{\n \"statement\": \"SELECT * FROM sales LIMIT 1000\",\n \"catalog\": \"<CATALOG>\",\n \"schema\": \"<SCHEMA>\",\n \"wait_timeout\": \"30s\",\n \"format\": \"JSON_ARRAY\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cluster-name", "<cluster-name>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/api/v2/sql/statements")
.header("cluster-name", "<cluster-name>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"statement\": \"SELECT * FROM sales LIMIT 1000\",\n \"catalog\": \"<CATALOG>\",\n \"schema\": \"<SCHEMA>\",\n \"wait_timeout\": \"30s\",\n \"format\": \"JSON_ARRAY\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/v2/sql/statements")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cluster-name"] = '<cluster-name>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"statement\": \"SELECT * FROM sales LIMIT 1000\",\n \"catalog\": \"<CATALOG>\",\n \"schema\": \"<SCHEMA>\",\n \"wait_timeout\": \"30s\",\n \"format\": \"JSON_ARRAY\"\n}"
response = http.request(request)
puts response.read_body{
"statement_id": "stmt-…",
"status": {
"state": "RUNNING"
},
"session_id": "eyJ…"
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}{
"error": {
"code": "QUERY_TIMEOUT",
"message": "Query exceeded the configured timeout",
"details": {}
}
}Authorizations
Send Authorization: Bearer <session> using the sessionId returned by POST /api/v1/authenticate.
You can also send a personal access token or service account key directly as the bearer token,
or use an SSO/OIDC JWT.
Headers
The target cluster. Required on all requests.
Body
application/json