curl --request POST \
--url https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"connection_ref": "<string>",
"sql": "<string>",
"max_rows": 1,
"mode": "<string>",
"timeout_ms": 1
}
'import requests
url = "https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query"
payload = {
"connection_ref": "<string>",
"sql": "<string>",
"max_rows": 1,
"mode": "<string>",
"timeout_ms": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
connection_ref: '<string>',
sql: '<string>',
max_rows: 1,
mode: '<string>',
timeout_ms: 1
})
};
fetch('https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/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.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query",
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([
'connection_ref' => '<string>',
'sql' => '<string>',
'max_rows' => 1,
'mode' => '<string>',
'timeout_ms' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query"
payload := strings.NewReader("{\n \"connection_ref\": \"<string>\",\n \"sql\": \"<string>\",\n \"max_rows\": 1,\n \"mode\": \"<string>\",\n \"timeout_ms\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"connection_ref\": \"<string>\",\n \"sql\": \"<string>\",\n \"max_rows\": 1,\n \"mode\": \"<string>\",\n \"timeout_ms\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"connection_ref\": \"<string>\",\n \"sql\": \"<string>\",\n \"max_rows\": 1,\n \"mode\": \"<string>\",\n \"timeout_ms\": 1\n}"
response = http.request(request)
puts response.read_body{
"columns": [
{
"data_type": "<string>",
"name": "<string>"
}
],
"row_count": 1,
"rows": [
[
{}
]
],
"truncated": true,
"rows_affected": 1
}Query Connector
Run an ad-hoc SQL query against a connector’s source and return the bounded result inline. Read-only by default (enforced node-side); write mode must also be allowed by the connection’s local policy on the connector box. Requires a connector advertising query:sql (0.1.26+).
curl --request POST \
--url https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"connection_ref": "<string>",
"sql": "<string>",
"max_rows": 1,
"mode": "<string>",
"timeout_ms": 1
}
'import requests
url = "https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query"
payload = {
"connection_ref": "<string>",
"sql": "<string>",
"max_rows": 1,
"mode": "<string>",
"timeout_ms": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
connection_ref: '<string>',
sql: '<string>',
max_rows: 1,
mode: '<string>',
timeout_ms: 1
})
};
fetch('https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/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.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query",
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([
'connection_ref' => '<string>',
'sql' => '<string>',
'max_rows' => 1,
'mode' => '<string>',
'timeout_ms' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query"
payload := strings.NewReader("{\n \"connection_ref\": \"<string>\",\n \"sql\": \"<string>\",\n \"max_rows\": 1,\n \"mode\": \"<string>\",\n \"timeout_ms\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"connection_ref\": \"<string>\",\n \"sql\": \"<string>\",\n \"max_rows\": 1,\n \"mode\": \"<string>\",\n \"timeout_ms\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.timbal.ai/orgs/{org_id}/connectors/{connector_id}/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"connection_ref\": \"<string>\",\n \"sql\": \"<string>\",\n \"max_rows\": 1,\n \"mode\": \"<string>\",\n \"timeout_ms\": 1\n}"
response = http.request(request)
puts response.read_body{
"columns": [
{
"data_type": "<string>",
"name": "<string>"
}
],
"row_count": 1,
"rows": [
[
{}
]
],
"truncated": true,
"rows_affected": 1
}Authorizations
Timbal API key. Obtain your API key from the Timbal platform settings. See Authentication for more information.
Body
Connection ref on the node (from /browse/connections).
The SQL to run. One statement on MySQL; multi-statement batches work on Postgres and SQL Server (the last result set is returned; on Postgres that's the last row-returning set — zero-row sets are invisible to the node's driver — while SQL Server returns the true last set even when empty).
Row cap on the returned result. Defaults to 500, ceiling 10000.
x >= 0read (default) | write. read is enforced node-side with
engine-level read-only semantics; write additionally requires the
connection's local policy (connections.json) to allow writes.
Node-side execution budget in milliseconds. Defaults to 30000, ceiling 60000.
x >= 0Response
Query executed
Show child attributes
Show child attributes
x >= 0Row-major, aligned with columns. Cells are plain JSON scalars:
numbers stay numbers, exact decimals and timestamps are strings,
binary is 0x-prefixed hex, NULL is null.
The node's row or byte cap bit — rows is a prefix of the real result.
Rows changed by non-row-returning statements, when the engine reports
it (Postgres/MySQL; null on SQL Server = unknown, not zero).
x >= 0