Skip to content

SQL Execution

Execute arbitrary SQL against any connected database. Supports SELECT, DML (INSERT/UPDATE/DELETE), and DDL (CREATE/ALTER/DROP) with configurable guardrails for agent callers.

Terminal window
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"
}'
FieldTypeDefaultDescription
connection_idstring(required)UUID of the database connection.
sqlstring(required)SQL statement to execute.
callerstring"human""human" (no guardrails) or "agent" (guardrails apply).
guardrailstring"strict"Agent guardrail level. Only applies when caller="agent".
row_limitinteger1000Maximum rows to return (1-10000).
timeout_secondsnumber30.0Query timeout in seconds (1-120).

Only apply when caller="agent":

LevelSELECTDMLDDL
strictYesNoNo
moderateYesYesNo
permissiveYesYesYes
{
"success": true,
"data": {
"columns": ["id", "name", "email"],
"rows": [[1, "Acme Corp", "acme@example.com"]],
"row_count": 1,
"truncated": false
}
}
{
"success": true,
"data": {
"columns": [],
"rows": [],
"row_count": 0,
"truncated": false,
"affected_rows": 5
}
}
CodeDescription
GUARDRAIL_VIOLATIONAgent attempted a statement type blocked by its guardrail level.
SQL_ERRORQuery failed during execution (syntax error, constraint violation, etc.).
TIMEOUTQuery exceeded the configured timeout.