Creating sandboxes
Create
Creates a new Sandbox in the specified App with the given Image.Context for the operation
The App to create the Sandbox in
The Image to use for the Sandbox
Sandbox configuration options
CPU request in fractional cores
Hard CPU limit in fractional cores
Memory request in MiB
Hard memory limit in MiB
GPU configuration (e.g., “T4”, “A100:2”)
Maximum lifetime. Defaults to 5 minutes.
Idle timeout before termination
Working directory (absolute path)
Command to run on startup
Environment variables
Secrets to inject
Volume mount points
Cloud bucket mount points
Enable PTY (pseudo-terminal)
List of encrypted ports to tunnel (TLS)
List of HTTP/2 ports to tunnel
List of unencrypted ports to tunnel
Block all network access
Allowed CIDR ranges (cannot be used with BlockNetwork)
Cloud provider
Preferred regions
Enable verbose logging
Modal Proxy to use
Optional name (unique within the App)
Custom domain for connections (Enterprise only)
*Sandbox- The created Sandboxerror- Error if creation fails
FromID
References a running Sandbox by its ID.Context for the operation
The Sandbox ID
*Sandbox- The Sandbox instanceerror- NotFoundError if the Sandbox doesn’t exist
FromName
References a running Sandbox by name.Context for the operation
The App name
The Sandbox name
*Sandbox- The Sandbox instanceerror- NotFoundError if the Sandbox doesn’t exist
List
Lists Sandboxes, optionally filtered by App or tags.Context for the operation
iter.Seq2[*Sandbox, error]- Iterator over Sandboxeserror- Error if the request fails
Sandbox methods
Exec
Executes a command in the Sandbox and returns a ContainerProcess.Context for the operation
Command and arguments to execute
Execution options
“pipe” or “ignore” (default: “pipe”)
“pipe” or “ignore” (default: “pipe”)
Working directory for the command
Execution timeout
Environment variables
Secrets to inject
Enable PTY
*ContainerProcess- Handle to the running processStdin(io.WriteCloser) - Standard inputStdout(io.ReadCloser) - Standard outputStderr(io.ReadCloser) - Standard errorWait(ctx)(int, error) - Wait for process to complete
error- Error if execution fails
Terminate
Stops the Sandbox.Context for the operation
Termination options
Wait for the Sandbox to exit and return exit code
int- Exit code (if Wait is true)error- Error if termination fails
Wait
Blocks until the Sandbox exits.Context for the operation
int- Exit codeerror- Error if waiting fails
Poll
Checks if the Sandbox has finished running.Context for the operation
*int- Exit code if finished, nil if still runningerror- Error if the request fails
Tunnels
Gets tunnel metadata for the Sandbox’s exposed ports.Context for the operation
Timeout to wait for tunnels to be ready
map[int]*Tunnel- Map of container port to TunnelHost(string) - Public hostnamePort(int) - Public portURL()(string) - HTTPS URLTLSSocket()(string, int) - TLS socketTCPSocket()(string, int, error) - TCP socket
error- SandboxTimeoutError if tunnels aren’t ready
SnapshotFilesystem
Snapshots the Sandbox’s filesystem to an Image.Context for the operation
Timeout for the snapshot operation
*Image- The snapshot Imageerror- Error if snapshot fails
Detach
Disconnects from the Sandbox, cleaning up local resources.error- Error if detachment fails