Skip to content

API Conventions

Base URL

https://your-domain.com/api/v1

Authentication

Public endpoints require no authentication:

  • GET /content/* - Read content
  • POST /chat - Send chat messages
  • GET /health/* - Health checks

Admin endpoints require the X-Admin-Key header:

bash
curl -H "X-Admin-Key: your-api-key" \
  https://your-domain.com/api/v1/admin/content

Metrics endpoint and MCP over HTTP endpoint also require admin authentication:

bash
curl -H "X-Admin-Key: your-api-key" \
  https://your-domain.com/api/metrics

curl -X POST -H "X-Admin-Key: your-api-key" \
  -H "Content-Type: application/json" \
  https://your-domain.com/api/mcp

Common Headers

Request Headers

HeaderDescriptionRequired
X-Admin-KeyAdmin API keyFor admin endpoints, /api/metrics, and /api/mcp
mcp-session-idMCP session identifierFor /api/mcp after initialization
Content-Typeapplication/jsonFor POST/PUT requests
Idempotency-KeyUnique request IDRecommended for mutations
If-None-MatchETag for cachingOptional for GET requests

Response Headers

HeaderDescription
X-Request-IdUnique request identifier
ETagEntity tag for caching
Cache-ControlCaching directives
Retry-AfterSeconds to wait (when rate limited)

HTTP Status Codes

CodeDescription
200Success
201Created
304Not Modified (ETag match)
400Validation Error
401Unauthorized
404Not Found
409Conflict (e.g., duplicate slug)
413Payload Too Large (body exceeds 100kb)
429Rate Limited
500Internal Server Error
502Bad Gateway (LLM unavailable)
504Request Timeout

Rate Limiting

Token bucket rate limiting is applied per IP:

  • Chat endpoint: 5 tokens capacity (default), refills at 0.333 tokens/second (~1 per 3 seconds). Configurable via RATE_LIMIT_CAPACITY and RATE_LIMIT_REFILL_RATE env vars.
  • Content endpoints: 60 tokens capacity (default), refills at 10 tokens/second. Configurable via CONTENT_RATE_LIMIT_CAPACITY and CONTENT_RATE_LIMIT_REFILL_RATE env vars.

When rate limited:

http
HTTP/1.1 429 Too Many Requests
Retry-After: 30

Pagination

List endpoints support pagination:

GET /api/v1/admin/content?limit=10&offset=20
ParameterDefaultMax
limit50100
offset0-

Filtering

Content can be filtered by type:

GET /api/v1/content?type=project

Caching

Content responses include ETag headers for efficient caching:

bash
# First request
curl -i https://api.example.com/api/v1/content/bundle
# Returns: ETag: "abc123"

# Subsequent request
curl -H "If-None-Match: abc123" \
  https://api.example.com/api/v1/content/bundle
# Returns: 304 Not Modified (if unchanged)

See Also

Released under the MIT License.