POST /projects/{project}/query
curl --request POST \
--url https://api-zangtable.com/projects/{project}/query \
--header 'Authorization: <authorization>'import requests
url = "https://api-zangtable.com/projects/{project}/query"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api-zangtable.com/projects/{project}/query', 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://api-zangtable.com/projects/{project}/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-zangtable.com/projects/{project}/query"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-zangtable.com/projects/{project}/query")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-zangtable.com/projects/{project}/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {},
"error": {},
"request_id": "<string>"
}Query and indexes
POST /projects/{project}/query
Runs one read-only SQL statement.
POST
https://api-zangtable.com
/
projects
/
{project}
/
query
POST /projects/{project}/query
curl --request POST \
--url https://api-zangtable.com/projects/{project}/query \
--header 'Authorization: <authorization>'import requests
url = "https://api-zangtable.com/projects/{project}/query"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api-zangtable.com/projects/{project}/query', 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://api-zangtable.com/projects/{project}/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-zangtable.com/projects/{project}/query"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-zangtable.com/projects/{project}/query")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-zangtable.com/projects/{project}/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {},
"error": {},
"request_id": "<string>"
}Runs one read-only SQL statement.
Full request:
Error or alternate response:
Endpoint details
string
required
Bearer
pat_... (Project API Token). Keep this token on your backend/server.string
required
Project slug. This acts as the Project ID in API paths.
boolean
required
true for a successful response and false for an error response.object | null
Endpoint-specific response data when
ok is true; null on errors.object | null
Error code and message when
ok is false; null on success.string
required
Request identifier you can use when troubleshooting a specific API call.
Authentication
Project API Token.Parameters
Body:sql or query required; params optional array or object; limit optional integer, clamped 1-1000, default 500.
Notes
OnlySELECT, WITH, and EXPLAIN QUERY PLAN are accepted. Multiple statements and write/schema keywords are blocked. A Project API Token can read registered application tables through this endpoint. Queries that try to read project control or credential tables return 403 query_table_denied. Joins and CTEs over registered application tables remain supported.
Queries also have execution and result-size budgets. An overly expensive query returns 422 query_budget_exceeded; an oversized result returns 413 query_result_too_large. Add an appropriate index or narrow the query and try again. The limit caps returned rows but does not by itself make an expensive query fast.
Request examples
Basic request:curl -X POST "$BASE_URL/projects/{project}/query" \
-H 'Authorization: Bearer pat_PROJECT_TOKEN' \
-H 'Content-Type: application/json' \
--data '{"sql":"SELECT id, email FROM contacts LIMIT 10"}'
curl -X POST "$BASE_URL/projects/{project}/query" \
-H 'Authorization: Bearer pat_PROJECT_TOKEN' \
-H 'Content-Type: application/json' \
-H 'X-Operation-Key: edit-profile-email' \
-H 'X-Operation-Run-Id: oprun_client_20260602_001' \
--data '{"query":"SELECT id, email FROM contacts WHERE status = :status ORDER BY id DESC","params":{"status":"active"},"limit":1000}'
Response examples
Success:{
"ok": true,
"data": {
"rows": [
{
"id": 1,
"email": "ada@example.com"
}
],
"row_count": 1,
"limit": 500,
"duration_ms": 24.5
},
"error": null,
"request_id": "req_20260602T012345_123456Z_abc123def456",
"operation_key": "edit-profile-email",
"operation_run_id": "oprun_20260602T012300_000000Z_a1b2c3d4e5f6",
"operation_grouping_status": "accepted_provided_run",
"meta": {
"generated_at": "2026-06-02T01:23:45Z"
}
}
{
"ok": false,
"data": null,
"error": {
"code": "write_sql_forbidden",
"message": "This endpoint only accepts read-only SQL and does not support ATTACH, PRAGMA, writes, or schema changes."
},
"request_id": "req_20260602T012345_123456Z_abc123def456",
"meta": {
"generated_at": "2026-06-02T01:23:45Z"
}
}