Control Plane API
REST API reference for STOA Control Plane.
OpenAPI Specificationβ
The complete OpenAPI 3.1 specification is available:
- JSON: openapi.json
- Swagger UI:
${STOA_API_URL}/docs - ReDoc:
${STOA_API_URL}/redoc
Import into your favorite API client (Postman, Insomnia, Bruno):
# Download spec
curl -o openapi.json https://raw.githubusercontent.com/stoa-platform/stoa/main/apis/control-plane-api/openapi.json
Base URLβ
${STOA_API_URL}/v1
export STOA_API_URL="https://api.gostoa.dev" # Replace with your domain
export STOA_AUTH_URL="https://auth.gostoa.dev" # Keycloak OIDC provider
Self-hosted? Replace gostoa.dev with your domain.
Authenticationβ
All API requests require authentication:
Authorization: Bearer <access_token>
Get access token from Keycloak:
curl -X POST ${STOA_AUTH_URL}/realms/stoa/protocol/openid-connect/token \
-d "client_id=control-plane-api" \
-d "client_secret=${STOA_CLIENT_SECRET}" \
-d "grant_type=client_credentials"
Tenantsβ
Create Tenantβ
POST /tenants
Content-Type: application/json
{
"name": "acme",
"display_name": "ACME Corp",
"description": "Payments team",
"owner_email": "owner@example.com"
}
name, display_name and owner_email are required. The tenant identifier is derived from name (lower-cased, spaces replaced by hyphens). Provisioning runs asynchronously: poll GET /tenants/{tenant_id}/provisioning-status. The response returns the supplied display_name as name.
Response:
{
"id": "acme",
"name": "ACME Corp",
"display_name": "ACME Corp",
"owner_email": "owner@example.com",
"status": "active",
"provisioning_status": "pending",
"created_at": "2025-01-09T10:00:00Z"
}
List Tenantsβ
GET /tenants
Returns a plain JSON array, without pagination. Platform admins see every tenant; other users only see their own tenant.
Get Tenantβ
GET /tenants/{tenant_id}
Update Tenantβ
PUT /tenants/{tenant_id}
Content-Type: application/json
{
"display_name": "ACME Corporation",
"description": "Payments and billing teams",
"max_apis": 20
}
All fields are optional (display_name, description, owner_email, max_apis, max_applications); omitted fields are left unchanged.
Delete Tenantβ
DELETE /tenants/{tenant_id}
APIsβ
Register APIβ
POST /tenants/{tenant_id}/apis
Content-Type: application/json
{
"name": "payment-api",
"display_name": "Payment API",
"description": "Payment processing API",
"backend_url": "https://payments.internal.example.com",
"version": "1.0.0",
"tags": ["payments"]
}
name, display_name and backend_url are required. version defaults to 1.0.0; openapi_spec optionally carries the OpenAPI document as a string. The API identifier is derived from name.
Response:
{
"id": "payment-api",
"tenant_id": "acme",
"name": "payment-api",
"display_name": "Payment API",
"version": "1.0.0",
"backend_url": "https://payments.internal.example.com",
"status": "draft",
"created_at": null
}
List APIsβ
GET /tenants/{tenant_id}/apis?page=1&page_size=20
Optional environment filter (dev, staging or prod). The response is a page envelope with items, total, page and page_size.
Get APIβ
GET /tenants/{tenant_id}/apis/{api_id}
Update APIβ
PUT /tenants/{tenant_id}/apis/{api_id}
Content-Type: application/json
{
"description": "Payment processing API (new backend)",
"backend_url": "https://payments-v2.internal.example.com"
}
Only the provided fields are updated (display_name, version, description, backend_url, openapi_spec, tags).
Delete APIβ
DELETE /tenants/{tenant_id}/apis/{api_id}
Subscriptionsβ
Subscriptions are a top-level resource under /subscriptions; they are not nested under the tenant.
Create Subscriptionβ
POST /subscriptions
Content-Type: application/json
{
"application_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"application_name": "Mobile App",
"api_id": "payment-api",
"api_name": "Payment API",
"api_version": "1.0.0",
"tenant_id": "acme",
"plan_id": "basic",
"plan_name": "Basic Plan"
}
Returns 201 Created. All fields except plan_id and plan_name are required; application_id is the UUID of an existing application. The subscription is returned as active when no plan_id is supplied, when the plan does not require approval, or when the caller holds one of the plan's auto-approve roles; otherwise it stays pending until a tenant admin approves it. Access is governed by the application's security profile: the default profile is a public OAuth2 client with PKCE, and API-key applications without an OAuth2 client are also accepted. Creating a subscription issues no new API key.
Response (abridged, plan requiring approval):
{
"id": "0f1e2d3c-4b5a-4c6d-8e9f-0a1b2c3d4e5f",
"application_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"api_id": "payment-api",
"tenant_id": "acme",
"status": "pending",
"created_at": "2025-01-09T10:30:00Z"
}
List Subscriptionsβ
GET /subscriptions/tenant/{tenant_id}?status=pending&page=1&page_size=20
Lists a tenant's subscriptions; available to members of that tenant and to platform admins. status and environment filters are optional; the response is paginated (items, total, page, page_size, total_pages). GET /subscriptions/my returns the calling user's own subscriptions; for tenant admins and platform admins it returns every subscription, not only their own.
Get Subscriptionβ
GET /subscriptions/{subscription_id}
Approve Subscriptionβ
POST /subscriptions/{subscription_id}/approve
Content-Type: application/json
{
"expires_at": "2025-12-31T23:59:59Z"
}
expires_at is optional. Requires the tenant admin or platform admin role.
Revoke Subscriptionβ
POST /subscriptions/{subscription_id}/revoke
Content-Type: application/json
{
"reason": "Violation of terms of service"
}
reason is required. A subscriber cancels their own subscription with DELETE /subscriptions/{subscription_id} (returns 204).
API Keysβ
List API Keysβ
GET /tenants/{tenant_id}/apikeys
Create API Keyβ
POST /tenants/{tenant_id}/apikeys
Content-Type: application/json
{
"subscription_id": "sub-12345",
"name": "Production Key",
"expires_at": "2026-01-09T00:00:00Z"
}
Rotate API Keyβ
POST /tenants/{tenant_id}/apikeys/{key_id}/rotate
Revoke API Keyβ
DELETE /tenants/{tenant_id}/apikeys/{key_id}
Metricsβ
Get Tenant Metricsβ
GET /tenants/{tenant_id}/metrics
?start_date=2025-01-01
&end_date=2025-01-31
&granularity=day
Response:
{
"metrics": [
{
"date": "2025-01-09",
"requests": 45231,
"errors": 23,
"p50_latency_ms": 87,
"p95_latency_ms": 234,
"p99_latency_ms": 456
}
]
}
Get API Metricsβ
GET /tenants/{tenant_id}/apis/{api_id}/metrics
Get Subscription Usageβ
GET /tenants/{tenant_id}/subscriptions/{subscription_id}/usage
Webhooksβ
Create Webhookβ
POST /tenants/{tenant_id}/webhooks
Content-Type: application/json
{
"url": "https://myapp.com/webhooks/stoa",
"events": [
"subscription.created",
"subscription.approved"
],
"secret": "whsec_abc123"
}
List Webhooksβ
GET /tenants/{tenant_id}/webhooks
Delete Webhookβ
DELETE /tenants/{tenant_id}/webhooks/{webhook_id}
Error Responsesβ
Every error response is a JSON object with a detail field:
{
"detail": "Conflict: a resource with this identifier already exists."
}
Request validation errors (422) use the same detail field, holding a list of field errors, each with loc, msg and type:
{
"detail": [
{
"loc": ["body", "name"],
"msg": "<validation message>",
"type": "<error type>"
}
]
}
Rate-limited requests (429) keep the detail field and add error, message, retry_after_seconds and documentation.
Status Codesβ
| HTTP Status | Description |
|---|---|
| 400 | Invalid request |
| 401 | Missing or invalid token |
| 403 | Insufficient permissions |
| 404 | Resource not found |
| 409 | Resource already exists |
| 422 | Request validation failed |
| 429 | Rate limit exceeded |
| 500 | Internal server error |
| 502 | An upstream service is unavailable |
| 503 | Database service unavailable |
Rate Limitsβ
When a rate limit is exceeded, the API returns 429 with the Retry-After and X-RateLimit-Limit headers, and the error body described in Error Responses.
π§ Coming Soon: WebSocket API and Bulk operations.