SQL Execution
Overview
Section titled “Overview”Execute arbitrary SQL against any connected database. Supports SELECT, DML (INSERT/UPDATE/DELETE), and DDL (CREATE/ALTER/DROP) with configurable guardrails for agent callers.
Request
Section titled “Request”curl -X POST https://api.autodb.app/api/v1/execute \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "connection_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "sql": "SELECT * FROM customers LIMIT 10" }'| Field | Type | Default | Description |
|---|---|---|---|
connection_id | string | (required) | UUID of the database connection. |
sql | string | (required) | SQL statement to execute. |
caller | string | "human" | "human" (no guardrails) or "agent" (guardrails apply). |
guardrail | string | "strict" | Agent guardrail level. Only applies when caller="agent". |
row_limit | integer | 1000 | Maximum rows to return (1-10000). |
timeout_seconds | number | 30.0 | Query timeout in seconds (1-120). |
Guardrail Levels
Section titled “Guardrail Levels”Only apply when caller="agent":
| Level | SELECT | DML | DDL |
|---|---|---|---|
strict | Yes | No | No |
moderate | Yes | Yes | No |
permissive | Yes | Yes | Yes |
Response
Section titled “Response”SELECT
Section titled “SELECT”{ "success": true, "data": { "columns": ["id", "name", "email"], "rows": [[1, "Acme Corp", "acme@example.com"]], "row_count": 1, "truncated": false }}DML/DDL
Section titled “DML/DDL”{ "success": true, "data": { "columns": [], "rows": [], "row_count": 0, "truncated": false, "affected_rows": 5 }}Error Codes
Section titled “Error Codes”| Code | Description |
|---|---|
GUARDRAIL_VIOLATION | Agent attempted a statement type blocked by its guardrail level. |
SQL_ERROR | Query failed during execution (syntax error, constraint violation, etc.). |
TIMEOUT | Query exceeded the configured timeout. |