Quick Start
Get up and running with Cyberdesk in under 5 minutes. This guide assumes you’ve already created workflows in the Cyberdesk Dashboard.1
Install the SDK
2
Initialize the client and create a run
We recommend creating and managing workflows through the Cyberdesk Dashboard. The dashboard editor supports rich, multimodal prompts — you can add screenshots or UI snippets directly into your prompt to guide the agent. The SDK is optimized for executing runs against your existing workflows.
Installation & Setup
Prerequisites
- Node.js 18+ or another runtime with
fetchsupport - TypeScript 4.0 or higher (for TypeScript projects)
Installation
- npm
- yarn
- pnpm
TypeScript Configuration
The SDK includes TypeScript definitions out of the box. For the best experience, ensure yourtsconfig.json includes:
tsconfig.json
Authentication
Creating a Client
Custom Base URL
For self-hosted or enterprise deployments:Automatic Retries
The SDK automatically retries failed requests with exponential backoff, following industry best practices similar to the Stripe SDK. This handles transient network issues and server errors gracefully without requiring any code changes.Default Behavior
- Retry count: 3 retries (4 total attempts)
- Retryable errors: Network failures, fetch errors, connection timeouts
- Retryable status codes: 408, 429, 500, 502, 503, 504, and
409when the API returnsIdempotency-Status: in_progress - Non-retryable: 4xx client errors (except 408, 409, 429)
- Backoff strategy: Exponential backoff with full jitter (250ms initial, 8s max)
- Retry-After header: Respected when present
Configuring Retries
Retries only occur for network-level failures and specific HTTP status codes that indicate temporary server issues. Client errors (4xx) are not retried because they indicate a problem with the request itself.
Idempotency
For write requests (POST, PUT, PATCH, DELETE), the SDK automatically adds anIdempotency-Key header. This ensures that if a request is retried due to a network timeout or server error, it won’t be processed twice — you’ll get the same response as the original request.
Default Behavior
- Enabled by default: All write requests automatically include an idempotency key
- Key generation: Uses
crypto.randomUUID()(with fallback for older environments) - Server-side handling: The API stores the response and replays it for duplicate keys
Configuring Idempotency
Working with Runs
Runs are the primary way to execute workflows in Cyberdesk. Here’s everything you need to know about managing runs through the SDK.Creating a Run
Prioritizing a Run
Setis_priority: true when a run should be matched before normal queued runs:
false. Bulk creation and chain creation also accept is_priority; one value applies to every run created by that request. Priority affects the next eligible machine assignment only—it does not interrupt running work or let a later run bypass an earlier run in the same session or chain. In-place retries keep the run’s existing priority unless the retry request supplies an is_priority override.
Priority runs are processed before normal runs. A sustained stream of priority work can delay normal queued runs.
Creating a Run with Sensitive Input Values
If your workflow prompt references sensitive variables using the{$variable} syntax (for example, {$password}), you can pass those values separately via sensitive_input_values.
Sensitive inputs are stored in a secure third‑party secret vault (Basis Theory) only for the duration of the run. They are not logged in Cyberdesk, and they are not sent to any LLMs. The values are only resolved at the last moment during actual computer actions (e.g., when typing). After the run completes, these sensitive values are deleted from the vault. On the dashboard, sensitive inputs are never displayed and will not be prefilled when repeating a run.
Creating a Run with Machine Pools
You can specify pool requirements when creating a run. This ensures your run is executed on a machine that belongs to ALL specified pools. This is especially useful for:- Running workflows on customer-specific machines
- Requiring machines with specific software installed
- Organizing machines by location or capability
Pool Matching Logic: When you specify multiple pools, Cyberdesk will only select machines that belong to ALL specified pools (intersection). For example, if you specify
["Customer A", "Has Excel"], only machines that are in both pools will be considered.If you provide a
machine_id when creating a 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).Creating a Run with File Inputs
You can attach files to a run at creation. This is useful for workflows that need to process or manipulate files on the remote machine.string
required
The name of the file, including its extension.
string
required
The base64-encoded content of the file.
string
The absolute path on the remote machine where the file should be saved. If not provided, it defaults to
~/CyberdeskTransfers/.boolean
If
true, the file will be deleted from the remote machine after the run completes (whether it succeeds or fails). Defaults to false.Listing Runs
Faster lists with fields projection
Return only selected fields using the
fields option. This avoids large payloads (like run_message_history) and speeds up responses.Need to fetch screenshots referenced in
run_message_history? See Run Screenshots for signed URL examples.- Base fields always included:
id,workflow_id,machine_id,status,created_at. - Add more by passing the
fieldsarray.
Getting a Specific Run
Updating a Run
Run updates are typically handled automatically by the Cyberdesk system. Manual updates are rarely needed.
Deleting a Run
Retrying a Run (same run_id)
Use retry when you want to re-run the exact same run id, clearing outputs and optionally providing fresh inputs/files. Sensitive values: always re-sendsensitive_input_values on retry; secrets are deleted after each run.
File inputs: if you set cleanup_imports_after_run, files are deleted from the remote machine after the run; include file_inputs again if you need a fresh copy or when no input attachments exist (providing file_inputs replaces prior input attachments).
Regular inputs: only send input_values if you want to change them; otherwise the previous ones are reused.
Behavior:
- Retry is allowed only for terminal runs:
success,task_failed,error, orcancelled. - Outputs, history, and output attachments are always cleared.
- Prior input attachments are kept unless you provide
file_inputs(then they are replaced). - If you provide
sensitive_input_values, new secrets are created; otherwise sensitive aliases are cleared. - When a
session_idis present and the session is busy, immediate assignment is skipped and the retried run queues. - When
machine_idis provided,pool_idsare ignored.
Polling for Run Completion
Here’s a robust pattern for waiting for runs to complete:Working with File Attachments
Manage files associated with your runs, such as input files uploaded at creation or output files generated by a workflow.Listing Run Attachments
You can list all attachments for a specific run and filter them by type (input or output).
Downloading an Attachment
There are two ways to download attachments depending on your use case:Method 1: Get a Download URL
Get a signed URL that triggers automatic download when accessed. Perfect for web applications where you want to provide download links to users.Method 2: Download Raw File Content
Download the file content directly. The SDK will return the raw data which you can then save to a file or process further.Example: Upload, Process, and Download
Here’s a full example of a workflow that processes a file.- Workflow Prompt:
"Take the file at ~/CyberdeskTransfers/report.txt, add a summary to the end of it, and mark it for export." - Workflow Setting:
includes_file_exportsis set totrue.
Bulk Creating Runs with Pools
When creating multiple runs in bulk, you can also specify pool requirements. All runs will be distributed across machines that match the pool criteria.Bulk Run Assignment: When bulk creating runs with pool requirements, Cyberdesk attempts to assign each run to any available machine that meets the pool criteria. If no matching machine is available, runs remain in scheduling until one is free. No specific load balancing guarantees are made.
Sessions and Chained Runs
At its core, a session is a reservation of a single machine. While a session is active, that machine is dedicated to your session only — no unrelated runs will be scheduled onto it. This guarantees your multi‑step automations run back‑to‑back on the same desktop without interference. What you get from a session:- Exclusive access to one machine for the session’s duration (strong scheduling guarantee)
- Deterministic “step 1 → step 2 → …” behavior with no opportunistic interleaving
Real‑world cases that require sessions
- 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 miscellaneous runs.
- Financial reporting: Export monthly reports from your ERP system, transform the data in Excel, then re‑import the processed results — all back‑to‑back without interference.
- Document processing: Download files from a web portal, process them with a local application, then upload the results back — ensuring no other runs interfere with your workflow.
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 using a JSON object:RefValue (exported), but a plain object with a top‑level $ref string also works. The path on the right points to a prior step’s output field.
Start a new session and run a chain (best when you know the whole sequence)
- Provide
machine_idto target a specific machine, orpool_idsto let Cyberdesk choose any machine that belongs to all specified pools (intersection). - The chain always runs on one reserved session. If you omit
session_id, the API creates one for you and reserves a machine before step 1 starts. shared_inputsare automatically filtered per workflow so each step only receives the variables it actually declares.shared_sensitive_inputsare available to all steps, whilesensitive_inputsin individual steps provide step-specific sensitive values.shared_file_inputsare attached to the first run in the chain.
Join an existing session
If you already have a reserved session (e.g., created by a prior chain), you can reuse it:machine_id/pool_ids are ignored when session_id is provided.
Keep the session alive after the chain
If you want to leave the reservation active for a follow‑up chain or ad‑hoc steps:session_id to continue from where you left off.
Ad‑hoc sessions without a chain (start with a single run, then add more)
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.
Automatic session release with release_session_after
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):
Detecting session completion via webhooks
Therelease_session_after field on a run indicates whether this run released the session. You can use this in your webhook handler to detect when all runs in a session are complete:
true when:
- You explicitly set
release_session_after: trueon a run - A chain completes with
keep_session_after_completion: false(the last run gets this flag) - A run errors or is cancelled and causes the session to be released
Polling chain runs
The chain API returns run_ids in creation order; you can poll them individually, or receive a webhook when any of those runs completeReal‑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.
If you provide a
machine_id in a bulk run request, pool_ids are ignored for those runs. Each run will only target the specified machine; if it is busy, the run will wait for that machine rather than falling back to other machines or pools.Real-World Example: Healthcare Integration
Here’s a complete example of retrieving patient data from an Epic EHR system using Cyberdesk:Other SDK Resources
Pools
Pools
Machines
Machines
Workflows
Workflows
Workflow Prompt Images
Workflow Prompt Images
Upload and manage images for use in workflow prompts. The returned
supabase_url can be embedded directly in workflow prompt HTML.Using prompt images in workflows: After uploading, copy the Cyberdesk automatically resolves these URLs when running workflows, displaying the images to the AI agent.
supabase_url and use it in your workflow’s main_prompt HTML:Connections
Connections
Trajectories
Trajectories
Workflow Tag Groups
Workflow Tag Groups
Group tags for organization and mutual exclusivity. Only one tag from a group can be assigned to a workflow at a time.
Model Configurations
Model Configurations
Usage
Usage
Error Handling
All SDK methods return an object withdata and error properties:
Common Error Types
object
Invalid input parameters
object
Invalid or missing API key
object
Too many requests
TypeScript Types
The SDK exports all types for better IDE support:Best Practices
Use Environment Variables
Store API keys and workflow IDs in environment variables, never in code.
Built-in Retry Logic
The SDK automatically retries on transient failures with exponential backoff. Adjust
maxRetries if needed.Handle Timeouts
Set reasonable timeouts for run completion based on your workflow complexity.
Log Everything
Keep detailed logs of run IDs and statuses for debugging and audit trails.
Next Steps
API Reference
Explore the complete API documentation
Dashboard
Create and manage workflows in the dashboard
Examples
Browse more code examples and use cases