Skip to main content

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
Configure your environment
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 StatusDescription
400Invalid request
401Missing or invalid token
403Insufficient permissions
404Resource not found
409Resource already exists
422Request validation failed
429Rate limit exceeded
500Internal server error
502An upstream service is unavailable
503Database 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.

Cookies and privacy

With your permission, we use cookies to measure visits and understand navigation to improve the site.

Learn more

Google Analytics measures visits and useful clicks. Microsoft Clarity provides masked interaction replays. No advertising use. Your choice is saved for six months. You can change or withdraw it at any time using the β€œCookies” button.

Read the audience measurement details