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

Create and manage workflows in the Cyberdesk Dashboard. The dashboard supports rich, multimodal prompts — you can insert images alongside text to help the agent understand tricky UI elements. Use the SDK to execute runs against those workflows.

Installation & Setup

Prerequisites

  • Python 3.10 or higher
  • pip, poetry, or pipenv for package management

Installation

Virtual Environment Setup

Always use a virtual environment to avoid dependency conflicts:

Authentication

Creating a Client

Custom Base URL

For self-hosted or enterprise deployments:

Using Context Managers

The client supports standard context managers for proper resource cleanup:
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, connection timeouts, DNS errors
  • Retryable status codes: 408, 429, 500, 502, 503, 504, and 409 only when Idempotency-Status: in_progress
  • Non-retryable: Most 4xx client errors
  • 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. Most 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. If a completed request is retried with the same key, the API replays the stored response. If the original request is still in progress, the API returns 409 with Retry-After. 5xx responses are not replay-cached, so a later retry with the same key may execute again.

Default Behavior

  • Enabled by default: All write requests automatically include an idempotency key
  • Key generation: Uses uuid.uuid4() to generate unique keys
  • Server-side handling: Completed responses are replayed for duplicate keys; in-progress duplicates return 409

Configuring Idempotency

You generally don’t need to configure idempotency — the defaults work well. The SDK handles everything automatically, making completed write retries safe without extra plumbing in your app.

Sync vs Async

The Cyberdesk Python SDK provides both synchronous and asynchronous methods for all operations.

When to Use Async

Use async methods when:
  • Building web applications with async frameworks (FastAPI, aiohttp)
  • Making multiple concurrent API calls
  • Integrating with other async libraries
  • Building high-performance applications

When to Use Sync

Use sync methods when:
  • Writing simple scripts
  • Working in Jupyter notebooks
  • Integrating with sync-only frameworks (Django, Flask)
  • Learning or prototyping

Method Naming Convention

  • Async methods: client.resource.method()
  • Sync methods: client.resource.method_sync()

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. RunBulkCreate and WorkflowChainCreate 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}), pass those values 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

Use the optional fields parameter to return only selected fields per run. This reduces payload size and speeds up listing, especially when you do not need heavy JSON fields like run_message_history.
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 fields=[...].
If you need full records (including run_message_history), call list() without fields.

Getting a Specific Run

Updating a Run

Run updates are typically handled automatically by the Cyberdesk system. Manual updates are rarely needed.

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=True, 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.
  • Avoid sending both machine_id and pool_ids on retry; if both are present, pool_ids take precedence.

Deleting a Run

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 multiple 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. This is perfect for web applications where you want to provide download links to users.

Method 2: Download Raw File Content

Download the file content directly as bytes. Useful when you need to process the file in memory.

Method 3: Save to File (Convenience Method)

The SDK provides a convenience method that downloads and saves the file in one operation.

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.

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.

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:
You can construct these as plain Python dicts when building chain steps.

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 match any machine in all specified pools (intersection).
  • The chain runs on one reserved session. If you omit session_id, the API creates one and reserves a machine before step 1.
  • shared_inputs are merged into each step, and step-level inputs override shared values when the same key appears in both places.
  • shared_sensitive_inputs are available to all steps in the chain.
  • sensitive_inputs in individual steps provide step-specific sensitive values that override or extend the shared ones. If the same key exists in both, the step-specific value takes precedence.
  • shared_file_inputs (if provided) are attached to the first run in the chain.

Join an existing session

For chains, provide either session_id or machine_id/pool_ids, not both.

Keep the session alive after the chain

Later you can start another chain with session_id to continue work on the same machine.

Ad‑hoc sessions without a chain (start with a single run, then add more)

You can start a session with a normal run and then submit additional runs referencing the same session_id — useful when downstream steps are conditional or discovered at runtime.

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, task-fails, 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 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.

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.
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.
Bulk Run Assignment: When bulk creating runs with pool requirements, Cyberdesk attempts to assign each run to any available machine that meets all specified pools. If no matching machine is available, runs remain in scheduling until one is free. No specific load balancing guarantees are made.

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 ApiResponse object with data and error attributes:

Common Error Types

  • Unexpected HTTP status / transport errors: surfaced in response.error as exceptions. For HTTP failures, check getattr(response.error, "status_code", None).
  • Validation errors (422): returned in response.data.detail, not response.error.
  • Successful responses: returned in response.data.

Exception Handling Pattern

Type Hints and IDE Support

The SDK provides comprehensive type hints for better IDE support:

Working with Jupyter Notebooks

The SDK works seamlessly in Jupyter notebooks:

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 retry=RetryConfig(...) 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.

Use Type Hints

Leverage type hints for better IDE support and fewer runtime errors.

Close Connections

Use context managers or explicitly close clients to free resources.

Performance Optimization

Concurrent Operations

When working with multiple operations, use asyncio for better performance:

Connection Pooling

The SDK automatically manages connection pooling for optimal performance. No additional configuration is needed.

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