Skip to content
View as Markdown

Daytona

Main class for interacting with the Daytona API.

Provides methods to create, retrieve, and list Sandboxes, and exposes service accessors for Snapshots and Volumes.

Implements AutoCloseable for deterministic HTTP resource cleanup.

Constructors

new Daytona()

public Daytona()

Creates a client using environment variables.

Reads DAYTONA_API_KEY, DAYTONA_API_URL, and DAYTONA_TARGET.

Throws:

  • DaytonaException - if required authentication is missing

new Daytona()

public Daytona(DaytonaConfig config)

Creates a client with explicit configuration.

Parameters:

  • config DaytonaConfig - SDK configuration containing API key and endpoint settings

Throws:

  • DaytonaException - if configuration is invalid or missing credentials

Methods

create()

public Sandbox create()

Creates a Sandbox with default parameters and timeout.

Returns:

  • Sandbox - created and started Sandbox

Throws:

  • DaytonaException - if creation or startup fails

create()

public Sandbox create(CreateSandboxFromSnapshotParams params)

Creates a Sandbox from snapshot-oriented parameters using default timeout.

Parameters:

  • params CreateSandboxFromSnapshotParams - snapshot creation parameters

Returns:

  • Sandbox - created and started Sandbox

Throws:

  • DaytonaException - if creation or startup fails

create()

public Sandbox create(CreateSandboxFromImageParams params)

Creates a Sandbox from image-oriented parameters using default timeout.

Parameters:

  • params CreateSandboxFromImageParams - image creation parameters

Returns:

  • Sandbox - created and started Sandbox

Throws:

  • DaytonaException - if creation or startup fails

create()

public Sandbox create(CreateSandboxFromSnapshotParams params, long timeoutSeconds)

Creates a Sandbox from snapshot parameters.

Parameters:

  • params CreateSandboxFromSnapshotParams - snapshot creation parameters including env vars, labels, and lifecycle options
  • timeoutSeconds long - maximum seconds to wait for the Sandbox to reach started

Returns:

  • Sandbox - created and started Sandbox

Throws:

  • DaytonaException - if creation fails or the Sandbox does not start in time

create()

public Sandbox create(CreateSandboxFromImageParams params, long timeoutSeconds)

Creates a Sandbox from image parameters.

Parameters:

  • params CreateSandboxFromImageParams - image creation parameters including image source and optional resources
  • timeoutSeconds long - maximum seconds to wait for the Sandbox to reach started

Returns:

  • Sandbox - created and started Sandbox

Throws:

  • DaytonaException - if creation fails or the Sandbox does not start in time

create()

public Sandbox create(CreateSandboxFromImageParams params, long timeoutSeconds, java.util.function.Consumer<String> onSnapshotCreateLogs)

Creates a new Sandbox from a declarative image with build log streaming.

Parameters:

  • params CreateSandboxFromImageParams - creation parameters including the image definition
  • timeoutSeconds long - maximum seconds to wait for the Sandbox to reach started
  • onSnapshotCreateLogs java.util.function.Consumer<String> - callback for build log lines; null to skip streaming

Returns:

  • Sandbox - created and started Sandbox

Throws:

  • DaytonaException - if creation fails or the Sandbox does not start in time

get()

public Sandbox get(String sandboxIdOrName)

Retrieves a Sandbox by ID or name.

Parameters:

  • sandboxIdOrName String - Sandbox identifier or name

Returns:

  • Sandbox - resolved Sandbox

Throws:

  • DaytonaException - if the Sandbox is not found or request fails

list()

public PaginatedSandboxes list()

Lists Sandboxes using default pagination.

Returns:

  • PaginatedSandboxes - first page of Sandboxes with default page size

Throws:

  • DaytonaException - if listing fails

list()

public PaginatedSandboxes list(Map<String, String> labels, Integer page, Integer limit)

Lists Sandboxes with optional label filtering and pagination.

Parameters:

  • labels Map<String, String> - label filter map; only Sandboxes with matching labels are returned
  • page Integer - page number starting from 1
  • limit Integer - maximum items per page

Returns:

  • PaginatedSandboxes - paginated Sandbox list

Throws:

  • DaytonaException - if listing fails

snapshot()

public SnapshotService snapshot()

Returns Snapshot management service.

Returns:

  • SnapshotService - snapshot service instance

volume()

public VolumeService volume()

Returns Volume management service.

Returns:

  • VolumeService - volume service instance

close()

public void close()

Closes this client and releases underlying HTTP resources.