Run SQL query against workspace data Executes a read-only PostgreSQL SELECT query against workspace data definitions projected as queryable tables. The query must reference a current workspace definition handle or its generated snake_case alias; bare table names only work when they match an existing definition.
POST /api/v1/data/sql-queryTest
Executes a read-only PostgreSQL SELECT query against workspace data definitions projected as queryable tables. The query must reference a current workspace definition handle or its generated snake_case alias; bare table names only work when they match an existing definition.
TypeScript Definitions
Use the request body type in TypeScript.
Copy
cURL
JavaScript
Go
Python
Java
C#curl -X POST "https://loading/api/v1/data/sql-query" \ -H "Content-Type: application/json" \ -d '{ "sql": "SELECT id, email, created_at FROM customer ORDER BY created_at DESC LIMIT 10" }'
200 400 401 403 500
{
"sql" : "SELECT id, email, created_at FROM customer ORDER BY created_at DESC LIMIT 10" ,
"normalizedSql" : "SELECT id, email, created_at FROM customer ORDER BY created_at DESC LIMIT 10" ,
"usedTables" : [
"customer"
],
"table" : {
"columns" : [
"id" ,
"email" ,
"created_at"
],
"rows" : [
[
"rec_123" ,
"jane@example.com" ,
"2026-03-17T10:00:00.000Z"
]
]
},
"records" : [
{
"id" : "rec_123" ,
"email" : "jane@example.com" ,
"created_at" : "2026-03-17T10:00:00.000Z"
}
],
"ascii" : "+---------+------------------+---------------------------+ \n | id | email | created_at | \n +---------+------------------+---------------------------+ \n | rec_123 | jane@example.com | 2026-03-17T10:00:00.000Z | \n +---------+------------------+---------------------------+ \n (1 row shown, limit 10)" ,
"rowCount" : 1 ,
"executionTimeMs" : 12 ,
"truncated" : false ,
"cached" : false ,
"warnings" : []
} {
"issues" : [
{
"_tag" : "Pointer" ,
"path" : [
"string"
],
"message" : "string"
}
],
"message" : "string" ,
"_tag" : "HttpApiDecodeError"
} {
"code" : "authentication_required" ,
"message" : "Authentication required. Send Authorization: Bearer <api-key>, x-api-key, or a signed-in session."
} {
"code" : "insufficient_permissions" ,
"message" : "This API key does not have data.read permission." ,
"details" : {
"requiredPermission" : "data.read"
}
} {
"code" : "internal_error" ,
"message" : "An unexpected server error occurred."
}