Skip to main content
HQ exposes two API surfaces: HTTP endpoints served by the Next.js UI, and Supabase RPCs you call directly against your Supabase project. Most day-to-day interaction happens through the dashboard, but both surfaces are available for scripting, integrations, and custom tooling.

Authentication

All requests require authentication. The method depends on which surface you’re calling.
The service-role key bypasses all RLS policies. Never expose it to browsers or client-side code. Use it only in server-side scripts and gateway daemons.

UI HTTP Endpoints

These are served by the Next.js app at your HQ URL (default http://localhost:3000).

Health and configuration

endpoint
Returns server health status. No authentication required.
endpoint
Returns the active workspace’s public-safe configuration. No authentication required.

Workspaces

All workspace endpoints require an authenticated session. POST /api/workspaces body:

Agent operations

POST /api/agents/[slug]/skills body:
For updates, include action: "update" and knowledge_item_id of the existing skill. GET /api/agents/[slug]/browser/screenshot query params:
  • quality — JPEG quality, 1–100 (default: 50)
  • maxWidth — Max pixel width (default: 1280)

Data sources

Embedding

endpoint
Generate an embedding vector for a text input. Proxies to the embedder service.

Supabase RPCs

Call these directly against your Supabase project using the Supabase client or any Postgres client. All RPCs respect RLS unless marked SECURITY DEFINER. The primary way to query the knowledge base programmatically.

search_knowledge_items

Vector similarity search across knowledge items.
Returns: id, title, kind, content, tags, folder_id, scope, updated_at, meta, source_connection_id, source_external_id, similarity.

search_knowledge_items_text

Full-text search (no embedding needed).

search_knowledge_chunks

Vector similarity search at the chunk level — useful for long documents where you want the most relevant passage.
Returns: knowledge_item_id, kind, title, tags, chunk_id, chunk_index, content, char_start, char_end, page_number, section_path, meta, similarity.

search_knowledge_chunks_text

Full-text search at the chunk level.

Command queue

Used by the runner daemon. You can also use these to script agent operations.

lease_command

Atomically lease the next pending command for a gateway.
Returns the leased agent_commands row, or empty if no work is pending.

start_command / complete_command / fail_command

Transition a command through its lifecycle.

Agent inbox

Used by the dispatcher daemon. These manage the work queue that wakes agents.

lease_inbox_item

Lease the next pending inbox item for an agent.

complete_inbox_item / fail_inbox_item

Failed items retry up to max_attempts (default 3), then move to dead_letter.

Routines

routine_next_occurrence

Compute the next fire time for a routine schedule.

spawn_routine_schedule_items

Called by pg_cron every minute. Creates inbox items for routines that are due. You generally don’t call this manually.

Agent hierarchy

agent_reports_chain

Walk the reporting chain for an agent.

Gateway registration

consume_gateway_token

Atomic token exchange during gateway registration. SECURITY DEFINER — bypasses RLS.

Task management

get_task_relations

Get all relations for a task (blockers, children, related tasks).

get_agent_daily_usage

Get an agent’s LLM usage for a date range.

Embedding pipeline

These are used internally by the embedder daemon.

Key Table Schemas

These are the tables you’ll query most often when building integrations. Full schema is in Database schema; migration source is in db/migrations/.

agents

tasks

knowledge_items

agent_commands

routines


Enum Reference

Enums used across the schema. Useful when filtering queries or building integrations.

Common Query Patterns

List all agents on a gateway

Get open tasks for an agent

Create a command (trigger an agent action)

The runner daemon will pick this up, execute it, and update status, stdout, and exit_code.

Search knowledge by text

Get an agent’s usage this month