Skip to main content

HTTP API

🌐

HTTP API

The foundational interface to Octopus. Every integration action — whether invoked from the CLI, an MCP tool call, or a direct application request — ultimately hits this HTTP layer. The CLI wraps it. MCP wraps it. Everything is a POST /v1/{service}/{method}.


Route Structure

Client
app · CLI · LLM
POST /v1/{service}/{method}
JSON body — method params as top-level keys
Service Registry
lookup service + method
Adapter
service-specific
External API
GitHub · Slack…
GET /health
Liveness check
GET /v1/meta
Full service schema
GET /v1/integrations
Connected integrations
POST /v1/documents/upload
Document ingestion
POST /v1/graphrag/query
Hybrid retrieval
GET /mcp/{domain}/tools
MCP tools list
POST /mcp/{domain}/execute
MCP tool execution
POST /v1/oauth/{service}/callback
OAuth callbacks

What & Why

The HTTP API is the single canonical interface to every Octopus capability. Rather than exposing a hand-crafted REST API, all routes for integration actions are generated at startup from @service_method decorators — the same decorators that produce CLI commands and MCP tool descriptions.

This means:

  • One source of truth. Add a decorator, get an HTTP route, a CLI command, and an MCP tool simultaneously.
  • Self-describing. GET /v1/meta returns the full schema of every registered service and method. Clients can introspect the API without reading documentation.
  • Uniform request shape. Every action is POST /v1/{service}/{method} with the method's parameters as top-level JSON keys. No different conventions per service.
  • Base URL: http://localhost:3007 in development, configurable via CONSTELLATION_API_URL env var.

Authentication Methods

Every request goes through APIKeyAuthMiddleware, which resolves one of three credential paths into a RequestContext passed to all downstream handlers:

JWT
Decode
RS256 / HS256
Validate
exp · iss · aud
Extract claims
tenant_id · sub · scopes
RequestContext
API Key
Lookup
hashed key → tenant record
Validate
active · not expired
Resolve tenant
tenant_id · permissions
RequestContext
Token Passthrough
Read header
Access-Token: <raw_token>
Forward as-is
no validation — adapter decides
Adapter receives
raw token in context
RequestContext

Header forms accepted:

Credential typeHeader(s)
JWT (OAuth token)Authorization: Bearer <token>
API KeyAuthorization: ApiKey <key> or X-API-Key: <key>
Token passthroughAccess-Token: <raw_token>

Output Format Negotiation

All /v1/{service}/{method} endpoints support three output formats. Format is selected by the Accept request header or the ?format= query parameter (query param takes precedence):

json
DEFAULT
Accept: application/json
?format=json
Structured JSON response envelope. Default when no format is specified.

Use for: Applications, integrations, any downstream processing.

text
CLI
Accept: text/plain
?format=text
Plain text suitable for direct terminal display. Tables and lists are rendered as readable ASCII.

Use for: CLI display, shell scripts, human-readable output.

agent
LLM
Accept: text/agent
?format=agent
Compact, label-prefixed plain text optimised for LLM context windows. Minimal tokens, maximum information density.

Use for: LLM tool calls, MCP execution, agentic pipelines.


/v1/meta — Schema Endpoint

GET /v1/meta returns a complete machine-readable description of every service registered at startup. No parameters required. Auth required (any valid credential).

Example response shape:

{
"services": {
"github": {
"description": "GitHub integration service",
"methods": {
"get_repository": {
"description": "Fetch repository details",
"parameters": {
"owner": {"type": "string", "required": true},
"repo": {"type": "string", "required": true}
},
"returns": "object"
}
}
}
}
}

Use /v1/meta to:

  • Enumerate all available services and their methods at runtime
  • Generate client SDKs or CLI completions automatically
  • Verify that a newly-deployed service registered correctly
  • Drive the MCP tool-description generation pipeline

Core Endpoints

MethodPathAuth requiredDescription
GET/healthNoLiveness check. Returns {"status": "ok"}. Used by ALB health checks.
GET/v1/metaYesFull schema of all registered services and methods. Self-describing API discovery.
GET/v1/integrationsYesList of connected integrations for the authenticated tenant.
POST/v1/{service}/{method}YesExecute any registered service method. Parameters as top-level JSON keys.
POST/v1/documents/uploadYesIngest a document: upload, chunk, embed, and index for retrieval.
POST/v1/graphrag/queryYesHybrid retrieval query combining vector search and knowledge graph traversal.
GET/mcp/{domain}/toolsYesList available MCP tools for the given domain.
POST/mcp/{domain}/executeYesExecute a single MCP tool with the provided arguments.
POST/v1/oauth/{service}/callbackNoOAuth 2.0 callback handler. Exchanges code for tokens and stores credentials.

Request Headers

HeaderRequiredDescription
Authorization: Bearer <token>One of three auth headersJWT from a connected identity provider (Google, Microsoft, etc.).
Authorization: ApiKey <key>One of three auth headersOctopus-issued API key. Alternative: X-API-Key: <key>.
Access-Token: <raw_token>One of three auth headersRaw token forwarded directly to the service adapter without validation.
X-API-Key: <key>No (alternative form)API key as a standalone header — same effect as Authorization: ApiKey.
Content-Type: application/jsonYes (POST requests)All POST bodies must be JSON.
AcceptNoControls output format: application/json (default), text/plain, or text/agent.
X-Tenant-IDNoExplicitly set tenant context. Usually inferred from the credential.

Response Envelope

All successful responses from /v1/{service}/{method} are wrapped in a standard envelope:

{
"status": "success",
"data": { },
"meta": {
"service": "github",
"method": "get_repository",
"cached": false,
"duration_ms": 45
}
}
FieldTypeDescription
status"success" | "error"Top-level outcome.
dataobjectThe method's return value. Shape is method-specific; see /v1/meta for schemas.
meta.servicestringThe service name that handled the request.
meta.methodstringThe method name that was invoked.
meta.cachedbooleantrue if the response was served from the Redis L2 cache.
meta.duration_msnumberWall-clock time in milliseconds from request receipt to response send.

Error envelope:

{
"status": "error",
"error": {
"code": "ADAPTER_ERROR",
"message": "Repository not found",
"service": "github",
"method": "get_repository"
}
}

Rate Limiting

Rate limits are enforced per tenant by RateLimitMiddleware. Limits and windows are configurable via environment variables. Every response includes the following headers:

HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the current window.
X-RateLimit-RemainingRequests remaining in the current window.
X-RateLimit-ResetUnix timestamp when the current window resets.

When the limit is exceeded, the server returns HTTP 429 Too Many Requests with a standard error envelope.