API Overview
AI Admin Panel's REST API supports panel administration and automation. This guide describes the v2.12.8 interface. The Partner API is a separate service for commercial licensing and uses different tokens, routes, and schemas.
Base URL
https://panel.example.com/api/v1
Resource routes such as /services, /templates, and /api-keys use this base. The panel serves the frontend and API from the same process. Documentation routes and the WebSocket and MCP transports have their own paths below.
Authentication
Browser requests use the __Host-aap_session cookie after Keycloak sign-in; it is valid for the panel hostname only and is never sent to deployed services. Automation uses a panel API key in the Authorization header:
curl 'https://panel.example.com/api/v1/services?page=1&pageSize=20' \
-H "Authorization: Bearer ${PANEL_API_KEY}"
PANEL_API_KEY is a placeholder environment variable for your securely supplied key; never put a real key in documentation or source control. This services route requires the admin role. Customer portal routes use a separate /api/v1/portal surface; an admin resource URL is not a customer-scoped integration endpoint. See Authentication for key creation and the known OIDC token-storage limitation.
Swagger UI
Open /api/docs on your panel to browse the bundled API description. Interactive requests can change real resources; use a test instance when trying mutations.
API specification
| URL | Format |
|---|---|
/api/openapi.yaml | OpenAPI 3.0 |
/api/swagger.yaml | Swagger 2.0 |
curl -O https://panel.example.com/api/openapi.yaml
These are bundled build artifacts generated from handler annotations. They are useful for client generation, but annotations can differ from registered routes or response serializers. In particular, v2.12.8 contains both resource-relative paths and already-prefixed auth paths: check the final URL before sending a generated request. The routes and examples on these pages have been reconciled against the v2.12.8 router and handlers. No fixed path count is a coverage promise.
Response Format
Follow each endpoint's schema. Services return camelCase fields such as deploymentType and createdAt; Git creation and AI analysis also use some snake_case request fields. There is no global field-name conversion.
Pagination
| List | Query parameters | Response metadata |
|---|---|---|
| Services | page (default 1), pageSize (default 20, maximum 100), status, search | data and pagination: {page, pageSize, total, totalPages} |
| Templates | limit (default 50, maximum 100), offset (default 0), category, search | data and pagination: {total, limit, offset} |
| API keys | No pagination parameters in this handler | keys |
Do not assume a list accepts sort, order, or a customer filter. Use only the parameters documented for that endpoint.
Error Handling
Many panel handlers use this error envelope:
{
"error": {
"code": "validation_failed",
"message": "composeYaml is required"
}
}
Here validation_failed maps to 400 Bad Request. Authentication/authorization failures commonly use 401/403, missing resources 404, conflicts 409, and rate limiting 429. A path under /api/ that is not an endpoint answers 404 with code not_found for every method, never the web app's HTML page. Some middleware and analysis/deployment errors return a string error and additional fields instead; do not assume every failure has nested field-level validation details.
Rate Limiting
Panel keys have a rateLimitRpm setting (creation defaults to 60). When the per-key limiter is wired, key-authenticated requests include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset. These are not a universal set of session or deployment tiers, and the headers are not present on every response. Back off on 429 and honor Retry-After when supplied.
Every request is also limited per client address and path: 10 sign-in attempts, 5 registrations and 60 other requests a minute. The address is the one the panel's own proxy saw the request come from, never a value the client writes into X-Forwarded-For or X-Real-IP, so changing those headers does not buy a new allowance (AI-1251). Behind Cloudflare's proxy every visitor arriving through the same Cloudflare edge address shares one allowance, because the panel does not yet read CF-Connecting-IP (AI-797).
WebSocket
The real-time transport is wss://panel.example.com/ws. The hub accepts the OIDC session cookie only, so it is used from a signed-in browser. A token query parameter is not accepted on an installed panel: it belonged to the earlier password login, which is switched off wherever Keycloak is configured, and it was never a panel API-key parameter. MCP uses the separate routes described in MCP Server.
The session is checked when the connection opens and again every 15 seconds while it is open. Once the session ends (sign-out, "sign out other devices", a password change, a suspension, expiry) the server closes the connection with code 1008 ("session ended"); the browser reconnects only with a valid session (AI-2602).
Every frame is JSON with channel, action and an optional data. A client subscribes with {"channel":"logs:<serviceId>","action":"subscribe"}. When the server refuses a subscribe or a terminal input message, it answers on the system channel with exactly one frame and records no subscription:
{"channel":"system","action":"error","data":{"action":"subscribe","channel":"logs:<serviceId>","error":"forbidden"}}
The frame is the same whether the channel belongs to someone else, does not exist or is malformed, so it does not reveal which resources exist. Without it a refused subscribe and an idle channel looked the same (AI-2352).
GET /api/metrics is not in the API description either: it lies outside the /api/v1 base path and takes its own scrape token, not an API key. See Prometheus Metrics.
API Endpoints
| Section | Coverage |
|---|---|
| Authentication | OIDC, API keys, session limitations |
| Services | Deployment, lifecycle, monitoring |
| Templates | Catalog records and template deployment |
| MCP Server | Admin and tenant assistant connections |
| Partner API | Commercial licensing and partner automation |