Reference

REST API Reference

The Open Astra gateway exposes a REST API for managing agents, sessions, memory, workspaces, and more. All endpoints require a JWT bearer token except where noted.

Correlation IDs

Every response includes an X-Request-ID header. The gateway reads an incoming X-Request-ID if present, or generates a UUID if none is provided. The same ID is attached to every structured log entry for that request, making it easy to trace a request end-to-end across logs. Attach this header when calling the API from your own code to correlate client-side and server-side logs.

Authentication

Most endpoints require a JWT bearer token obtained via /auth/login. Admin and diagnostic endpoints use an API key sent via the x-api-key header.

bash
# Get a JWT token
curl -X POST http://localhost:3000/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "..."}'

# Use the token for all authenticated requests
curl -H "Authorization: Bearer ${JWT_TOKEN}" http://localhost:3000/agents

Auth

MethodPathAuthDescription
POST/auth/registerNoneCreate a new user account
POST/auth/loginNoneAuthenticate and receive access + refresh tokens
POST/auth/refreshNoneRotate refresh token, issue new token pair
POST/auth/logoutJWTRevoke all refresh tokens for the user

Chat

All chat endpoints return 404 if the agentId does not exist, and 403 if the agent exists but is not available to the requesting workspace (see Agent Grants).

MethodPathDescription
POST/agent/chatSend a message, receive a complete response (idempotency supported)
POST/agent/chat/streamSend a message, receive a Server-Sent Events stream
POST/agent/resetManually reset the current user session
GET/agent/presenceGet active agent states
GET/agent/healthAgent health check

Agents

MethodPathDescription
POST/agentsCreate a new agent config
GET/agentsList all agents in the workspace
GET/agents/:idGet agent details
PUT/agents/:idUpdate agent config
DELETE/agents/:idDelete an agent
GET/agents/:id/capabilitiesGet resolved tool set, active skills, spawn config, and model config for an agent

Sessions

MethodPathDescription
GET/sessionsList sessions (supports pagination and status filter)
GET/sessions/:idGet session details and message history
GET/sessions/search/messagesFull-text search across all session messages
POST/sessions/:id/handoffTransfer an active session to a different agent; inserts a system handoff marker and switches all future turns to the target agent

Memory

MethodPathDescription
GET/memory/searchVector search across all memory tiers
GET/memory/profileGet the current user profile (Tier 3)
PUT/memory/profileUpdate user profile fields
GET/memory/dailyFetch recent daily memory entries
GET/memory/daily/:dateGet a specific day's memory
DELETE/memory/daily/:date/:entryIndexDelete a daily memory entry
POST/memory/notesAdd a strategic note
DELETE/memory/notes/:indexRemove a note by index

Workspaces

MethodPathDescription
POST/workspacesCreate a new workspace
GET/workspacesList workspaces the user has access to
GET/workspaces/:idGet workspace details (membership check)
PUT/workspaces/:id/settingsUpdate workspace settings (owner/admin only)
POST/workspaces/:id/membersAdd a member to the workspace
DELETE/workspaces/:id/members/:uidRemove a member from the workspace
GET/workspaces/:id/statsUsage dashboard: session counts, token/cost totals, top 5 agents, top 5 tools, active users. Accepts ?days= window (default 30, max 365)
PUT/workspaces/:id/restrictionsSet allowed providers and models for the workspace (owner/admin only). Pass null to remove restrictions
POST/workspaces/:id/grantsGrant another workspace access to one of this workspace's agents (owner/admin only)
DELETE/workspaces/:id/grantsRevoke a cross-workspace agent grant (owner/admin only)

Webhooks

MethodPathDescription
POST/webhooksCreate a webhook
GET/webhooksList all webhooks (secrets stripped)
GET/webhooks/:idGet webhook details
PUT/webhooks/:idUpdate a webhook
DELETE/webhooks/:idDelete a webhook
GET/webhooks/:id/deliveriesView delivery history
POST/webhooks/:id/testSend a test dispatch

Heartbeat

Heartbeat configs let agents monitor external sources (RSS, HTTP) on a schedule.

MethodPathDescription
GET/heartbeatList heartbeat configs
POST/heartbeatCreate a heartbeat config (rss or http)
GET/heartbeat/:id/runsPaginated run history
PATCH/heartbeat/:idEnable or disable a config
DELETE/heartbeat/:idDelete a heartbeat config

Skills

MethodPathAuthDescription
GET/skillsNoneList all skills with tool counts
GET/skills/:idNoneGet skill detail and prompt context
GET/skills/cache/statsNoneCache statistics
POST/skills/cache/clearNoneClear skill cache (optional ?tool=)

Cost Dashboard

MethodPathDescription
GET/costsWorkspace cost summary
GET/costs/breakdownDetailed cost breakdown with date range filter

Autonomous Execution

Execute agent tasks programmatically. Requires API key authentication via x-api-key header.

MethodPathDescription
POST/autonomous/runExecute a single agent task
POST/autonomous/batchExecute an agent task across multiple users

Onboarding

MethodPathDescription
POST/onboarding/setupCreate a workspace and agents in one call

Admin

Admin endpoints require API key authentication via x-api-key header.

MethodPathDescription
GET/admin/healthServer health (memory, uptime, sessions)
GET/admin/agentsList all agent configs across workspaces
GET/admin/usage/:uidToken usage for a specific user
GET/admin/sessions/:uidActive sessions for a user
GET/admin/audit/:uidAudit log (last 50 entries)

Diagnostics

Diagnostics endpoints require API key authentication via x-api-key header.

MethodPathDescription
GET/diagnosticsFull diagnostic run (12 checks across 6 categories)
GET/diagnostics/quickQuick connectivity checks only
GET/diagnostics/historyLast 10 diagnostic runs

System

MethodPathAuthDescription
GET/healthNoneDeep health check (Typesense, Postgres, WebSocket)
GET/readinessNoneKubernetes readiness probe
GET/metricsNoneOperational metrics (sessions, messages, billing)

WebSocket API

Connect to ws://localhost:3000/ws with a JWT bearer token. Rate limit: 30 requests per 60 seconds per user. Max 1 active agent request per socket.

javascript
const ws = new WebSocket("ws://localhost:3000/ws", {
  headers: { Authorization: "Bearer " + token }
})

// Send a message
ws.send(JSON.stringify({
  type: "message",
  agentId: "research-agent",
  message: "Summarize the latest findings",
  surface: "api"
}))

// Receive streaming chunks
ws.onmessage = (event) => {
  const frame = JSON.parse(event.data)
  // frame.type: session_resolved | stream_chunk | tool_call
  //             | tool_result | stream_done | error | pong
}

Inbound frames

TypeDescription
messageSend a message to an agent (agentId, message, surface)
pingKeepalive ping

Outbound frames

TypeDescription
session_resolvedSession ID assigned after first message
stream_chunkToken delta during streaming
tool_callTool invocation start
tool_resultTool execution result
stream_doneCompletion with full content and token usage
errorError frame
pongKeepalive response