Skip to main content

Installation

Quick Start

Core Features

Lifecycle Management

Manage the sandbox lifecycle, including renewal, pausing, and resuming.

Connect to an Existing Sandbox

Use ConnectAsync when you already have a sandbox ID and need a new SDK instance bound to it.

Custom Health Check

Define custom logic to determine whether the sandbox is ready/healthy.

Command Execution & Streaming

Execute commands and handle output streams in real-time.

Background Commands

For background commands, you can poll status and incremental logs:

File Operations

Manage files and directories, including read, write, list/search, and delete.

Endpoints

GetEndpointAsync() returns an endpoint without a scheme (for example "localhost:44772"). Use GetEndpointUrlAsync() if you want a ready-to-use absolute URL.

Sandbox Management (Admin)

Use SandboxManager for administrative tasks and finding existing sandboxes.

Configuration

Connection Configuration

The ConnectionConfig class manages API server connection settings.

Diagnostics and Logging

The SDK uses Microsoft.Extensions.Logging abstractions.

Sandbox Creation Configuration

Sandbox.CreateAsync() allows configuring the sandbox environment.

Timeout and Retry Behavior

  • ConnectionConfig.RequestTimeoutSeconds controls timeout for SDK HTTP calls.
  • RunCommandOptions.TimeoutSeconds controls command execution timeout for command runs.
  • SandboxCreateOptions.TimeoutSeconds controls sandbox server-side TTL.
  • ReadyTimeoutSeconds controls how long CreateAsync / ConnectAsync waits for readiness.
  • The SDK does not automatically retry failed API requests; implement retries in caller code where appropriate.

Resource Cleanup

Both Sandbox and SandboxManager implement IAsyncDisposable. Use await using or call DisposeAsync() when done.

Error Handling

The SDK throws SandboxException (and derived exceptions such as SandboxApiException, SandboxReadyTimeoutException, and InvalidArgumentException) when operations fail.

Supported Frameworks

The SDK supports a wide range of .NET platforms:
  • .NET Standard 2.0 (for maximum compatibility with .NET Framework 4.6.1+, .NET Core 2.0+, Mono, Xamarin, etc.)
  • .NET Standard 2.1
  • .NET 6.0 (LTS)
  • .NET 7.0
  • .NET 8.0 (LTS)
  • .NET 9.0
  • .NET 10.0

API Reference

Sandbox

Main class for interacting with sandboxes.

Methods

static method
Creates and initializes a new sandbox instance.Parameters:
  • options (SandboxCreateOptions): Configuration options
Returns: Task<Sandbox>
static method
Connects to an existing sandbox by ID.Parameters:
  • options (SandboxConnectOptions): Connection options including sandbox ID
Returns: Task<Sandbox>
property
Access to command execution operations.Returns: CommandsClient
property
Access to file system operations.Returns: FilesClient
method
Extends the sandbox expiration time.Parameters:
  • timeoutSeconds (int): Extension duration in seconds
Returns: Task
method
Pauses the sandbox (suspends all processes).Returns: Task
method
Resumes this paused sandbox.Returns: Task<Sandbox>
method
Terminates the sandbox immediately.Returns: Task
method
Retrieves current sandbox information.Returns: Task<SandboxInfo>
method
Gets the external endpoint for a port (without scheme).Parameters:
  • port (int): Internal port number
Returns: Task<SandboxEndpoint>
method
Gets the full URL for a port (with scheme).Parameters:
  • port (int): Internal port number
Returns: Task<string>

Examples

Running a C# Script

Network Policy Example

Port Forwarding

Next Steps

Python SDK

Explore the Python SDK

JavaScript SDK

Explore the JavaScript/TypeScript SDK

API Reference

Detailed API documentation

Examples

Browse more code examples