Appearance
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;nullis a route that needs only a token;x-secrets-pickis a write whose body can name a secret key) come from the table of routes; the schemas are written once incrates/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:
shcargo run -q -p aap-api-server --bin api -- openapi > docs/api/platform-api-v1.openapi.jsoncargo test -p aap-platform-api --test openapifails until you do. A breaking change is/v2and a new file, not an edit of this one.CBOR (AD-062). Every JSON body of the API is also
application/cboron the same schema: sendContent-Type: application/cborand/orAccept: application/cbor. JSON is the default; anAcceptthat lists neither is406; every answer saysVary: Accept; theETagof an object is the same in both. Maps have text keys and there are no byte strings.GET /v1/openapi.jsonand the YAML export stay as they are.aapctl --encoding cbor(orAAPCTL_ENCODING=cbor) opts in.The running API serves the same document at
GET /v1/openapi.json(it needsplatform: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 ​
- 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/meanswers{ "permissions": [...] }: theplatform:values of the token. Use it to decide what to show; the API decides what is allowed. A401is a missing or bad token (WWW-Authenticatesays which); a403names the one permission that is missing inpermission. - List and read.
GET /v1/agentsis{ "agents": [...] }, a row each (stateis the lifecycle:saving,blocked,degraded,ready,suspended,deleting;managedByisdashboardorgitops, and agitopsobject 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'sstatusand theETagheader. 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'sstatusis the operator's (K2):usedBy, the conditionsAccepted,InUseandAgentsReady, and, when the deployment probes its MCP server (K3b,toolProbe), theReachablecondition (Probed,NeedsHeader,Invalid,Unreachable,NotMcporTimeout) andprobe.tools(at most 64 names, sorted,probe.toolsMore, andprobe.incompletewhen 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. - Create with
If-None-Match: *.PUT /v1/agents/{name}withContent-Type: application/json, the form as the body, andIf-None-Match: *.201with the new object, itsETagand aLocation. A second create of the same name is409already-exists. A body that names a secret key needsplatform:secrets.pickas well. An agent form is one of three kinds, discriminated byagent.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 nomodel(null, and refused when it carries one), no tool servers and noenvironment.image; its image, port, card and health paths and variables areagent.{image,port,cardPath,healthPath,env}, each variable a plainvalueor asecret, never both.GET /v1/agentssays which kind a row is inkind. - Replace and delete with
If-Match. Read the object, keep itsETag, send it back unchanged inIf-Match:PUTreplaces (200),DELETEdeletes (204, or202with the row and anETagwhile the operator is still releasing what the agent ran: pollGETuntil it is404; a repeatedDELETEneeds the freshETag). NoIf-Matchand noIf-None-Matchis428; a tag that is no longer the object's is412: read again and decide, do not retry blindly. TheETagis opaque and strong: only equality means anything. - Read why an agent is not
Ready.statusand itsconditionssay what the operator saw.GET /v1/agents/{name}/eventsis{ "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 ownAgentServiceandAgentConfigby uid,by: "uid"): an event of another agent's object never appears, but an unrelated object whose name has the same shape can, so showby. An empty list is not a healthy agent (Kubernetes keeps events for a limited time), andincomplete: truemeans 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. - Read the error. Every failure is
application/problem+json(RFC 9457):type(a URN such asurn:vymalo:agents:problem:stale, not an address to fetch),title,status,detail, and by kind:errors: [{ field, message }]on a422(fieldis the form field as you sent it:model.endpoint,agent.github.owners[0]; empty for the form as a whole),permissionon a403,agentCountand, for a caller who may read agents,agentson a409referenced,reasonson a409yaml-only. Branch ontype, showdetail, put eacherrors[].messagebeside its field. A503carriesRetry-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).