Desktop sessions and tickets
A desktop session lives on a machine that provides a desktop. Create it with the machine id; it allows one live session per machine. Then your backend mints a single-use, origin-bound watch ticket that expires in 15–120 seconds, so a browser never holds your API key:ticket object:
ws_url with Sec-WebSocket-Protocol: bma.desktop.v1, bma.ticket.<ticket> from the same Origin. The URL never contains the ticket, and the ticket works once. When it expires or is used, mint a new one.
Control
Control is enforced by the server: while a person holds control, the agent’s desktop actions are rejected. After a release or hand-back the agent re-observes the screen before continuing.
Terminal sessions
Terminal sessions work the same way:POST /v1/terminal_sessions with {"machine_id": "mch_..."} (optional shell, cwd, cols, rows), then POST /v1/terminal_sessions/{id}/tickets for a single-use connect ticket and a WebSocket attach with resumable output; POST /v1/terminal_sessions/{id}/close ends it. See Anthropic SDKs for a runnable example.