Skip to content

SQL Interface ​

Query your agent's database directly with the SQL editor.

Overview ​

Features:

  • Monaco editor with SQL syntax highlighting
  • Schema browser
  • Query execution with timing
  • Result display and export

Using the Editor ​

Via Dashboard ​

  1. Navigate to SQL
  2. Write your query
  3. Click Execute or press Ctrl+Enter
  4. View results

The execute_sql tool ​

The agent's own execute_sql tool is narrower than the editor: read-only, one statement, and tenant-scoped. Only an allowlist of tables with an agent_id column can be named (contacts, conversations, chat_messages, calendar_tasks, schedules, transactions, workflows, agent_tasks, turn_traces, jev_decisions, data_sources, media, skills, token_usage, …), and every referenced table is shadowed by a CTE filtered to the agent, so a query cannot read another agent's rows however it is written. Platform tables (agents, tenants, keys, sessions) are not reachable from it; schema-qualified names and multiple statements are rejected.

Allowed Operations (dashboard editor) ​

OperationAllowed
SELECTYes
INSERTYes
UPDATEYes
DELETEYes
PRAGMAYes (read-only)
EXPLAINYes
CREATENo
DROPNo
ALTERNo

Schema Browser ​

View database structure:

  • Tables
  • Columns
  • Types
  • Indexes

Query Examples ​

List Workflows ​

sql
SELECT id, name, status, created_at
FROM workflows
WHERE agent_id = 'current-agent'
ORDER BY created_at DESC
LIMIT 10

Count Contacts ​

sql
SELECT COUNT(*) as total
FROM contacts
WHERE agent_id = 'current-agent'

Search Messages ​

sql
SELECT content, created_at
FROM chat_messages
WHERE content LIKE '%keyword%'
ORDER BY created_at DESC

Best Practices ​

1. Use Indexes ​

Query on indexed columns for performance.

2. Limit Results ​

Always use LIMIT for large tables:

sql
SELECT * FROM logs LIMIT 100

3. Select Needed Columns ​

sql
-- Good
SELECT name, email FROM contacts

-- Avoid
SELECT * FROM contacts

API Reference ​

See SQL API for complete endpoint documentation.