Skip to content

SQL API

Execute SQL queries on the agent database.

Endpoints

MethodEndpointDescription
GET/api/agents/{id}/sql/schemaGet database schema
POST/api/agents/{id}/sql/executeExecute query

Get Schema

bash
GET /api/agents/{id}/sql/schema

Response

json
{
  "tables": [
    {
      "name": "workflows",
      "columns": [
        { "name": "id", "type": "TEXT", "nullable": false },
        { "name": "name", "type": "TEXT", "nullable": false },
        { "name": "status", "type": "TEXT", "nullable": true }
      ]
    }
  ]
}

Execute Query

bash
POST /api/agents/{id}/sql/execute
Content-Type: application/json

Request Body

json
{
  "query": "SELECT id, name FROM workflows LIMIT 10",
  "params": []
}

Response

json
{
  "columns": ["id", "name"],
  "rows": [
    ["workflow-1", "Email Notification"],
    ["workflow-2", "Data Sync"]
  ],
  "row_count": 2,
  "duration_ms": 5
}

Allowed Operations

OperationAllowed
SELECTYes
INSERTYes
UPDATEYes
DELETEYes
PRAGMAYes
EXPLAINYes
CREATENo
DROPNo
ALTERNo

Parameterized Queries

Use ? placeholders:

json
{
  "query": "SELECT * FROM contacts WHERE email = ?",
  "params": ["john@example.com"]
}

Errors

CodeDescription
400Invalid query
403Forbidden operation
500Execution error

Released under the MIT License.