HTTP API
When KASM_RUNTIME_SESSION_TOKEN is set, Kasm Session Runtime serves HTTP on KASM_SESSION_RUNTIME_PORT (default 9434). The listener carries MCP, the same 68 methods as plain HTTP calls, recipes, file transfer, an optional pass-through to the browser’s DevTools port, the routes the sidebar reads and writes, and the routes that run the agent in the workspace. Each route is listed here with the credential it takes.
Most routes need no model. The exceptions are the vision methods screen.judge, screen.ground and screen.ask (see MCP methods), recipes that declare screen.* steps, and the agent in the workspace, which uses its own provider.
The OpenAPI document
Section titled “The OpenAPI document”A running server describes itself at GET /v1/openapi.json, with no credential. It is an OpenAPI 3.1 document generated from the routes as mounted in that process: every method’s parameter schema, every request and response body, and each route’s credential as configured. Use it to generate a client, or to check what a particular session has switched on. The tables below summarise it.
The document’s info.version is the version of the API contract, v1, which only gains routes and fields. The runtime’s own release is in the served document’s x-kasm-runtime-version field. The MCP initialize reply carries the same release as serverInfo.version. To find out whether a session has a feature, look for its path in the document’s paths. Compatibility says how an image moves to a newer release.
Base address and credentials
Section titled “Base address and credentials”Through Kasm, the base is https://<host>/desktop/<kasm_id>/runtime/, where runtime is the name of the Kasm port-map entry for port 9434. Every path below is relative to that base.
Every request through that address carries two credentials. Kasm’s proxy checks Kasm’s session cookie before it forwards anything, on every route; the runtime then checks its own token. The cookie (Cookie: session_token=<...>; username=<...>) must be the session owner’s. A username and password login sets it, and so does the kasm_url that public/request_kasm returns to an API key caller: loading it posts the JWT in that URL to POST /api/login_saml, whose response sets the cookie for the requested user, so a client with a cookie jar needs no password.
| Credential | Set by | Sent as |
|---|---|---|
| Session token | KASM_RUNTIME_SESSION_TOKEN |
the X-Kasm-Runtime-Session-Token header only |
| Messaging token | KASM_RUNTIME_INBOX_TOKEN |
the same header, or ?token= on the activity and inbox routes |
| Sidebar token | generated for the bundled sidebar | the same header only |
The session token is the credential of whoever drives the session from outside. The messaging token is the narrower one a sidebar or a bridge holds for people’s messages. The sidebar token is generated for the bundled sidebar and carries the same rights as the messaging token (see Sidebar protocol). None goes in Authorization, because Kasm’s port-map proxy overwrites that header before forwarding. A missing or wrong token gets 401. The header value decides which token it is.
In a Kasm session, the routes the sidebar reads (the read rule below) always need one of these tokens.
Paths in a URL are percent-encoded, as in any URL: a file named Q3 report.pdf is /v1/files/home/Documents/Q3%20report.pdf.
| Method | Path | Credential | What it does |
|---|---|---|---|
POST |
/mcp |
session token | MCP Streamable HTTP: JSON-RPC requests, answered as JSON or an event stream |
GET |
/mcp |
session token | the server-to-client stream, for protocol versions before 2026-07-28 |
DELETE |
/mcp |
session token | ends a session, for protocol versions before 2026-07-28 |
The Mcp-Protocol-Version header picks the protocol. From 2026-07-28 each POST stands alone, with no initialize and no session; GET and DELETE then return 405. A request body is capped at 8 MiB.
Method calls
Section titled “Method calls”| Method | Path | Credential | What it does |
|---|---|---|---|
POST |
/v1/call/<method> |
session token | runs one of the 68 methods; the body is its parameters as a JSON object, and an empty body is {} |
A call returns 200 {"result": ...} or {"error": {"class", "message"}}:
| Status | Error class | Meaning |
|---|---|---|
| 400 | malformed |
the body is not one JSON object, or the parameters fail the method’s schema or checks |
| 404 | malformed |
no such method; nothing ran and no step is recorded |
| 413 | malformed |
the body is over 8 MiB |
| 422 | resolution |
a capability is unavailable, something was not found, or a wait timed out |
| 500 | environment, internal, error |
the runtime failed |
| 503 | shutting_down, cancelled |
the call never ran |
A call that runs records one row in report.json’s steps[], the same row the method records over MCP. Calls run one at a time; a second call waits for the first.
The optional header X-Kasm-Runtime-Coordinates: agent asks for the fixed 1280×800 agent canvas instead of screen pixels (see coordinate spaces).
Set TOKEN to the runtime session token, KASM_LOGIN_COOKIE to the cookie obtained from a Kasm login, and KASM_USERNAME to that session owner’s username. Then call the method:
curl -s -X POST -H "X-Kasm-Runtime-Session-Token: $TOKEN" \ -H "Cookie: session_token=$KASM_LOGIN_COOKIE; username=$KASM_USERNAME" \ -H 'Content-Type: application/json' \ -d '{"chord": "ctrl+s"}' \ "https://<host>/desktop/<kasm_id>/runtime/v1/call/input.key"Recipes
Section titled “Recipes”| Method | Path | Credential | What it does |
|---|---|---|---|
POST |
/v1/recipes |
session token | discovers or runs an installed recipe |
The body is one JSON object, at most 64 KiB:
| Field | Meaning |
|---|---|
command |
index, list, describe, guide or run |
operation |
the operation ID, for describe and run |
arguments |
the operation’s arguments, for run |
resume |
the token from a needs_decision receipt, to answer it |
decisions |
the answers, keyed by decision ID, sent with resume |
The reply is catalogue data or a receipt tree. Only a receipt whose outcome is verified is success. The command-line recipes subcommand uses this route. The recipes.* methods return the same data in a compact form; see Recipes. The route takes the same coordinate header as method calls. A catalogue that is not configured answers 503.
File transfer
Section titled “File transfer”{root} is home or tmp. Paths may not leave the root, including through a symlink.
| Method | Path | Credential | What it does |
|---|---|---|---|
GET |
/v1/files/{root}/{path} |
session token | streams a regular file; the X-Kasm-Runtime-Sha256 trailer carries its SHA-256 |
PUT |
/v1/files/{root}/{path} |
session token | writes a file, streamed; ?overwrite=true to replace, ?mode=0755 to set the mode |
GET |
/v1/dirs/{root}/{path} |
session token | streams a directory as a zip of its regular files and directories |
PUT |
/v1/dirs/{root}/{path} |
session token | extracts an uploaded zip into a directory; ?overwrite=true to replace |
- A file
PUTcreates any missing parent directories inside the root. - A file
PUTis atomic. The upload is written under a temporary name and appears at the path only once it is complete, so a reader never sees part of a file and a failed upload leaves the old file in place. Once the reply arrives, the file is there in full. - A
PUTanswers 201 when nothing was there and 200 when it replaced a file. Withoutoverwrite, something already at the path gets 409 and nothing is replaced, even if it appeared while the upload was running. - A file
PUTreplies{"path", "bytes", "sha256", "created"}: the path written, as~/<path>or/tmp/<path>, its size, the SHA-256 of what was written, and whether the file is new. A directoryPUTreplies{"path", "files", "bytes"}. - Uploads are capped by
KASM_RUNTIME_UPLOAD_MAX_BYTES, an archive’s extracted size byKASM_RUNTIME_EXTRACT_MAX_BYTESand what a directory download reads byKASM_RUNTIME_DOWNLOAD_MAX_BYTES, all 1 GiB by default. An upload over its cap is 413; a directory download that reaches its cap is cut off mid-stream. An archive is checked in full before anything is extracted, and may hold at most 10,000 entries. - At most four transfers run at once; the next gets 503
busyand should retry. A stream that makes no progress for 60 seconds is cut off. - A finished transfer appears as a
transferevent on/events, without its content.
Checking a download
Section titled “Checking a download”The X-Kasm-Runtime-Sha256 trailer on a file GET reaches the client only on a direct connection to the runtime. Kasm’s proxy does not pass trailer values on. Through the Kasm address the response still carries the Trailer: X-Kasm-Runtime-Sha256 header, but the body ends without the value. To check a download there:
- For a file up to 5 MiB, call
file.get(POST /v1/call/file.get), which returns the content and itssha256in one reply. - For a larger file, run
sha256sumon it with theshellmethod and compare that with the hash of what you received.
An upload needs neither, because the PUT reply’s sha256 travels in the body.
Transfer errors
Section titled “Transfer errors”A transfer that fails before its body starts returns the same {"error": {"class", "message"}} body as a method call:
| Status | Error class | Meaning |
|---|---|---|
| 400 | malformed |
a bad path, a path that leaves the root, a bad mode, or an archive that cannot be read |
| 404 | resolution |
nothing at the path |
| 409 | resolution |
something is already there without overwrite, the path is not a regular file or directory, or an entry was swapped during the write |
| 413 | malformed |
over the upload or extraction cap |
| 503 | busy, cancelled |
every transfer slot is taken, or the request ended or stalled |
| 500 | environment |
the runtime failed |
A download that fails after its body has started cannot change its status, so the runtime drops the connection. A download that ends without a clean finish is incomplete.
CDP passthrough
Section titled “CDP passthrough”Mounted only when KASM_ENABLE_CDP=true as well as the session token.
| Method | Path | Credential | What it does |
|---|---|---|---|
GET |
/cdp/{name}/{path} |
session token | one application’s DevTools HTTP endpoints and WebSocket, proxied |
PUT |
/cdp/{name}/{path} |
session token | the same, for DevTools endpoints that take PUT |
GET |
/cdp/ |
session token | nothing: a 404 that states the route above |
{name} is an application as dom.targets lists it: default for the fixed endpoint, or the name an image’s launcher registered the application under, such as chrome. A generic Chrome DevTools Protocol client, such as Playwright or Puppeteer, then has the whole of that application, including every tab and arbitrary JavaScript. The discovery responses’ WebSocket URLs are rewritten to point back through the same route. Each request checks the registration first, over the same connection it is then forwarded on: a name nothing registered is 404, and one whose browser is not answering, whose port another process took over, or whose browser fails during the request, is 502, each with a JSON body saying so. The runtime’s credentials and a client’s Origin header are dropped before the request reaches the application, so a browser-hosted client connects as a command-line one does. Through Kasm it is reached through the same runtime port map, at https://<host>/desktop/<kasm_id>/runtime/cdp/<name>/json/version.
Observe routes
Section titled “Observe routes”These are what a sidebar reads to follow a run. They are also served by kasm-session-runtime run when KASM_RUNTIME_OBSERVE=1.
| Method | Path | Credential | What it does |
|---|---|---|---|
GET |
/events |
read rule | server-sent events, one per line of the run’s trace.jsonl |
GET |
/artifacts/report.json |
read rule | the run’s report as last written |
GET |
/artifacts/trace.jsonl |
read rule | every event /events streams, one per line |
GET |
/artifacts/{path} |
read rule | any other file in the run’s output directory, such as screenshots/NN-label.jpg |
Under the read rule, a read needs a token when KASM_RUNTIME_OBSERVE_TOKEN_REQUIRED=true. In a Kasm session the gate is always on, and KASM_RUNTIME_OBSERVE_INPUT=true turns it on anywhere, because the trace then holds keystrokes. Outside Kasm with the gate off, reads need no credential. A gated read accepts the session token or the sidebar token in the header only, or the messaging token in the header or as ?token= (an EventSource or <img> cannot set a header). A gated read with no token configured at all is refused with 503. The OpenAPI document’s x-kasm-runtime-observe-gate field says which rule a running server uses.
If you expose the port without Kasm’s proxy in front and leave the gate off, the open reads expose screenshots and tool results; turn the gate on or put your own authentication in front.
Event types and file handling are on Sidebar protocol.
Inbox routes
Section titled “Inbox routes”These routes carry the channel between people in the session and whoever is working: the agent in the workspace, an outside agent or the runtime’s loop. They are mounted when KASM_RUNTIME_INBOX_TOKEN or the session token is set; otherwise they return 404.
| Method | Path | Credential | What it does |
|---|---|---|---|
POST |
/messages |
session, messaging or sidebar token | posts a message |
GET |
/messages |
read rule | lists messages since a revision (?since=) or by state (?state=) |
GET |
/messages/{id} |
read rule | one message |
GET |
/runs/{run}/messages/{key} |
session, messaging or sidebar token | looks up a message by the idempotency key the caller posted it under |
POST |
/attachments |
session, messaging or sidebar token | uploads an attachment to reference from a message |
GET |
/attachments/{id} |
read rule | one attachment; ?inline=1 for images |
POST |
/requests |
session token only | asks the person a typed question |
GET |
/requests |
read rule | lists requests, optionally by ?state= |
GET |
/requests/{id} |
read rule | one request |
POST |
/requests/{id}/cancel |
session token only | closes a request without a reply |
POST |
/requests/{id}/decline |
messaging or sidebar token only | the person declines a request: Not done, or Stop. The request closes closed_by: declined |
POST |
/actions |
session, messaging or sidebar token; ack needs the session token |
a control action: stop, finish_intervention or ack |
GET |
/inbox |
read rule | the run id, epoch, revision, counts by state and open requests |
The sender recorded on a message comes from the credential: orchestrator for the session token and operator for the messaging and sidebar tokens. JSON bodies on these routes are capped at 1 MiB; attachments have their own cap, evidence.inbox_attachment_bytes in the operator file. Message and request shapes, idempotency keys and states are on Sidebar protocol.
Agent routes
Section titled “Agent routes”These routes run the agent in the workspace: the Claude Code, Codex or OpenCode agent the runtime starts inside the session. They need a harness in the image and KASM_RUNTIME_AGENT=local. From your own code shows them in use.
| Method | Path | Credential | What it does |
|---|---|---|---|
GET |
/agent |
read rule | the configured harness choice and the agent’s state: state, auth, choices, conversation (fresh, resume, current_at, previous_at), start_available, terminal_available, onboarding_complete, reason, and form_choice when the launch form asked for an agent the workspace’s own settings overrode. Reading starts nothing and does not check sign-in |
POST |
/agent/start |
session, messaging or sidebar token | starts the selected harness, or reuses the one running. Body {"fresh": true} starts a fresh conversation. Accepts no command or harness override |
POST |
/agent/conversation |
session, messaging or sidebar token | starts a fresh conversation or resumes the previous one. Body {"mode": "fresh" | "resume", "intent": "<idempotency key>", "reuse_empty": false} |
POST |
/agent/terminal |
session, messaging or sidebar token | raises the agent’s terminal window, or opens it. Never starts the agent |
POST |
/agent/events |
session token only | takes the harness’s own hook events. A sidebar credential cannot submit them |
A fresh conversation requested with the messaging or sidebar token stops a busy agent first, and the message it was answering settles as stopped. The same request with the agent’s own session token is refused while the agent is answering. A reply is 409 when the agent is busy, the harness does not support the mode or nothing is started; the reply says whether anything changed.
Workspace routes
Section titled “Workspace routes”The sidebar uses these to show the workspace and to start and check playbooks. They take the session, messaging or sidebar token in the header only; a ?token= is refused.
| Method | Path | What it does |
|---|---|---|
GET |
/workspace/playbooks |
the effective playbooks (bundled, then the image’s, then the person’s own, by ID), each with available and, when false, missing. It runs nothing |
POST |
/workspace/playbooks |
saves a complete personal playbook. available and missing in the body are ignored |
DELETE |
/workspace/playbooks?id=<id> |
removes the person’s own playbook with that ID. The image’s or bundled one with the same ID returns |
POST |
/workspace/playbooks/rehearsal |
scores the recipe receipts the runtime wrote between since and until (RFC 3339, at most two hours apart) and records the run on a personal playbook. Body {id, since, until?, model?, kind?} |
GET |
/workspace/playbook-input |
checks a playbook’s file input: ?path= and ?playbook=. Reads only |
GET |
/workspace/playbook-context |
the installed and open applications, tools and browser tab host names used to suggest playbooks. No page content |
GET |
/workspace/files |
browses file names under the home folder and /tmp: at most 500 entries, no hidden or special files |
POST |
/workspace/apps/action |
starts, raises or closes an application. Body {name, action, window?}. A close asks the window to close and leaves any save prompt |
The playbook fields are on Playbooks.
Sidebar sign-in
Section titled “Sidebar sign-in”| Method | Path | Credential | What it does |
|---|---|---|---|
POST |
/sidebar/auth |
sidebar token only | the bundled sidebar confirms it has stored its token, and the runtime deletes the token file. Answers 204. See Sidebar protocol |
- MCP methods: what each
/v1/call/method does and how it fails. - Sidebar protocol: the events and inbox wire in detail.
- What the process can reach: how these credentials fit the runtime’s security model.