What you get from a session
- Exclusive access to one machine for the session’s duration (strong scheduling guarantee)
- Deterministic sequencing: “step 1 → step 2 → …” behavior with no opportunistic interleaving
- Shared state: Files and desktop state persist across runs in the same session
When to use sessions
Sessions are essential when your automation requires multiple steps that must happen on the same machine without interruption:- EHR workflows: Log into Epic, navigate to a specific patient, extract their data, then upload documents to their chart — all with no interruptions from other runs
- Financial reporting: Export monthly reports from your ERP system, transform the data in Excel, then re-import the processed results
- Document processing: Download files from a web portal, process them with a local application, then upload the results back
- Any multi-step workflow: Where state on the desktop (open applications, logged-in sessions, temporary files) must persist between steps
Chains: The easiest way to use sessions
Chains are a convenient way to create multiple runs that execute back-to-back in the same session. Instead of manually creating individual runs and managing their sequencing, you can define all your workflow steps upfront and let Cyberdesk handle the session management and execution order.Start a new session with a chain
- TypeScript
- Python
- Provide
machine_idto target a specific machine, orpool_idsto match any machine in all specified pools (intersection) - The chain always runs on one reserved session. If you omit
session_id, the API creates one and reserves a machine before step 1 starts shared_inputsare automatically filtered per workflow so each step only receives the variables it actually declaresshared_sensitive_inputsare available to all steps, whilesensitive_inputsin individual steps provide step-specific sensitive valuesshared_file_inputsare attached to the first run in the chain
Passing data between steps with refs
Once you have multiple workflows running in the same session, you’ll often want to pass outputs from earlier steps as inputs to later ones. Refs make this seamless — simply reference a previous step’s output:- TypeScript
- Python
How refs interact with input schema validation
If downstream workflows defineinput_schema, Cyberdesk validates ref usage before execution:
- For refs that target earlier steps in the same chain request, Cyberdesk checks compatibility against the producing step’s
output_schema. - For refs that target runs that already exist in the session, Cyberdesk validates alias/path/type compatibility up front using available source metadata.
- If referenced runs are queued/scheduling and don’t have output yet, creation is allowed as long as compatibility checks pass.
output_data, downstream required inputs will fail when the run executes.
For full details on validation timing, error shapes, and $-prefixed sensitive keys, see Input Validation.
Nested path access
You can access nested fields and array elements in refs:- TypeScript
- Python
Refs inside structured inputs
Refs can be used anywhere inside structured input objects. This allows you to build complex inputs by combining refs with literal values:- TypeScript
- Python
Join an existing session
If you already have a reserved session (e.g., created by a prior chain), you can reuse it:- TypeScript
- Python
session_id or machine_id/pool_ids, not both.
Keep the session alive after the chain
If you want to leave the reservation active for a follow-up chain or ad-hoc steps:- TypeScript
- Python
session_id to continue from where you left off.
Ad-hoc sessions without a chain
You don’t have to use a chain to benefit from sessions. You can start a session with a single run and then submit additional runs that reference the samesession_id. This is ideal when downstream steps depend on external conditions or when you want to decide at runtime which workflow to run next.
- TypeScript
- Python
Automatic session release
When creating individual runs in a session (not using chains), you can userelease_session_after: true to automatically release the session when that run completes (regardless of success or failure):
- TypeScript
- Python
The session is released when the run completes, whether it succeeds, fails, or is cancelled. This ensures the session doesn’t remain locked if something goes wrong.
Detecting session completion via webhooks
Therelease_session_after field on a run indicates whether this run released the session. This is useful for webhook consumers who need to know when all runs in a session are complete.
How it works:
- When you explicitly set
release_session_after: trueon a run, that field is stored - When using chains with
keep_session_after_completion: false(the default), the last run automatically getsrelease_session_after: true - If a run errors or is cancelled and causes the session to be released,
release_session_afteris set totrueon that run
For webhook endpoint setup, signature verification, retries, and local testing, see Webhooks Quickstart. The examples below assume you have already verified a
run_complete payload and want to treat a successful releasing run as the “session is done” signal.output_data, use this pattern:
run_completeis the wait signal- continue only when
run.status === "success" - continue only when
run.release_session_after === true - then list all runs in
run.session_idand aggregate their outputs
- TypeScript
- Python
Polling chain runs
The chain API returnsrun_ids in creation order. You can poll them individually, or receive a webhook when any of those runs complete:
- TypeScript
- Python
Real-world patterns
Login + Work (Exclusive)
Reserve a session, log into a thick client once, then run 5 workflows in sequence. No other jobs will touch that machine mid-sequence.Search + Process with Refs
Step 1 finds a record; Step 2 uses{$ref: 'step1.outputs.id'} to open/process; Step 3 posts results. All on the same desktop.
Download → Transform → Export
Files created by Step 1 are visible to Steps 2/3 because the session keeps the same working directory.Machine targeting
If you provide a
machine_id when creating a chain or run, pool_ids are ignored. Cyberdesk will only attempt the specified machine; if it’s busy or unavailable, the run will wait until that machine is free (no fallback to other machines or pools).Next steps
TypeScript SDK
Full TypeScript SDK reference
Python SDK
Full Python SDK reference
Webhooks
Get notified when runs complete
Workflows
Create workflows in the dashboard