← contextcapsule.ai

API Documentation

Context Capsule v1 — Portable context for agent workflows

Authentication

Capsule creation requires a Bearer token. Get one via the signup endpoint. Keys use the ak_ prefix.

Authorization: Bearer ak_your_api_key

Fetch endpoints are public — no authentication required.

POST /v1/capsules

Create a context capsule. Auth required. Rate limit: 60/min per API key.

Request

curl -X POST https://www.contextcapsule.ai/v1/capsules \
  -H "Authorization: Bearer ak_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "summary": "Refactored auth module",
    "decisions": ["Chose RS256 over HS256"],
    "next_steps": ["Add refresh tokens"],
    "payload": {"files": ["auth.ts"]},
    "refs": {"workflow_id": "wf_123"},
    "expires_in": 3600
  }'

Response (201)

{
  "id": "cap_...",
  "short_url": "https://www.contextcapsule.ai/capsule/cap_...",
  "expires_at": "2025-01-01T12:00:00.000Z",
  "request_id": "req_..."
}

GET /v1/capsules/:id

Fetch a capsule by ID. Public. Rate limit: 120/min per IP.

curl https://www.contextcapsule.ai/v1/capsules/cap_abc123

Response (200)

{
  "id": "cap_abc123",
  "summary": "Refactored auth module",
  "decisions": ["Chose RS256 over HS256"],
  "next_steps": ["Add refresh tokens"],
  "payload": {"files": ["auth.ts"]},
  "refs": {"workflow_id": "wf_123"},
  "audience": null,
  "created_at": "2025-01-01T11:00:00.000Z",
  "expires_at": "2025-01-01T12:00:00.000Z"
}

Short URL also works: GET /capsule/:id

POST /v1/auth/signup

Get a free API key. Rate limit: 5/min per IP.

curl -X POST https://www.contextcapsule.ai/v1/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'

Response (201)

{
  "api_key": "ak_...",
  "message": "Store this key securely — it cannot be retrieved later."
}

POST /cron/cleanup

Hourly cleanup of expired capsules. Protected by a shared secret.

curl -X POST https://www.contextcapsule.ai/cron/cleanup \
  -H "Authorization: Bearer CRON_SECRET"

Response (200)

{"deleted": 42}

Capsule Schema

FieldTypeRequiredConstraints
summarystringyesmax 500 chars
decisionsstring[]no
next_stepsstring[]no
payloadobjectnomax 32KB JSON
refsobjectnosee below
expires_innumberno60–604800s, default 86400
idempotency_keystringnodeduplication key
audiencestringnoconsumer hint

Refs Object

FieldTypeDescription
workflow_idstringWorkflow ID
agent_idstringCreating agent
session_idstringCreating session
parent_capsule_idstringParent capsule (chaining)
receipt_idsstring[]ProofSlip receipt IDs

Errors

All errors return a JSON body with error, message, and request_id.

CodeHTTPDescription
validation_error400Request body failed validation
unauthorized401Missing or invalid credentials
capsule_not_found404Capsule not found or expired
idempotency_conflict409Same key, different body
email_exists409Email already registered
rate_limited429Too many requests
internal_error500Unexpected server error

MCP Server

Use Context Capsule from any MCP-compatible client:

npx -y @contextcapsule/mcp-server

Tools: create_capsule, fetch_capsule, signup

Discovery Endpoints

URLFormatDescription
/llms.txttextLLM-friendly summary
/llms-full.txttextFull API reference
/.well-known/openapi.jsonJSONOpenAPI 3.1 spec
/.well-known/mcp.jsonJSONMCP discovery
/.well-known/agent.jsonJSONAgent discovery
/robots.txttextRobots & discovery
/sitemap.xmlXMLSitemap

Context Capsule — contextcapsule.ai