/ API Reference
GitHub

API Reference

Reference·All endpoints

All endpoints are prefixed with /v1/. Authentication uses the X-API-Key header. Interactive docs are available at http://localhost:8000/docs (Swagger UI) when running locally.

Authentication

request header
X-API-Key: crwl_your_api_key_here
ℹ️

Every endpoint requires a valid API key scoped to the operation. Use scope * for full access during development.

Agents

MethodPathDescriptionScope
GET/v1/agentsList agents. Query: status, tags, limit, cursoragents:read
POST/v1/agentsCreate agentagents:write
GET/v1/agents/{id}Get agent by IDagents:read
PATCH/v1/agents/{id}Update name, description, tags, configagents:write
DELETE/v1/agents/{id}Delete agent and all dataagents:write
GET/v1/agents/{id}/statusGet cached status (Redis, 60s TTL)agents:read
PATCH/v1/agents/{id}/statusUpdate status and optional session_idagents:write
GET/v1/agents/{id}/status/historyStatus transition history. Query: limit (default 20)agents:read
POST/v1/agents/{id}/tagsAdd tags ({"tags": ["prod"]})agents:write
DELETE/v1/agents/{id}/tags/{tag}Remove a tagagents:write
GET/v1/agents/{id}/relationsList agent relationsagents:read
POST/v1/agents/{id}/relationsAdd relation: type (supervisor/collaborator/delegate), related_agent_idagents:write
DELETE/v1/agents/{id}/relations/{rel_id}Remove relationagents:write
GET/v1/agents/{id}/exportExport agent as streaming JSON (all memories, actions, episodes)agents:read
POST/v1/agents/importImport agent from exported JSON. Atomic with savepoint.agents:write

Example: create an agent

curl
curl -X POST http://localhost:8000/v1/agents \
  -H "X-API-Key: crwl_..." \
  -H "Content-Type: application/json" \
  -d '{"name": "sales-agent", "tags": ["production"], "config": {"model": "claude-opus-4-8"}}'

# Response
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "sales-agent",
  "status": "idle",
  "tags": ["production"],
  "config": {"model": "claude-opus-4-8"},
  "created_at": "2025-06-14T12:00:00Z"
}

Memory

MethodPathDescription
POST/v1/agents/{id}/memorySave a long-term memory. Body: content, importance (0–1), optional source, session_id
GET/v1/agents/{id}/memoryList memories. Query: limit, cursor, source
POST/v1/agents/{id}/memory/recallSemantic recall. Body: query, limit (default 10), optional min_similarity
DELETE/v1/agents/{id}/memory/{memory_id}Delete a specific memory
GET/v1/agents/{id}/memory/statsCount by source, average importance, oldest/newest
POST/v1/agents/{id}/memory/messagesAppend short-term message. Body: session_id, role, content
GET/v1/agents/{id}/memory/messagesGet short-term messages. Query: session_id
DELETE/v1/agents/{id}/memory/messagesClear short-term memory for a session

Example: semantic recall

curl
curl -X POST http://localhost:8000/v1/agents/$AGENT_ID/memory/recall \
  -H "X-API-Key: crwl_..." \
  -H "Content-Type: application/json" \
  -d '{"query": "user language preferences", "limit": 5}'

# Response
[
  {
    "id": "mem-uuid",
    "content": "User prefers Python over JavaScript",
    "similarity": 0.94,
    "importance": 0.9,
    "source": "extracted",
    "created_at": "2025-06-10T09:00:00Z"
  }
]

Actions

MethodPathDescription
POST/v1/agents/{id}/actionsLog an action. Body: tool_name, input_params, output_result, status, optional duration_ms, session_id
GET/v1/agents/{id}/actionsList actions. Query: tool, status, limit (default 50, max 500), cursor
GET/v1/agents/{id}/actions/{action_id}Get a single action
GET/v1/agents/{id}/actions/statsAggregated stats: counts, error rate, avg duration by tool

Sessions

MethodPathDescription
POST/v1/agents/{id}/sessionsCreate session. Body: optional episode_id, metadata
GET/v1/agents/{id}/sessionsList sessions for agent
GET/v1/sessions/{session_id}Get session details
POST/v1/sessions/{session_id}/closeClose session and extract memories from conversation using Claude

Episodes

MethodPathDescription
POST/v1/agents/{id}/episodesCreate episode. Body: title, optional description
GET/v1/agents/{id}/episodesList episodes
GET/v1/agents/{id}/episodes/{episode_id}Get episode with session list
POST/v1/agents/{id}/episodes/{episode_id}/completeMark episode complete
POST/v1/agents/{id}/episodes/{episode_id}/recallSemantic recall scoped to this episode's memories

Context (Blackboard)

MethodPathDescription
GET/v1/context/{namespace}List all keys in namespace
GET/v1/context/{namespace}/{key}Read value (current version)
PUT/v1/context/{namespace}/{key}Write value. Body: {"value": any}. Increments version.
DELETE/v1/context/{namespace}/{key}Delete key
GET/v1/context/{namespace}/{key}/historyVersion history for a key
POST/v1/context/{namespace}/{key}/rollbackRollback to a specific version. Body: {"version": 3}
GET/v1/context/{namespace}/subscribeSSE stream. Emits events when any key in the namespace changes.

Evaluations

MethodPathDescription
POST/v1/agents/{id}/evaluationsCreate evaluation. Body: prompt, response, optional expected, session_id, variant
GET/v1/agents/{id}/evaluationsList evaluations. Query: variant, limit, cursor
GET/v1/agents/{id}/evaluations/summaryA/B summary: avg score per variant, anomaly counts

Prompts

MethodPathDescription
POST/v1/agents/{id}/promptsCreate prompt version. Body: name, content, optional description
GET/v1/agents/{id}/promptsList all versions
GET/v1/agents/{id}/prompts/{version_id}Get specific version with diff from previous
POST/v1/agents/{id}/prompts/{version_id}/activateMark version as active

Webhooks

MethodPathDescription
POST/v1/webhooksRegister webhook. Body: url, events (array), optional secret
GET/v1/webhooksList webhooks
DELETE/v1/webhooks/{webhook_id}Delete webhook

Webhook events include: agent.status_changed, memory.extracted, action.error, anomaly.detected.

Auth / API Keys

MethodPathDescription
POST/v1/auth/keysCreate API key. Body: name, scopes, optional expires_at, rate_limit
GET/v1/auth/keysList API keys (values are never returned after creation)
DELETE/v1/auth/keys/{key_id}Revoke API key immediately

Other Endpoints

MethodPathDescription
GET/v1/auditRead-only audit log of all API operations. Query: agent_id, action, limit
GET/v1/usageResource usage counts for the current tenant
GET/metricsPrometheus metrics. Requires Authorization: Bearer METRICS_TOKEN from non-localhost
GET/healthHealth check: DB + Redis status

Available Scopes

ScopeAccess
*All operations (superkey)
agents:readRead agents and status
agents:writeCreate, update, delete agents
memory:readRead and recall memories
memory:writeSave and delete memories
actions:readRead action log
actions:writeLog new actions
context:readRead blackboard values
context:writeWrite blackboard values