Skip to main content

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 fetch support
  • TypeScript 4.0 or higher (for TypeScript projects)

Installation

TypeScript Configuration

The SDK includes TypeScript definitions out of the box. For the best experience, ensure your tsconfig.json includes:
tsconfig.json

Authentication

Creating a Client

Custom Base URL

For self-hosted or enterprise deployments:
Never hardcode API keys in your source code. Use environment variables:

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 409 when the API returns Idempotency-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 an Idempotency-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

You generally don’t need to configure idempotency — the defaults work well. The SDK handles everything automatically, making retries safe even for operations that create resources.

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

Pass nested objects and access them in prompts with dot notation like {insurance.provider}. See Structured Inputs.

Prioritizing a Run

Set is_priority: true when a run should be matched before normal queued runs:
The field defaults to 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.
See Priority Runs for complete matching, session-ordering, and retry semantics.

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 and Managing Pools: While you can manage pools via the SDK, we recommend using the Cyberdesk Dashboard for a more intuitive experience:
  1. Navigate to any machine in the dashboard
  2. Click on the machine to view its details
  3. Add the machine to existing pools or create new pools
  4. Assign multiple pools to organize machines by customer, capability, or location
Common pool strategies:
  • By Customer: “Customer A”, “Customer B”, etc.
  • By Software: “Has Excel”, “Has Chrome”, “Has Epic EHR”
  • By Environment: “Production”, “Staging”, “Development”
  • By Location: “US-East”, “EU-West”, etc.

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 fields array.

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-send sensitive_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, or cancelled.
  • 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_id is present and the session is busy, immediate assignment is skipped and the retried run queues.
  • When machine_id is provided, pool_ids are 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.
  1. Workflow Prompt: "Take the file at ~/CyberdeskTransfers/report.txt, add a summary to the end of it, and mark it for export."
  2. Workflow Setting: includes_file_exports is set to true.
This example demonstrates the complete lifecycle: uploading a file with a run, executing a workflow that modifies it, and then retrieving the processed file from the run’s output attachments.

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
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.

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:
The SDK type for this shape is 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)

Notes:
  • Provide machine_id to target a specific machine, or pool_ids to 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_inputs are automatically filtered per workflow so each step only receives the variables it actually declares.
  • shared_sensitive_inputs are available to all steps, while sensitive_inputs in individual steps provide step-specific sensitive values.
  • shared_file_inputs are 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:
This keeps the same reserved machine and any state/files already present on 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:
Later, you can start a new chain with that 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 same session_id.
This approach is ideal when the next steps depend on external conditions (e.g., decide at runtime which workflow to run next) or when you want to keep the session open for a while and feed runs one at a time.

Automatic session release with release_session_after

When creating individual runs in a session (not using chains), you can use release_session_after: true to automatically release the session when that run completes (regardless of success or failure):
This is useful mainly as a convenience, so you don’t have to decouple creating a session ending run and actually ending the session. Note: 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

The release_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:
This field is automatically set to true when:
  • You explicitly set release_session_after: true on 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
See Detecting session completion via webhooks for more details.

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 complete

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.
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

Important: While the SDK provides full CRUD operations for all Cyberdesk resources, we strongly recommend using the Cyberdesk Dashboard for managing these resources. The dashboard provides a more intuitive interface for:
  • Creating and editing workflows
  • Managing machines
  • Viewing connections
  • Analyzing trajectories
The SDK methods below are provided for advanced use cases and automation scenarios.
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 supabase_url and use it in your workflow’s main_prompt HTML:
Cyberdesk automatically resolves these URLs when running workflows, displaying the images to the AI agent.
Organize your workflows with tags. Tags support emojis, colors, and optional grouping for mutual exclusivity.
Mutual Exclusivity: When a tag belongs to a group, adding it to a workflow automatically removes any other tag from the same group. This is useful for status-like tags (e.g., “Draft” vs “Published”).
Group tags for organization and mutual exclusivity. Only one tag from a group can be assigned to a workflow at a time.
See Usage-Based Billing for more details.

Error Handling

All SDK methods return an object with data 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