HTTP API
The server binds KAIO_ADDR (default 127.0.0.1:8080, or a Unix socket) and
serves the frontend alongside these endpoints. Kaio authenticates no one, and
whatever drives this API drives the Docker daemon, which is root-equivalent on
that host. Every request is first sorted by where it comes from and given a
level, as Security describes.
Access
Section titled “Access”Each endpoint below needs one of the levels read, write or admin. A
caller below it gets 403 with a message naming both levels; a caller from an
address Kaio does not accept gets 403 naming the variable to set; a route that
needs the control plane’s signature gets 401 without it. A request that
changes something, or upgrades to a WebSocket, gets 403 when the browser marks
it cross-site.
| Level | Endpoints |
|---|---|
| none | GET /api/health, GET /api/whoami, the web UI, POST /api/cluster/register (it carries a join token), /metrics with its token |
read |
Every other GET, apart from those below, and POST /mcp (each tool then needs its own rung) |
write |
Deploy, apply, update, start, stop, restart, pause, unpause, recreate, rollback, scan, check-update, copy, PUT /api/stacks/{name}/env, container actions, node checks |
admin |
Every DELETE and prune, the container shell, /api/audit, /api/doctor, the cluster token, join and leave, and the signed transfer routes |
A route not in this table needs admin.
| Endpoint | Method | Description |
|---|---|---|
/api/whoami |
GET |
Who the server takes the caller for: user and groups (from the proxy or the control plane, else null and []), level, via (local, network, proxy or cluster) and source, the address the request came from |
/api/audit |
GET |
The audit log, newest first. ?limit= from 1 to 1000, 200 by default. Each entry has at, actor, source, via, level, action, target, outcome (ok, denied or failed), status and detail |
/api/doctor |
GET |
The findings of kaio-server doctor for this server, worst first: severity (danger, warn or info), code, message and fix |
System
Section titled “System”| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET |
Health check. Returns status, version, sha, the git commit the binary was built from, and server_id, this server’s identity, which is how a probe tells it apart from another machine that took its address |
/api/dashboard |
GET |
Current system summary, full container list and metric history. ?hours= sets the history window, from 1 up to KAIO_METRICS_RETENTION_HOURS (default 12); the reply echoes the window it served as history_hours, the retention as metrics_retention_hours, the host’s core count as host_cpus, and every stack as stack_groups: its container ids, its state, their summed CPU, memory and traffic, whether it needs attention, and whether it was started outside Kaio |
/api/events |
GET |
SSE stream for real-time Docker events |
/api/events/history |
GET |
Historical events (limited to 100) |
| Endpoint | Method | Description |
|---|---|---|
/mcp |
POST |
Model Context Protocol over streamable HTTP, for AI agents. Not routed unless KAIO_MCP names a mode, and guarded by its own Host and Origin allowlists rather than the API’s CORS policy. See MCP server |
Metrics
Section titled “Metrics”| Endpoint | Method | Description |
|---|---|---|
/metrics |
GET |
Prometheus exposition of the state Kaio knows: stacks, containers, pending updates, CVE counts, cluster health and Kaio’s own loops. Not routed unless KAIO_METRICS=on, and requires the bearer token KAIO_METRICS_TOKEN names when one is set. See Prometheus and Grafana |
/metrics/targets |
GET |
The nodes of this server’s registry in Prometheus’ HTTP service discovery format, so one Kaio hands Prometheus the rest of the cluster. Each group carries a node label. Same flag and same token as /metrics |
Cluster
Section titled “Cluster”How a server joins another one’s registry. See Multiple servers.
| Endpoint | Method | Description |
|---|---|---|
/api/cluster |
GET |
Whether this server is a control plane, a member, or neither |
/api/cluster/token |
POST |
Mint a join token: {token, expires_at}. It lets one server in, once, within 24 hours, and only its SHA-256 is stored, so no route reads it back |
/api/cluster/token |
DELETE |
Retire every token not used yet: {revoked}. Enrolled servers are not affected |
/api/cluster/register |
POST |
Called by a joining node: {token, server_id, name?, advertise?}. On a valid token the node is added to the registry under its own server_id, probed, and its settled {name, url, status, error} returned. A server that is the control plane itself is refused |
/api/cluster/join |
POST |
Asks this server to join the cluster in {control_plane_url, token, name?, advertise?} |
/api/cluster/membership |
DELETE |
Leave: asks the control plane to drop this server’s registry entry, then forgets it locally. Returns {left, removed, error}, and still forgets when the control plane cannot be reached |
register reads the connection’s peer address when advertise is missing, so
a node behind a wildcard bind is enrolled without naming its own address.
The registry of Kaio instances this server pilots. See Multiple servers.
| Endpoint | Method | Description |
|---|---|---|
/api/nodes |
GET |
List the nodes that have joined, ordered by name |
/api/nodes/{name} |
GET |
One node |
/api/nodes/{name} |
DELETE |
Drop the node from the registry. The node itself is untouched; it rejoins by running kaio-cli join again |
/api/nodes/{name}/check |
POST |
Probe one node and return it with the result |
/api/nodes/{name}/proxy/{*path} |
any | Forward the request to that node’s own API, at {node url}/{path}. A node that is not in the registry answers 404: the registry is what makes a node reachable this way |
/api/nodes/check |
POST |
Probe every node and return them all |
Through the gateway
Section titled “Through the gateway”/api/nodes/{name}/proxy/{*path} makes every route on this page reachable on a
node: GET /api/nodes/prod-01/proxy/api/dashboard answers with prod-01’s
dashboard. The query string is carried over and all three transports survive the
hop: JSON with any method and body, SSE streamed rather than buffered, and a
WebSocket upgrade bridged socket to socket so the container terminal works.
Every call the gateway relays is signed by this server for that node, with the
caller’s user and level inside the signature, so the node holds it to the same
level and records the same user. The route itself needs the level of what it
relays: DELETE /api/nodes/prod-01/proxy/api/stacks/blog needs admin, here and
again on the node. Authorization and the caller’s identity headers are not
forwarded.
A route kept for the control plane, such as /api/stacks/{name}/env/export,
stays shut through the gateway: it answers 401 here, whatever the caller’s
level, and only a call the control plane makes itself, for a copy, reaches it.
Request bodies are buffered so that their hash can be signed, up to 32 MiB.
On the node, a signed call is checked for its headers, its clock and the
cluster it names before its body is read, and a Content-Length above 32 MiB
is refused with 413 straight away. A
volume archive is the exception: POST .../api/volumes/{name}/import is
streamed at constant memory, with a signature that says the body is not covered.
Reaching a node this way requires it to be in the registry. Removing it removes the route, and a node that left the cluster no longer accepts the signature.
Nodes only enter the registry by joining (see the cluster routes above), and
nothing here edits one. status is the result of the last probe: online,
offline, unauthorized or unknown.
Containers
Section titled “Containers”| Endpoint | Method | Description |
|---|---|---|
/api/containers/{id} |
DELETE |
Delete a container |
/api/containers/{id}/action |
POST |
start, stop, restart, pause, unpause |
/api/containers/{id}/logs |
GET |
SSE stream of logs. ?follow=false for a one-shot snapshot of the last lines; ?tail= overrides KAIO_LOGS_TAIL |
/api/containers/{id}/shell |
WS |
WebSocket for interactive sh access |
Stacks
Section titled “Stacks”| Endpoint | Method | Description |
|---|---|---|
/api/stacks |
POST |
Deploy a stack (name, content, optional env array replacing the stack environment, optional accept_risks, optional wait and wait_timeout in seconds, optional expected_version, optional allow_port_clash). A file that hands the host to a service is refused with 409 and code host_access unless accept_risks is true, and one that publishes a port another stack or container already publishes with 409 and code port_taken unless allow_port_clash is true. With wait, answers once every container runs and passes its healthcheck, and otherwise rolls back to the previous version and answers 409 with code unhealthy. Answers the new version and the risks of the file |
/api/stacks/{name} |
DELETE |
Remove a stack, its files and its containers |
/api/stacks/{name}/update |
POST |
Pull and update (pull + up -d). ?wait=true, with wait_timeout in seconds, waits for the stack as a deploy does, and ?expected_version= refuses to act on a stack that moved, and puts back the images it ran before when it does not come up healthy |
/api/stacks/{name}/restart |
POST |
Restart, or bring the stack up when it has no containers yet, which is checked for risks like a deploy: ?accept_risks=true |
/api/stacks/{name}/start |
POST |
Start every stopped container of the stack |
/api/stacks/{name}/pause |
POST |
Pause every running container of the stack |
/api/stacks/{name}/unpause |
POST |
Resume every paused container of the stack |
/api/stacks/{name}/recreate |
POST |
Recreate every container of the stack from its compose file |
/api/stacks/{name}/scan |
POST |
Start a Trivy scan of all the stack’s images |
/api/stacks/{name}/check-update |
POST |
Trigger a remote image update check |
/api/stacks/{name}/logs |
GET |
SSE stream merging the logs of every container of the stack, each line prefixed by its service. ?tail= overrides KAIO_LOGS_TAIL, per container |
/api/stacks/{name}/compose |
GET |
Retrieve the docker-compose.yml |
/api/stacks/{name}/plan |
POST |
What an action would change, without running it. The body names it: {"action": "deploy", "content": ..., "env": [...]}, {"action": "apply"}, {"action": "rollback", "version": 3} or {"action": "update"}. Answers the services added, removed and changed, the images pulled and dropped, the variables that move with secrets left out, the risks of the resulting file, and port_clashes as a list of {port, held_by, free}, which a deploy, an apply or a rollback would be refused on. An update plan asks the registry there and then, unless a check of the last five minutes, started after the stack last changed, can answer. Read level: it changes nothing |
/api/stacks/{name}/risks |
POST |
Name what a Compose file would hand the host to, without deploying it (content, optional env merged with the stored variables as a deploy would). Write level, like the deploy it checks |
The deploy, apply, rollback and risks all answer risks as a list of
{service, kind, detail}, empty for an ordinary file. kind is one of
runtime_socket (a bind mount of docker.sock, podman.sock or
containerd.sock, or of a directory holding one), host_root (a bind mount
of /), privileged, host_namespace (network_mode, pid, ipc, uts or
userns_mode set to host) and capability (ALL, SYS_ADMIN or
SYS_MODULE in cap_add). detail quotes the mount as the file writes it,
${VARIABLES} unexpanded, so it never carries a value. A deploy, an apply, a
rollback or a copy whose file has any is refused unless the call passes
accept_risks, over REST as over MCP; accepted, it
goes ahead and records a warn event naming them.
Stack environment
Section titled “Stack environment”| Endpoint | Method | Description |
|---|---|---|
/api/stacks/{name}/env |
GET |
List variables: [{key, value, secret}], secret values returned as null |
/api/stacks/{name}/env |
PUT |
Replace the environment without deploying (a null value keeps the stored one). Returns env_pending |
/api/stacks/{name}/env/export |
GET |
Same list with secret values in the clear, for a server moving a stack to another server. Requires a call signed by the control plane this server joined, and answers 401 otherwise |
/api/stacks/{name}/apply |
POST |
Redeploy with the stored environment, create a version and clear env_pending. ?accept_risks=true and ?allow_port_clash=true as for a deploy. ?wait=true, with wait_timeout in seconds, waits for the stack as a deploy does, and ?expected_version= refuses to act on a stack that moved |
Copying a stack to another server
Section titled “Copying a stack to another server”| Endpoint | Method | Description |
|---|---|---|
/api/stacks/{name}/copy |
POST |
Copy a stack to another node, or onto this one under a new name. Answers the plan it followed |
This is the control plane’s own route, not a node’s: it orchestrates the pieces below. The source is never written to, never stopped and never deleted, so a failed copy costs time rather than data.
{ "from": "prod-01", "to": "prod-02", "as": "web-staging", "include_volumes": true, "start": false, "allow_binds": false, "allow_anonymous_volumes": false, "accept_risks": false, "dry_run": false}Every field is optional. from and to name nodes in the registry; leaving one
out means this server. as defaults to the source name, and must differ from it
when source and destination are the same server. start defaults to false:
a copy that came up on its own would leave two live stacks contending for the
same DNS, webhooks, queues and mail.
dry_run returns the plan and changes nothing, blockers included, so a caller
can show them before asking for confirmation. A real copy refuses on those same
blockers.
The plan carries volumes (each with the name it will take on the destination),
binds, images, warnings and blockers. A copy stops before touching the
destination when:
- the destination already runs a stack by that name;
- a port the stack publishes is already published there, whether or not the copy
was asked to start, because the result could never come up.
allow_port_clashaccepts writing it all the same; - a volume keeps its own name on the destination (an explicit
name:, or anexternalone) and both ends are the same server, because the copy would then mount the volume the source is running on; - the stack mounts host paths, unless
allow_bindssays to accept that they stay behind; - a volume is anonymous and
include_volumeswas asked for, unlessallow_anonymous_volumessays to accept losing it. Declaring the volume undervolumes:in the compose file and redeploying is the better answer: an anonymous volume holding real data would otherwise produce a copy that looks healthy and is empty; - the stack’s file hands the host to a service, unless
accept_riskssays to copy it anyway, as a deploy would ask.
Named volumes are renamed to follow the destination project: copying web as
web-staging moves web_data into web-staging_data. A volume given an
explicit name: in the compose file keeps it, and an external one is left
alone; on another server that is what you want, and on the same server it is
refused rather than quietly shared.
A volume declared under volumes: that Docker has never created is left out of
the plan rather than failing the copy, and a name: written with ${VAR} is
interpolated with the stack’s environment before it is looked up.
If anything fails after the destination has been written to, the copy undoes
itself there: the volumes it created are removed, the stack it imported is
removed, and a volume that already existed is never touched. When even that
fails, an error event names what to remove by hand.
Moving a stack to another server
Section titled “Moving a stack to another server”These routes carry a stack, its secrets and its data off the machine, so each
one asks for a call signed by the control plane, the way
/api/stacks/{name}/env/export does above, and answers 401 without it. They
are the pieces a copy or a migration is built from: none of them moves anything
by itself.
| Endpoint | Method | Description |
|---|---|---|
/api/stacks/{name}/export |
GET |
The whole stack as JSON: compose file, environment with its secrets in the clear, every version with its own environment, the images it references, and an inventory of what it mounts. ?sizes=true also measures each volume, which costs one throwaway container |
/api/stacks/import |
POST |
Write a stack here from that JSON, under name, without starting it. Refuses a name already taken, files already present, or a current_version missing from versions |
/api/volumes/{name}/export |
GET |
Stream the volume as an uncompressed tar (application/x-tar), read from a throwaway container |
/api/volumes/{name}/import |
POST |
Unpack such a tar into the volume, creating it when absent. Refuses a volume that already holds data unless ?force=true |
/api/stacks/{name}/up |
POST |
Bring an imported stack up without adding a version to its history. Checked for risks and taken ports like a deploy: ?accept_risks=true, ?allow_port_clash=true |
The mount inventory separates what can be moved from what cannot:
volumesare the named volumes, each with the Compose key it comes from (web_datafromdataunder the projectweb), where each service mounts it, whether it isexternal, and whether it isanonymous. An anonymous volume is one Docker named itself: its data is real but its name is not, so it cannot be recreated by name on another host.bindsare the host paths the stack mounts. They are never transferred. A path that exists on one server has no reason to exist on the next, and copying it blindly would land the wrong ownership on the wrong files, so the inventory reports them and stops there.
An external: true volume is reported but belongs to something else, so a copy
leaves it alone.
The throwaway container runs KAIO_TRANSFER_IMAGE (default alpine:3), pulled
on first use, with no network and nothing mounted but the volume.
Stack versions
Section titled “Stack versions”| Endpoint | Method | Description |
|---|---|---|
/api/stacks/{name}/versions |
GET |
List all historical versions |
/api/stacks/{name}/rollback/{version} |
POST |
Roll back to a specific version. ?accept_risks=true and ?allow_port_clash=true as for a deploy. ?wait=true, with wait_timeout in seconds, waits for the stack as a deploy does, and ?expected_version= refuses to act on a stack that moved |
/api/stacks/{name}/versions/{version} |
DELETE |
Delete a specific version |
Images
Section titled “Images”| Endpoint | Method | Description |
|---|---|---|
/api/images |
GET |
List local images, enriched with scan summaries |
/api/images/scan |
POST |
Start a Trivy scan for every tagged image on the host |
/api/images/{id} |
DELETE |
Forcefully delete an image |
/api/images/{id}/scan |
POST |
Start a scan for one image (asynchronous) |
/api/images/{id}/scan |
GET |
Latest scan result, with the full CVE list |
Volumes & networks
Section titled “Volumes & networks”| Endpoint | Method | Description |
|---|---|---|
/api/volumes |
GET |
List volumes |
/api/volumes/{name} |
DELETE |
Delete a volume |
/api/networks |
GET |
List networks |
/api/networks/{id} |
DELETE |
Delete a network |
/api/images, /api/volumes and /api/networks give each item a Stacks
array: the stacks whose containers use it, sorted, empty when none does.
Pruning
Section titled “Pruning”| Endpoint | Method | Description |
|---|---|---|
/api/prune/images |
POST |
Prune dangling and unused images |
/api/prune/containers |
POST |
Prune stopped containers |
/api/prune/volumes |
POST |
Prune unused local volumes, named ones included |
/api/prune/networks |
POST |
Prune unused networks |
Streaming formats
Section titled “Streaming formats”- SSE (
/api/events, log endpoints): one JSON object per line. Log lines carryservice,container,stream,tsandline. - WebSocket (
/api/containers/{id}/shell): raw PTY bytes in both directions.
Errors
Section titled “Errors”A refused or failed call answers with a JSON body that says why in words and in a stable code, so a script or an agent can branch on the code rather than on the wording:
{ "status": "error", "code": "external_stack", "message": "Stack monitoring was started outside Kaio, ..." }| Code | Status | Meaning |
|---|---|---|
invalid |
400 |
The request does not hold together: a bad name, an unreadable file, a missing value |
unauthorized |
401 |
No identity, or one that does not check out |
forbidden |
403 |
The identity is known and lacks the level the call needs |
not_found |
404 |
No such stack, container, version, node or file |
external_stack |
409 |
The stack was started outside Kaio: it can be read, not acted on |
host_access |
409 |
The file hands the host to a service and the call did not pass accept_risks |
busy |
409 |
Another call is already changing that stack: try again once it has finished |
version_moved |
409 |
The call passed expected_version and the stack runs another version: read it again before acting |
port_taken |
409 |
The file publishes a port that a running, paused, restarting or unhealthy container of another stack, or outside any stack, already publishes with the same protocol on an overlapping address, or that another deploy in flight is about to. The message names the holder, and a free port to try when there is one. Nothing was created; allow_port_clash goes ahead all the same |
unhealthy |
409 |
A deploy, apply, rollback or update with wait did not come up healthy in time and was put back to what it ran before |
upstream |
502 |
A node or a registry did not answer, or an update check or an update plan could not check an image |
database, docker |
500 |
The server could not reach its database or the container runtime |
Related
Section titled “Related”Kaio, built by Régis Gaidot