backdesk Operations Reference: Arguments, Receipts and Errors
backdesk has 27 operations. They are the same over the CLI (backdesk call <op> --json '{...}') and over MCP (backdesk mcp serves each non-human operation as a tool). This page was written from the output of backdesk ops; run that command for the current list.
Shapes
Request on backdesk call --hold (one JSON object per line):
{"id":"7","op":"set_text","args":{"sessionId":"<session-id>","leaseId":"<lease-id>","hwnd":<hwnd>,"nodeId":"<node-id>","text":"Ada Lovelace"}}
Success reply:
{"id":"7","ok":true,"result":{ ... }}
Error reply. The same error object is used over MCP:
{"id":"7","ok":false,"error":{"code":"stale_observation","message":"...","retryable":true,"handoffRecommended":false,"details":{}}}
Error codes are listed on the recovery page.
Input operations (click, double_click, scroll, type_text, key, drag, invoke, set_text) return a receipt and an isolation check. This is a real receipt from the fixture workflow, trimmed:
{
"receipt": {
"operation": "type_text",
"route": "posted-message",
"target": {"hwnd": <hwnd>, "class": "WindowsForms10.Edit.app.0.1c138_r3_ad1", "title": "", "control": "id:<id>"},
"dispatched": ["WM_CHAR x10 (text length 10)"],
"activated": true,
"observed": {"frameChanged": true, "textDiff": "length 0 -> 10", "windowsOpened": [], "windowsClosed": []},
"unverified": ["app_semantics: whether the app acted on the input beyond frame and window changes"],
"durationMs": 305,
"accessibility": null
},
"isolation": {
"ok": true,
"passed": ["input_desktop_is_not_session (Default)", "target_thread_on_session_desktop", "target_valid_and_in_session_job"],
"failed": []
}
}
The receipt says what was dispatched and what changed. unverified lists what backdesk did not check: whether the app did what you meant is yours to verify, for example by reading the file it saved.
Common Arguments
Every operation accepts machineId (string): the expected machine id. A mismatch returns wrong_machine. It is left out of the tables below. backdesk doctor reports the machine id. All operations reject unknown arguments. Input operations take leaseId and, where listed, observationId: the action is rejected if the window changed since that observation.
Operations
doctor
Check whether this machine supports the backend. Sends no host input.
No arguments besides machineId.
session_start
Start an isolated session. Everything not listed in the spec is denied.
| Argument | Type | Required | Description |
|---|---|---|---|
allowedApps | array | no | Executables app_launch may start: fully qualified paths only (C:\...\app.exe); bare names and relative paths are rejected. |
readableFolders | array | no | Folders whose paths wait_for file_exists may check. |
writableFolders | array | no | Treated like readableFolders by wait_for file_exists, and nothing else. Not enforced: it does not restrict what launched apps can read or write (they run with the user's file access). |
saveCaptures | boolean | no | Persist observation PNGs under the data dir (default false). |
logText | boolean | no | Show typed text in receipts and full app_launch paths in the journal (default false: text length and file name only). |
idleSeconds | integer | no | Lease idle release (default 15). |
ttlSeconds | integer | no | Lease hard ttl (default 300). |
observationTtlSeconds | integer | no | Observation lifetime (default 30). |
settleMs | integer | no | Delay before the after-frame of a receipt (default 150). |
accessibility | string (auto, win32) | no | Control tree provider: auto (UI Automation when it works, else Win32) or win32. |
desktop | string (visible, hidden) | no | Where apps run. visible (default): on your desktop, outlined with a green glow, with a green agent pointer; input is posted to the app, never through your cursor or keyboard, and a window you are using is refused. hidden: a separate desktop you never see. |
session_list
List sessions on this machine.
No arguments besides machineId.
session_inspect
Session state, lease holder and windows.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
session_stop
Stop a session: release input, kill its processes, close its desktop.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
session_pause
Pause input on a session (held input is released).
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
session_resume
Resume a paused session.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
lease_acquire
Take the session's input lease for this connection.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
agentId | string | no | Who holds the lease. |
lease_release
Release the lease (held input is released first).
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | yes | Lease id. |
app_launch
Start an allowlisted executable inside the session. Returns {pid, path, window, windowPid}: window is the first new window of the started process, else of any session process (a launcher may start the real app), and windowPid is its owner.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | yes | Lease id. |
path | string | yes | Fully qualified executable path (must match an allowedApps entry). |
args | array | no | Arguments. |
cwd | string | no | Working directory. |
waitForWindowMs | integer | no | Wait for a first window (default 10000, 0 = no wait). |
window_list
List session windows (owned windows, dialogs, menus included); with hwnd and tree=true, the control tree.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
hwnd | integer | no | Window for the control tree. |
tree | boolean | no | Return the control tree of hwnd. |
recover_report
Actions interrupted by a daemon stop (interrupted_ambiguous; never replayed).
No arguments besides machineId.
observe
Capture a session window (window-px) or the whole session desktop (desktop-px) and record an observation.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
hwnd | integer | no | Window to capture; omit for the session desktop. |
crop | object | no | Optional {x, y, width, height} in the window's pixels. |
includeImage | boolean | no | Return the PNG (default true). |
includeTree | boolean | no | Also return the window's control tree (needs hwnd). |
wait_for
Poll until a condition holds, without a lease. condition.type: window_exists {titleRegex}, window_gone {titleRegex|hwnd}, control_text {nodeId|class, contains} (needs hwnd), file_exists {path in an allowed folder}, frame_changed {observationId}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
condition | object | yes | Condition object. |
hwnd | integer | no | Window for control_text. |
timeoutMs | integer | no | Give up after this long (default 10000). |
pollMs | integer | no | Poll interval (default 200). |
click
Click at (x, y) in the observation's coordinate space (posted mouse messages). Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | no | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
x | integer | yes | X in frame pixels. |
y | integer | yes | Y in frame pixels. |
button | string (left, right, middle) | no | Mouse button (default left). |
double_click
Double-click at (x, y) in the observation's coordinate space. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | no | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
x | integer | yes | X in frame pixels. |
y | integer | yes | Y in frame pixels. |
button | string (left, right, middle) | no | Mouse button (default left). |
scroll
Scroll at (x, y): dy > 0 scrolls up (wheel away), dx > 0 scrolls right. Units are wheel notches. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | no | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
x | integer | yes | X in frame pixels. |
y | integer | yes | Y in frame pixels. |
dx | integer | no | Horizontal notches. |
dy | integer | no | Vertical notches. |
type_text
Type text into the focused control of the target window (WM_CHAR per UTF-16 unit). Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | yes | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
text | string | yes | Text to type. |
key
Press a key with optional modifiers (ctrl, shift, alt, win) in the target window. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | yes | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
key | string | yes | Key name: a-z, 0-9, enter, tab, escape, backspace, delete, up, down, left, right, home, end, pageup, pagedown, space, f1-f12. |
modifiers | array | no | Modifier names. |
drag
Drag from (x1, y1) to (x2, y2) with interpolated moves; cancellable between steps; held input is released on any failure. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | no | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
x1 | integer | yes | Start X. |
y1 | integer | yes | Start Y. |
x2 | integer | yes | End X. |
y2 | integer | yes | End Y. |
steps | integer | no | Number of moves (default 10). |
stepDelayMs | integer | no | Delay between moves (default 10). |
button | string (left, right, middle) | no | Mouse button (default left). |
invoke
Invoke a control from the window tree (button click via the control, not coordinates). Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | yes | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
nodeId | string | yes | Node id from window_list with tree=true. |
set_text
Replace the text of an edit control from the window tree. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
leaseId | string | no | Lease id from lease_acquire on this connection. |
hwnd | integer | yes | Target window handle from window_list (when no observationId). |
observationId | string | no | Observation the coordinates refer to; the action is rejected if the window changed since. |
nodeId | string | yes | Node id from window_list with tree=true. |
text | string | yes | New text. |
handoff_request
Ask a human to take over (sign-in, payment, sensitive or confusing steps). The lease is released and input is refused with human_in_control until the human hands back. With waitSeconds the call waits for the answer: handback returns outcome handed_back, a refusal returns permission_denied, no answer in time returns approval_timeout.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
reason | string | yes | What the human should do, shown in the viewer. |
waitSeconds | integer | no | Wait this long for the human's answer (default 0: return at once). |
handback
Human: return control to the agent (ends a takeover first). Human-only operation: an agent should not call it.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
handoff_decline
Human: refuse the pending handoff request (the agent gets permission_denied). Human-only operation: an agent should not call it.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
takeover
Human: show the session desktop on this screen with a guard bar (return button, Ctrl+Alt+Backspace, timeout). Agent input is refused with human_in_control until it ends. Human-only operation: an agent should not call it.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
timeoutSeconds | integer | no | Return automatically after this long (default 120). |
dryRun | boolean | no | Run the guard without switching desktops (testing). |
takeover_end
Human: end the takeover and return to the previous desktop. Human-only operation: an agent should not call it.
| Argument | Type | Required | Description |
|---|---|---|---|
sessionId | string | yes | Session id. |
Related
Recovery and error codes, permissions and privacy, examples.