Gateway Admin API
Complete reference for the STOA Gateway (stoa-gateway) administrative surface mounted under /admin/* (stoa-gateway/src/handlers/admin/router.rs). These endpoints are used by the Control Plane and operators to manage UAC contracts, routes, policies, skills, federation, caches, and runtime diagnostics.
Authentication & Middleware Chainβ
Every /admin/* route passes through three middleware layers (outermost to innermost):
admin_audit_logβ Logs all administrative requests (including rate-limited429and unauthenticated401attempts)admin_rate_limitβ Throttles bearer-probing bursts before authenticationadmin_authβ ValidatesAuthorization: Bearer <token>
curl -H "Authorization: Bearer ${STOA_ADMIN_API_TOKEN}" \
"${STOA_GATEWAY_URL}/admin/health"
| Response | Meaning |
|---|---|
200 OK / 201 Created / 204 No Content | Authenticated, request processed |
401 Unauthorized | Missing/invalid STOA_ADMIN_API_TOKEN (constant-time comparison), or missing strong-auth administrative OIDC JWT when strong authentication is enabled (WWW-Authenticate: Bearer error="insufficient_user_authentication") |
429 Too Many Requests | Admin pre-auth rate limit exceeded |
503 Service Unavailable | Admin API disabled (STOA_ADMIN_API_TOKEN is unset or empty β fail-closed) |
Health & Route Reloadβ
GET /admin/healthβ
Returns gateway status and registry counts.
curl "${STOA_GATEWAY_URL}/admin/health" \
-H "Authorization: Bearer ${STOA_ADMIN_API_TOKEN}"
{
"status": "ok",
"version": "0.12.0",
"routes_count": 42,
"policies_count": 15
}
POST /admin/routes/reloadβ
Trigger a hot-reload of dynamic routes from the configured source.
UAC Contract Managementβ
Contract mutations (stoa-gateway/src/handlers/admin/contracts.rs) are transactional across three in-memory stores (contract_registry, route_registry, and tool_registry):
- Upsert (
POST /admin/contracts) runs bind-first: REST routes and MCP tools are bound before committing tocontract_registry(rolling back partial binds on error). - Delete (
DELETE /admin/contracts/:key) runs unbind-first: both binders must succeed before the contract record is removed.
POST /admin/contractsβ
Register or update a Universal API Contract (201 Created on insert, 200 OK on update). tenant_id is required, and "inboundAuth": "jwt" enforces Keycloak JWT validation on the generated REST route (matching quickstart/verify.sh and stoa-gateway/src/uac/schema.rs). perform_upsert and the REST/MCP binders (contracts.rs, rest.rs, mcp.rs) generate routes and tools unconditionally on upsert β status (such as "published" in the example payload below) is stored contract metadata rather than a conditional activation gate:
curl -X POST "${STOA_GATEWAY_URL}/admin/contracts" \
-H "Authorization: Bearer ${STOA_ADMIN_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "echo-service",
"version": "1.0.0",
"tenant_id": "acme",
"status": "published",
"classification": "H",
"inboundAuth": "jwt",
"endpoints": [
{
"path": "/ping",
"methods": ["GET"],
"backend_url": "http://backend:80",
"operation_id": "echoPing"
}
]
}'
{
"key": "acme:echo-service",
"status": "ok",
"routes_generated": 1,
"tools_generated": 1,
"llm_capabilities": 0
}
GET /admin/contractsβ
List all registered UAC contracts.
GET /admin/contracts/:keyβ
Fetch a single contract by its composite key ({tenant_id}:{name} by default, e.g., acme:echo-service, unless an explicit key was passed on upsert). Returns 404 if not found.
DELETE /admin/contracts/:keyβ
Unbind REST routes and MCP tools for :key and delete the contract (200 OK with JSON counters {"status": "deleted", "routes_removed": 1, "tools_removed": 1}, or 404 Not Found if missing).
API Route & Proxy Backend Managementβ
POST /admin/apisβ
Create or update a low-level API route (201 Created or 200 OK).
curl -X POST "${STOA_GATEWAY_URL}/admin/apis" \
-H "Authorization: Bearer ${STOA_ADMIN_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"id": "api-123",
"name": "payments",
"tenant_id": "acme",
"path_prefix": "/apis/acme/payments",
"backend_url": "https://api.example.com",
"methods": ["GET", "POST", "PUT"],
"spec_hash": "abc123def456",
"activated": true
}'
GET /admin/apisβ
List all registered API routes.
GET /admin/apis/:idβ
Get a single API route by ID (404 Not Found if missing).
DELETE /admin/apis/:idβ
Remove an API route (204 No Content or 404 Not Found).
GET /admin/api-proxy/backendsβ
List configured internal API proxy backends and their active status (protected by admin_auth).
Policy & Credential Managementβ
POST /admin/policiesβ
Create or update a gateway policy (201 Created or 200 OK).
curl -X POST "${STOA_GATEWAY_URL}/admin/policies" \
-H "Authorization: Bearer ${STOA_ADMIN_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"id": "policy-123",
"name": "rate-limit-gold",
"policy_type": "rate_limit",
"config": {
"limit": 1000,
"window_secs": 60
},
"priority": 1,
"api_id": "api-123"
}'
GET /admin/policiesβ
List all registered policies.
DELETE /admin/policies/:idβ
Remove a policy (204 No Content or 404 Not Found).
Backend & Consumer Credentials (BYOK)β
| Endpoint | Method | Description |
|---|---|---|
/admin/backend-credentials | GET, POST | List or upsert upstream BYOK credentials per route |
/admin/backend-credentials/:route_id | DELETE | Remove backend credential for :route_id |
/admin/consumer-credentials | GET, POST | List or upsert per-consumer credentials |
/admin/consumer-credentials/:route_id/:consumer_id | DELETE | Remove consumer credential |
Skills Managementβ
Manage hierarchical context-injection skills (global < tenant < tool < user specificity, matching the Skill CRD). Literal routes (/status, /resolve, /sync, /health) are registered ahead of parametric /skills/:id.
| Endpoint | Method | Description |
|---|---|---|
/admin/skills/status | GET | Skill resolver summary (enabled, cache_ttl_secs, skill_count) |
/admin/skills/resolve | GET | Preview resolved instructions (?tenant_id=<id> required; optional &tool_ref=<tool>&user_ref=<user>) |
/admin/skills/sync | POST | Atomically replace the in-memory skill registry from a posted JSON array of skill objects (does not pull from the Control Plane) |
/admin/skills | GET, POST | List skills or upsert a skill (201 on insert, 200 on update) |
/admin/skills/:id | GET, PUT, DELETE | Get, update, or delete a skill by ID (canonical delete path) |
/admin/skills?key=<key> | DELETE | Deprecated: query-based deletion returning Deprecation and Sunset headers; prefer DELETE /admin/skills/:id |
/admin/skills/health | GET | Aggregated health status across all skills |
/admin/skills/:id/health | GET | Health metrics for a single skill |
/admin/skills/:id/health/reset | POST | Reset error/health counters for :id |
MCP Federation Managementβ
Inspect and manage upstream MCP server federation and sub-account caches (stoa-gateway/src/handlers/admin/federation.rs).
GET /admin/federation/statusβ
{
"enabled": true,
"cache_size": 18,
"cache_ttl_secs": 300
}
GET /admin/federation/upstreamsβ
Lists configured upstream MCP servers (url, transport, has_auth, timeout_secs β credentials are never exposed).
GET /admin/federation/cacheβ
Returns federation cache hit/miss statistics.
DELETE /admin/federation/cache/:sub_account_idβ
Invalidates cached federation state for :sub_account_id and reports whether an active entry was purged (invalidated: true | false).
Prompt Cache & LLM Cost-Aware Routingβ
Prompt Cacheβ
| Endpoint | Method | Description |
|---|---|---|
/admin/prompt-cache/stats | GET | Hit/miss statistics and entry counts |
/admin/prompt-cache/patterns | GET | List cached prompt patterns |
/admin/prompt-cache/get/:key | GET | Inspect a cached prompt entry by key |
/admin/prompt-cache/load | POST | Preload prompt cache entries |
/admin/prompt-cache/invalidate | POST | Clear all entries in the prompt cache ({"status": "cleared"}, no pattern filter) |
LLM Routingβ
| Endpoint | Method | Description |
|---|---|---|
/admin/llm/status | GET | LLM router status and active configuration |
/admin/llm/providers | GET | Configured LLM providers and health |
/admin/llm/costs | GET | Aggregated LLM cost and token telemetry |
Circuit Breaker Managementβ
GET /admin/circuit-breaker/statsβ
Get the main Control Plane circuit breaker statistics (closed, open, half_open).
{
"name": "cp-api-breaker",
"state": "closed",
"success_count": 1234,
"failure_count": 5,
"consecutive_failures": 0,
"open_count": 2,
"rejected_count": 0
}
POST /admin/circuit-breaker/resetβ
Reset the main circuit breaker to closed.
GET /admin/circuit-breakersβ
List all per-upstream circuit breakers.
POST /admin/circuit-breakers/:name/resetβ
Reset a specific upstream circuit breaker (404 if unknown).
Cache Managementβ
GET /admin/cache/statsβ
{
"hits": 523,
"misses": 127,
"entry_count": 45,
"hit_rate": 0.804
}
POST /admin/cache/clearβ
Clear all cached entries immediately.
Session Managementβ
GET /admin/sessions/statsβ
Returns MCP session tracking statistics.
{
"active_sessions": 42,
"zombie_count": 2,
"tracked_sessions": 44
}
mTLS & Quota Managementβ
GET /admin/mtls/config & GET /admin/mtls/statsβ
Inspect current mTLS settings (trusted_proxies redacted) and client-certificate validation counters (total_requests, cert_validated, cert_missing, cert_invalid).
GET /admin/quotas, GET /admin/quotas/:consumer_id & POST /admin/quotas/:consumer_id/resetβ
Inspect or reset daily and monthly consumer quota counters.
Diagnostics, Error Snapshots, Tracing & A2A Registryβ
| Endpoint | Method | Description |
|---|---|---|
/admin/diagnostic | GET | Gateway uptime, circuit breaker states, and route statistics |
/admin/diagnostics/summary | GET | Aggregated diagnostic report summary |
/admin/diagnostics/:request_id | GET | Per-request diagnostic trace report |
/admin/snapshots | GET, DELETE | List or clear captured error snapshots |
/admin/snapshots/:request_id | GET | Retrieve a specific error snapshot |
/admin/tracing/status | GET | OpenTelemetry distributed tracing exporter status |
/admin/a2a/agents | GET, POST | List or register Agent-to-Agent (A2A) agents |
/admin/a2a/agents/:name | GET, DELETE | Inspect or unregister an A2A agent |
(Internal supervision endpoints under /admin/hegemon/* and experimental /admin/ebpf/* hooks are also mounted behind admin_auth for platform-internal telemetry.)
Unauthenticated Health Probesβ
Kubernetes liveness and readiness probes live outside /admin and require no token:
| Endpoint | Purpose |
|---|---|
GET /health / GET /health/live | Liveness probe β gateway process is alive |
GET /ready / GET /health/ready | Fail-closed readiness probe β verifies required policy/audience/audit-spool state (ADR-070) |
Relatedβ
- MCP Gateway API β MCP JSON-RPC and companion REST endpoints
- Control Plane API β Platform management API
- Quota Enforcement β Quota model and enforcement
- RBAC Permissions β Role and scope model