Skip to content

The Platform API's contract ​

platform-api-v1.openapi.json is the OpenAPI 3.1 document of the Platform API (/v1, §60a). It is the contract a client is built from: the web, aapctl and the planned Flutter app need nothing else. The server enforces, a client only offers: a permission, an ETag, a name and a form are all checked again by the API, whatever a screen showed.

  • It is generated. The paths, methods and permissions (x-permission; null is a route that needs only a token; x-secrets-pick is a write whose body can name a secret key) come from the table of routes; the schemas are written once in crates/platform-api/src/openapi.rs. Tests hold the file equal to the code and hold the schemas equal to what the router answers (every real answer validates; every documented status is answered; every example parses).

  • Regenerate it after a change to a route, a body or an answer, and commit the result:

    sh
    cargo run -q -p aap-api-server --bin api -- openapi > docs/api/platform-api-v1.openapi.json

    cargo test -p aap-platform-api --test openapi fails until you do. A breaking change is /v2 and a new file, not an edit of this one.

  • CBOR (AD-062). Every JSON body of the API is also application/cbor on the same schema: send Content-Type: application/cbor and/or Accept: application/cbor. JSON is the default; an Accept that lists neither is 406; every answer says Vary: Accept; the ETag of an object is the same in both. Maps have text keys and there are no byte strings. GET /v1/openapi.json and the YAML export stay as they are. aapctl --encoding cbor (or AAPCTL_ENCODING=cbor) opts in.

  • The running API serves the same document at GET /v1/openapi.json (it needs platform:agents.read).

  • Not in it, on purpose: cookies, CORS credentials and a wildcard origin, an unconditional write or delete, a secret value, DPoP.

A client in half a page ​

  1. Authenticate. Get an access token from the deployment's OIDC issuer (Authorization Code with PKCE; a native client uses the system browser and a loopback or claimed redirect) and send Authorization: Bearer <token> on every call. GET /v1/me answers { "permissions": [...] }: the platform: values of the token. Use it to decide what to show; the API decides what is allowed. A 401 is a missing or bad token (WWW-Authenticate says which); a 403 names the one permission that is missing in permission.
  2. List and read. GET /v1/agents is { "agents": [...] }, a row each (state is the lifecycle: saving, blocked, degraded, ready, suspended, deleting; managedBy is dashboard or gitops, and a gitops object is read-only). GET /v1/agents/{name} is the row, representation ({ "form": { "form", "deployment" } }, or { "yamlOnly": [...] } when no form can say the object), the operator's status and the ETag header. Models are /v1/models, tool servers /v1/tool-servers, the Secret keys a form may name /v1/secret-keys (names only, never a value). A tool server's status is the operator's (K2): usedBy, the conditions Accepted, InUse and AgentsReady, and, when the deployment probes its MCP server (K3b, toolProbe), the Reachable condition (Probed, NeedsHeader, Invalid, Unreachable, NotMcp or Timeout) and probe.tools (at most 64 names, sorted, probe.toolsMore, and probe.incomplete when the server still named a cursor after five pages); both are absent when the deployment does not probe it or the server was not probed.
  3. Create with If-None-Match: *. PUT /v1/agents/{name} with Content-Type: application/json, the form as the body, and If-None-Match: *. 201 with the new object, its ETag and a Location. A second create of the same name is 409 already-exists. A body that names a secret key needs platform:secrets.pick as well. An agent form is one of three kinds, discriminated by agent.kind: coder (a GitHub App, no files), folder (the folder inline, no GitHub App) and, since K11b, a2a — an image that serves A2A itself (AD-054), which has no model (null, and refused when it carries one), no tool servers and no environment.image; its image, port, card and health paths and variables are agent.{image,port,cardPath,healthPath,env}, each variable a plain value or a secret, never both. GET /v1/agents says which kind a row is in kind.
  4. Replace and delete with If-Match. Read the object, keep its ETag, send it back unchanged in If-Match: PUT replaces (200), DELETE deletes (204, or 202 with the row and an ETag while the operator is still releasing what the agent ran: poll GET until it is 404; a repeated DELETE needs the fresh ETag). No If-Match and no If-None-Match is 428; a tag that is no longer the object's is 412: read again and decide, do not retry blindly. The ETag is opaque and strong: only equality means anything.
  5. Read why an agent is not Ready. status and its conditions say what the operator saw. GET /v1/agents/{name}/events is { "events": [...], "incomplete": false }, the Kubernetes Events about the agent's objects, newest first, at most 100, each { type, reason, message, object: { kind, name }, count, firstSeen, lastSeen, by }. They are attributed by the names the operator gives an agent's objects (by: "name"; the agent's own AgentService and AgentConfig by uid, by: "uid"): an event of another agent's object never appears, but an unrelated object whose name has the same shape can, so show by. An empty list is not a healthy agent (Kubernetes keeps events for a limited time), and incomplete: true means events may be missing: say so to the person. A message is the cluster's own text: render it as text, never as markup, and keep it out of your logs.
  6. Read the error. Every failure is application/problem+json (RFC 9457): type (a URN such as urn:vymalo:agents:problem:stale, not an address to fetch), title, status, detail, and by kind: errors: [{ field, message }] on a 422 (field is the form field as you sent it: model.endpoint, agent.github.owners[0]; empty for the form as a whole), permission on a 403, agentCount and, for a caller who may read agents, agents on a 409 referenced, reasons on a 409 yaml-only. Branch on type, show detail, put each errors[].message beside its field. A 503 carries Retry-After.

aapctl is the second client of this contract (K9b-1, crates/platform-client): get, apply, delete, export, whoami and login --token-stdin call only what this document lists, and client_calls_are_documented holds the client's table of calls (method, path template, and every status it acts on) to it, so a route renamed or a status dropped here fails a test and not a person at a terminal. What it shows a client of the contract has to know: the API takes forms, not custom resources (an AgentService and its AgentConfig are one form; the deployment's part is the server's, filled from GET /v1/info's defaults on a create and kept on a replace, so a client that reads a file compares it instead of sending it), an agent's ETag moves when the operator writes its status (a 412 is not always a person's edit: read again, and retry only if the form is what you read), and a second create is 409 already-exists, never a replace. The sign-in of aapctl with the browser (PKCE) is not built yet: it takes a token from AAPCTL_TOKEN or login --token-stdin.

Every answer is Cache-Control: no-store. A browser client is allowed only if its exact origin is in the deployment's list (there is no wildcard, and no credentials: the token is the only credential).