API reference
Query workspace data
Run role aware SQL against the database attached to one Supervisor workspace.
API reference
01
Database proxy
The database proxy accepts one SQL statement and optional positional parameters. It applies the authenticated member role before executing the request.
Viewer roles are read only. The proxy blocks unsafe database directives including ATTACH, DETACH, and PRAGMA. Use parameters for values instead of constructing SQL with untrusted input.
- sql
- Required string containing one SQL statement
- params
- Optional array of positional values for the statement
import jsonimport osimport urllib.requesturl = "https://api.trysupervisor.com/workspaces/{workspaceId}/db"payload = json.dumps({"sql": "SELECT id, status, updated_at FROM orders ORDER BY updated_at DESC LIMIT 20","params": []}).encode("utf-8")request = urllib.request.Request(url, data=payload, method="POST")request.add_header("Authorization", f"Bearer {os.environ['SUPERVISOR_API_KEY']}")request.add_header("Content-Type", "application/json")with urllib.request.urlopen(request) as response:result = json.load(response)print(json.dumps(result, indent=2))
02
Workspace records
Schemas differ because mini apps and connected workflows create data for the needs of each workspace. Inspect the schema in Supervisor before writing a query that depends on custom tables or columns.