Server HTTP API

This page describes app/v2/server, not the legacy server. Open the running server’s /docs or /openapi.json for request schemas, response models, and status codes.

Authentication

POST /api/auth/login accepts JSON username and password. It returns data.access_token and sets the sage_server_v2 cookie. Protected routes accept the authenticated identity through the server’s dependency layer. Admin routes require an administrator.

A2A and API keys

/api/keys manages Agent-bound machine credentials; keep the returned secret securely. Inbound /a2a/v1 and the Agent Card routes require the a2a extra (included in server) and a Bearer API Key, not a user JWT. Cards and task reads require a2a:read; sending and cancellation require a2a:invoke. Cards are authenticated because one origin serves multiple users. Manage outbound peers through /api/a2a-agents; outbound calls do not require the inbound SDK extra.

Chat and replay

POST /api/agent accepts AG-UI RunAgentInput and returns text/event-stream. Specify the Agent for a new conversation through forwardedProps.agentId; the first Run binds the Agent to the thread. Send Last-Event-ID when reconnecting to an accepted Run. Replay comes from canonical Session events; it is not stored in Redis.

session_id is the canonical Session identity: supplied IDs are preserved exactly; omitted IDs are generated by Sage. threadId is a compatibility alias and must equal session_id when both are provided. SSE lifecycle frames and result responses return the final session_id. Reuse it for follow-up requests. Ownership binds the tenant, Agent and Session; a global ID claimed by a different owner is rejected. Existing hashed Sessions remain accessible through the legacy mapping and return their persisted ID.

{
  "session_id": "example-thread",
  "threadId": "example-thread",
  "runId": "example-run",
  "state": {},
  "messages": [{"id": "message-1", "role": "user", "content": "Hello"}],
  "tools": [],
  "context": [],
  "forwardedProps": {"agentId": "your-agent-id"}
}

Replace IDs appropriately. A new logical request needs a new Run ID; reconnection must not create another logical task.

The agent list uses GET /api/agents/summary for the current user. Admins use GET /api/admin/agents to retrieve all owners in one request. Summaries contain id, name, description, model_id, model_name, tool_count, and skill_count; admin summaries also contain user_id and username. Fetch the agent detail endpoint for full configuration.

External runs and workspaces

External routes require a target-bound Authorization: Bearer <API Key> and a SAGE-TENANT-ID header. Reads require a2a:read, writes/execution require a2a:invoke, and interaction replies require a2a:approve. The server verifies the key binding, ownership, and grants; tenant, Session, and Run IDs are not credentials.

For external runs backed by a legacy hashed Session, AG-UI lifecycle frames and the exact-run result echo the requested ID in threadId. The session_id field carries the persisted Session ID.

PUT /api/agents/{agent_id}/workspace/files imports {directory, files} with base64 file contents. It creates missing files only, accepts identical content again, and returns 409 on conflicts. Limits are 256 files, 4 MiB per file, and 16 MiB total. DELETE on the same route checks paths and workspace idleness.

PUT /api/agents/{agent_id}/workspace/file?path=projects/site/uploads/clip.mp4 imports one nonempty raw binary request body, up to 64 MiB. Identical retries succeed; different existing content returns 409, invalid paths or empty bodies return 422, and oversized bodies return 413. Paths are relative to the tenant and Agent workspace; symbolic links are not followed.

GET /api/agents/{agent_id}/workspace/file?path=IDENTITY.md reads one regular file from the Claw workspace identified by the calling backend’s SAGE-TENANT-ID and the Agent ID. It requires a Bearer API key bound to that Agent with a2a:read. Success returns the original bytes with Cache-Control: private, no-store. Markdown uses text/plain; charset=utf-8. Missing or invalid credentials return 401, Agent or scope mismatch returns 403, missing files return 404, and directories, path escapes, and symlinks return 422.

The Agent API key can select any tenant workspace for its bound Agent. The calling backend must keep the key server-side and set SAGE-TENANT-ID from its authenticated and authorized user context. Discard any client-supplied tenant header. Duplicate tenant headers return 422.

GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/files?exclude=uploads optionally excludes one top-level entry from the Run workspace archive. Nested entries with the same name remain included. The remaining archive is subject to the existing 32 MiB and 512-entry limits.

GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/files/version?exclude=uploads returns {code:0,data:{version,files,bytes}} under the same Agent API key and tenant authorization as downloads. version is lowercase SHA-256 over sorted relative file paths encoded as UTF-8, each followed by NUL and the raw 32-byte SHA-256 of its contents. Regular file bytes define identity, not modification times; empty directories do not affect it. The optional single root exclusion, symlink handling, 32 MiB and 512-entry limits match downloads. This operation hashes in a worker without creating a ZIP; Cube computes inside its bound volume and returns metadata only. The exact latest Run by persisted admission revision (not wall-clock time) is checked before and after hashing; an older Run returns409, concurrent writes503, quota overflow413, missing files404, and unsupported storage501. There is no ZIP fallback. Clients must hash downloads with the same recipe and reject a version mismatch before caching a derived snapshot.

POST /api/agents/{agent_id}/runs?workspace_path=... accepts AG-UI input and optional runtimeContext for this Run without modifying shared configuration. Reads, replies, cancellation, and downloads identify the exact thread_id and run_id and check ownership; replies also require the expected interaction ID and revision.

GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/recover subscribes to an existing Run using the Agent key with a2a:read and the original tenant. The text/event-stream response sends up to 100 recent tool events followed by the current Run state, then follows new events. Each JSON payload contains agentId, threadId, runId, and state. Tool events also include toolCallId and toolName. Reconnect with the last SSE id from this endpoint as Last-Event-ID to receive later events. Replay skips suspensions superseded by a resume. The stream sends the stop state and closes on completed, failed, cancelled, or suspended (waiting to resume). The subscription reads recorded events and leaves execution to the existing Run.

File downloads snapshot the Run-bound working directory, limited to 32 MiB and 512 entries. A directory superseded by a newer Run in the same Session returns 409; changes during packaging may return 503. Callers validate artifacts and Run identity. Sage does not interpret downstream business manifests or build customer projects.

GET /api/agents/{agent_id}/sessions/{session_id}/missing-history-images returns the unique missing media IDs for legacy WishSeen user images in an authorized Session. It scans up to the initial Session sequence head. Only numeric tenants and wishseen_w_<32 lowercase hex digits> sessions are recognized. For matching workspace_path=projects/w_<id> Runs, existing feedback files under user-uploads/feedback replace matching signed image URLs in the final model request; missing files become a text placeholder. It never downloads signed URLs, follows symlinks, or rewrites canonical history or summary checkpoints.

Guidance and Skills sync

The ZIP-upload mode of PUT /api/agents/{agent_id}/guidance uses multipart prompt and files, accepts 1–32 complete Skill ZIPs, and validates/reports each item. This upload branch does not require a user identity and must be exposed only to trusted callers; do not confuse it with Bearer Key-protected external Run routes.

sync_bound=true synchronizes existing bindings, requires the authenticated configuration owner, and cannot include prompt or ZIP uploads. Sync preserves models, tools, and execution policy; consult the HTTP schema and host implementation for configuration/resource activation behavior.

Machine credential checks · Run and workspace routes · Sync routes

Route inventory

The inventory below follows the registered router source. Jaeger routes depend on host configuration; inbound A2A routes depend on the SDK extra. Use OpenAPI for full schemas rather than treating this list as a client SDK.

Method Path Router
GET /.well-known/agent-card.json a2a
POST /a2a/v1 a2a
GET /a2a/v1/card a2a
GET /api/a2a-agents a2a_agents
POST /api/a2a-agents a2a_agents
DELETE /api/a2a-agents/{name} a2a_agents
PUT /api/a2a-agents/{name} a2a_agents
POST /api/a2a-agents/{name}/refresh a2a_agents
GET /api/admin/a2a-agents admin
GET /api/admin/agents admin
GET /api/admin/mcp admin
GET /api/admin/models admin
GET /api/admin/runtime/concurrency admin
PUT /api/admin/runtime/concurrency admin
GET /api/admin/skills admin
GET /api/admin/threads admin
GET /api/admin/threads/{thread_id} admin
GET /api/admin/threads/{thread_id}/events admin
GET /api/admin/users admin
GET /api/agents agents
POST /api/agents agents
GET /api/agents/editor-resources agents
GET /api/agents/summary agents
DELETE /api/agents/{agent_id} agents
GET /api/agents/{agent_id} agents
PUT /api/agents/{agent_id} agents
PUT /api/agents/{agent_id}/guidance agents
GET /api/agents/{agent_id}/skills agents
PUT /api/agents/{agent_id}/skills agents
PUT /api/agents/{agent_id}/skills/{skill_id}/version agents
GET /api/plugins agents
GET /api/plugins/server agents
PUT /api/plugins/server agents
GET /api/tools agents
GET /api/tools/options agents
GET /api/keys api_keys
POST /api/keys api_keys
DELETE /api/keys/{key_id} api_keys
GET /api/auth/execution-policy auth
PUT /api/auth/execution-policy auth
POST /api/auth/login auth
POST /api/auth/logout auth
POST /api/auth/register auth
GET /api/auth/session auth
POST /api/agent conversations
POST /api/agent-package conversations
POST /api/agents/{agent_id}/runs conversations
GET /api/agents/{agent_id}/runs/{thread_id}/{run_id} conversations
POST /api/agents/{agent_id}/runs/{thread_id}/{run_id}/cancel conversations
GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/files conversations
GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/files/version conversations
GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/metrics conversations
GET /api/agents/{agent_id}/runs/{thread_id}/{run_id}/recover conversations
POST /api/agents/{agent_id}/runs/{thread_id}/{run_id}/reply conversations
DELETE /api/agents/{agent_id}/sessions/{session_id} conversations
GET /api/agents/{agent_id}/sessions/{session_id}/missing-history-images conversations
DELETE /api/agents/{agent_id}/tenant-data conversations
GET /api/agents/{agent_id}/workspace/file conversations
PUT /api/agents/{agent_id}/workspace/file conversations
DELETE /api/agents/{agent_id}/workspace/files conversations
GET /api/agents/{agent_id}/workspace/files conversations
PUT /api/agents/{agent_id}/workspace/files conversations
POST /api/agents/{agent_id}/workspace/files/stat conversations
GET /api/agents/{agent_id}/workspace/user-preferences conversations
PUT /api/agents/{agent_id}/workspace/user-preferences conversations
GET /api/approvals conversations
POST /api/approvals/{run_id}/decisions conversations
GET /api/threads conversations
DELETE /api/threads/{thread_id} conversations
GET /api/threads/{thread_id} conversations
POST /api/threads/{thread_id}/cancel conversations
GET /api/threads/{thread_id}/download conversations
GET /api/threads/{thread_id}/events conversations
GET /api/threads/{thread_id}/package conversations
GET /api/threads/{thread_id}/result conversations
POST /api/threads/{thread_id}/resume conversations
GET /api/threads/{thread_id}/runs/{run_id}/timing conversations
POST /api/threads/{thread_id}/steer conversations
GET /api/workspace/download files
DELETE /api/workspace/files files
GET /api/workspace/files files
GET /active health
GET /health health
GET /api/im/connections im
POST /api/im/connections im
DELETE /api/im/connections/{cid} im
GET /api/im/connections/{cid} im
PATCH /api/im/connections/{cid} im
GET /api/im/connections/{cid}/deliveries im
POST /api/im/connections/{cid}/pairings im
GET /api/im/connections/{cid}/status im
POST /api/im/connections/{cid}/test im
DELETE /api/im/deliveries/{delivery_id} im
POST /api/im/deliveries/{delivery_id}/retries im
GET /api/im/plugins im
GET /api/mcp mcp
POST /api/mcp mcp
DELETE /api/mcp/{name} mcp
PUT /api/mcp/{name} mcp
POST /api/mcp/{name}/refresh mcp
GET /api/models models
POST /api/models models
POST /api/models/probe models
DELETE /api/models/{model_id} models
GET /api/models/{model_id} models
GET /api/observability/console observability
GET /api/observability/jaeger observability
GET /api/observability/jaeger/auth observability
GET /api/observability/jaeger/login observability
GET/POST/PUT/PATCH/DELETE/OPTIONS/HEAD /api/observability/jaeger/{full_path:path} observability
GET /api/observability/performance observability
GET /api/observability/services observability
GET /api/observability/trace-spans observability
GET /api/observability/trace-spans/{span_id} observability
GET /api/observability/traces/summary observability
GET /api/observability/traces/{trace_id}/spans observability
GET /api/agent-packages packages
POST /api/agent-packages packages
GET /api/agent-packages/capacity packages
GET /api/agent-packages/resources packages
GET /api/agent-packages/runs packages
POST /api/agent-packages/runs packages
GET /api/agent-packages/runs/{operation} packages
POST /api/agent-packages/runs/{operation}/control packages
GET /api/agent-packages/runs/{operation}/events packages
GET /api/agent-packages/schema packages
GET /api/agent-packages/template packages
POST /api/agent-packages/validate packages
GET /api/agent-packages/{ref} packages
POST /api/agent-packages/{ref}/activate packages
POST /api/agent-packages/{ref}/fork packages
GET /api/agents/{agent_id}/rsi/runs rsi
POST /api/agents/{agent_id}/rsi/runs rsi
GET /api/agents/{agent_id}/rsi/runs/{run_id} rsi
POST /api/agents/{agent_id}/rsi/runs/{run_id}/cancel rsi
POST /api/agents/{agent_id}/rsi/runs/{run_id}/resume rsi
GET /api/agents/{agent_id}/rsi/runs/{run_id}/versions/{version_id} rsi
POST /api/agents/{agent_id}/rsi/runs/{run_id}/versions/{version_id}/apply rsi
POST /api/skill-import-previews skills
POST /api/skill-imports skills
GET /api/skills skills
POST /api/skills skills
POST /api/skills/upload skills
DELETE /api/skills/{skill_id} skills
GET /api/skills/{skill_id} skills
PUT /api/skills/{skill_id} skills
GET /api/skills/{skill_id}/diff skills
GET /api/skills/{skill_id}/files skills
GET /api/skills/{skill_id}/files/{path:path} skills
POST /api/skills/{skill_id}/rollback skills
GET /api/skills/{skill_id}/versions skills
GET /api/skills/{skill_id}/versions/{version_id} skills
PUT /api/workspace/skills/{name} skills

Host infrastructure also exposes GET /livez, GET /readyz, and GET /metrics outside OpenAPI. Readiness probes the host database and application state.

Success and error JSON carry request_id; the server also returns X-Request-ID. Streaming responses follow AG-UI event framing.

Router source · Server setup

Tool directory details

Each GET /api/tools entry includes description, input_schema, side_effect_level, and requires_approval alongside name, category, source, default, and approval_key. These fields project the currently discoverable ToolDefinition for read-only browsing; listing tools never invokes them. default identifies the initial tool set for new Agents. Tool approval declarations do not replace the Agent’s current grants or execution policy.


Sage documentation for the current repository layout. Source available under the MIT license.

This site uses Just the Docs, a documentation theme for Jekyll.