Installation
- .NET CLI
- Package Manager
Quick Start
Core Features
Lifecycle Management
Manage the sandbox lifecycle, including renewal, pausing, and resuming.Connect to an Existing Sandbox
UseConnectAsync 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)
UseSandboxManager for administrative tasks and finding existing sandboxes.
Configuration
Connection Configuration
TheConnectionConfig class manages API server connection settings.
- Basic
- Advanced
Diagnostics and Logging
The SDK usesMicrosoft.Extensions.Logging abstractions.
Sandbox Creation Configuration
Sandbox.CreateAsync() allows configuring the sandbox environment.
Timeout and Retry Behavior
ConnectionConfig.RequestTimeoutSecondscontrols timeout for SDK HTTP calls.RunCommandOptions.TimeoutSecondscontrols command execution timeout for command runs.SandboxCreateOptions.TimeoutSecondscontrols sandbox server-side TTL.ReadyTimeoutSecondscontrols how longCreateAsync/ConnectAsyncwaits for readiness.- The SDK does not automatically retry failed API requests; implement retries in caller code where appropriate.
Resource Cleanup
BothSandbox and SandboxManager implement IAsyncDisposable. Use await using or call DisposeAsync() when done.
Error Handling
The SDK throwsSandboxException (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
Task<Sandbox>static method
Connects to an existing sandbox by ID.Parameters:
options(SandboxConnectOptions): Connection options including sandbox ID
Task<Sandbox>property
Access to command execution operations.Returns:
CommandsClientproperty
Access to file system operations.Returns:
FilesClientmethod
Extends the sandbox expiration time.Parameters:
timeoutSeconds(int): Extension duration in seconds
Taskmethod
Pauses the sandbox (suspends all processes).Returns:
Taskmethod
Resumes this paused sandbox.Returns:
Task<Sandbox>method
Terminates the sandbox immediately.Returns:
Taskmethod
Retrieves current sandbox information.Returns:
Task<SandboxInfo>method
Gets the external endpoint for a port (without scheme).Parameters:
port(int): Internal port number
Task<SandboxEndpoint>method
Gets the full URL for a port (with scheme).Parameters:
port(int): Internal port number
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