API Reference
All endpoints require an X-API-Key header unless noted otherwise.
Context Layer
/api/contextStore a context object. Embeddings are auto-generated if OPENAI_API_KEY is configured.
{
"taskId": "task_001", // required
"entityId": "customer_123", // required
"agentId": "chatbot", // required
"input": "User question", // required
"output": "Agent response", // required
"embedding": [0.1, ...], // optional, 1536-dim
"metadata": { "key": "value" } // optional
}{ "id": "uuid", "taskId": "...", "entityId": "...", ... } // 201 Created/api/context/:idRetrieve a specific context object by ID.
{ "id": "uuid", "taskId": "...", "entityId": "...", ... } // 200 OK
{ "error": "Context not found" } // 404/api/context/searchSearch context objects by text query (semantic), raw embedding, or filters.
query // text query (auto-embedded for semantic search)
embedding // raw 1536-dim JSON array (alternative to query)
entityId // filter by entity
agentId // filter by agent
limit // max results (1-100, default 10)[{ "id": "...", "similarity": 0.87, ... }] // 200 OK/api/context/injectGet formatted context block ready for prompt injection.
query // required, text query
entityId // filter by entity
agentId // filter by agent
limit // max results (default 5)
minSimilarity // threshold (default 0.3){
"context": "--- Prior Context ---\n[Context 1 from chatbot (relevance: 87%)]\n...",
"hasContext": true
}Coordination Layer
/api/tasks/claimClaim a task for an entity. Returns 409 if another agent already has an active task for this entity.
{
"entityId": "customer_123", // required
"agentId": "chatbot", // required
"input": "Handle request", // required
"metadata": {} // optional
}{ "id": "uuid", "status": "claimed", ... } // 201 Created
{ "error": "Task conflict", "activeTask": { ... } } // 409 Conflict/api/tasks/activeList all active (claimed or in_progress) tasks.
entityId // optional filter[{ "id": "...", "status": "claimed", "agentId": "...", ... }]/api/tasks/:id/completeMark a task as completed with output.
{
"output": "Task result", // required
"metadata": {} // optional, merged with existing
}{ "id": "...", "status": "completed", "completedAt": "...", ... }/api/tasks/:id/handoffHand off a task to another agent. Original task is marked as handed_off and a new task is created for the target agent.
{
"targetAgentId": "escalation-handler", // required
"context": "Handoff context...", // required
"metadata": {} // optional
}{
"handedOff": { "id": "...", "status": "handed_off", ... },
"newTask": { "id": "...", "status": "claimed", "agentId": "escalation-handler", ... }
} // 201 CreatedLearning Layer
/api/workflowsLog a complete workflow trace. Embeddings are auto-generated from steps.
{
"entityId": "customer_123",
"steps": [
{
"agentId": "chatbot",
"action": "process_message",
"input": "Customer complaint",
"output": "Identified issue",
"timestamp": "2025-04-05T10:00:00Z"
}
],
"outcome": "success", // "success" | "failure" | "partial"
"duration": 900, // optional, milliseconds
"metadata": {} // optional
}{ "id": "uuid", "entityId": "...", "outcome": "success", ... } // 201 Created/api/workflows/:idRetrieve a specific workflow trace.
{ "id": "uuid", "steps": [...], "outcome": "success", ... }/api/workflows/similarFind similar past workflows using semantic search.
query // required, text query
entityId // optional filter
outcome // optional filter ("success" | "failure" | "partial")
limit // max results (1-50, default 5)[{ "id": "...", "similarity": 0.82, "outcome": "success", "steps": [...], ... }]Authentication
/api/auth/signupNo auth requiredCreate a new organization and get your first API key. The key is only shown once.
{
"name": "My Company", // required
"slug": "my-company" // required, lowercase alphanumeric + hyphens
}{
"organization": { "id": "...", "name": "My Company", "slug": "my-company" },
"apiKey": { "id": "...", "key": "ck_live_...", "prefix": "ck_live_abc1", "label": "default" }
} // 201 Created/api/auth/keysCreate an additional API key for your organization.
{ "label": "production" } // optional, default "default"{ "id": "...", "key": "ck_live_...", "prefix": "...", "label": "production" } // 201/api/auth/keysList all API keys for your organization (prefix only, not the full key).
[{ "id": "...", "prefix": "ck_live_abc1", "label": "default", "lastUsedAt": "...", "createdAt": "..." }]