Skip to content

SandboxesClient

Source: src/services/sandboxes.ts

SandboxesClient(transport: Leap0Transport)

Creates, fetches, pauses, and deletes sandboxes.

  • Leap0Error: If request validation, API calls, or response validation fail.
async create(params: CreateSandboxParams = {}, options: RequestOptions = {}): Promise<T>

Creates a sandbox from a template and resource config.

  • params: Sandbox creation parameters.
  • options: Optional request settings such as timeout and query params.
  • The created sandbox resource.
  • Leap0Error: If params are invalid, local OTEL env is missing, or sandbox creation fails.
const sandbox = await client.sandboxes.create({
templateName: "base",
timeoutMin: 30,
});
async pause(sandbox: SandboxRef, options: RequestOptions = {}): Promise<T>

Pauses a running sandbox.

  • sandbox: Sandbox ID or sandbox-like object.
  • options: Optional request settings such as timeout and query params.
  • The updated sandbox resource.
async get(sandbox: SandboxRef, options: RequestOptions = {}): Promise<T>

Fetches a sandbox by ID.

  • sandbox: Sandbox ID or sandbox-like object.
  • options: Optional request settings such as timeout and query params.
  • The current sandbox resource.
async delete(sandbox: SandboxRef, options: RequestOptions = {}): Promise<void>

Deletes a sandbox by ID.

  • sandbox: Sandbox ID or sandbox-like object.
  • options: Optional request settings such as timeout and query params.
invokeUrl(sandbox: SandboxRef, path = "/", port?: number): string

Builds the public invoke URL for a sandbox.

  • sandbox: Sandbox ID or sandbox-like object.
  • path: Route path to append to the sandbox base URL.
  • port: Optional forwarded port.
  • The public HTTPS URL for the sandbox.
websocketUrl(sandbox: SandboxRef, path = "/", port?: number): string

Builds the public websocket URL for a sandbox.

  • sandbox: Sandbox ID or sandbox-like object.
  • path: Route path to append to the sandbox base URL.
  • port: Optional forwarded port.
  • The public websocket URL for the sandbox.