apps/docs/src/content/docs/en/java-sdk/sandbox.mdx
Represents a Daytona Sandbox instance.
Exposes lifecycle controls and operation facades for process execution, file-system access, and Git.
Properties:
process Process - Process execution interface for this Sandbox.fs FileSystem - File-system operations interface for this Sandbox.git Git - Git operations interface for this Sandbox.computerUse ComputerUse - Computer use (desktop automation) interface for this Sandbox.codeInterpreter CodeInterpreter - Stateful code interpreter for this Sandbox (Python).public LspServer createLspServer(String languageId, String pathToProject)
Creates an LSP server instance for the specified language and project.
Parameters:
languageId String - language server to start (e.g. "typescript", "python", "go")pathToProject String - absolute path to the project root inside the sandboxReturns:
LspServer - a new LspServer configured for the given languagepublic void start()
Starts this Sandbox with default timeout.
Throws:
DaytonaException - if the Sandbox fails to startpublic void start(long timeoutSeconds)
Starts this Sandbox and waits for readiness.
Parameters:
timeoutSeconds long - maximum seconds to wait; 0 disables timeoutThrows:
DaytonaException - if start fails or times outpublic void stop()
Stops this Sandbox with default timeout.
Throws:
DaytonaException - if the Sandbox fails to stoppublic void stop(long timeoutSeconds)
Stops this Sandbox and waits until fully stopped.
Parameters:
timeoutSeconds long - maximum seconds to wait; 0 disables timeoutThrows:
DaytonaException - if stop fails or times outpublic void waitUntilStopped(long timeoutSeconds)
Waits until Sandbox reaches stopped (or destroyed) state.
Parameters:
timeoutSeconds long - maximum seconds to wait; 0 disables timeoutThrows:
DaytonaException - if timeout is invalid, state becomes error, or timeout expirespublic void delete()
Deletes this Sandbox with default timeout behavior.
Throws:
DaytonaException - if deletion failspublic void delete(long timeoutSeconds)
Deletes this Sandbox.
Parameters:
timeoutSeconds long - reserved timeout parameter for parity with other SDKsThrows:
DaytonaException - if deletion failspublic Map<String, String> setLabels(Map<String, String> labels)
Replaces Sandbox labels.
Parameters:
labels Map<String, String> - label map to applyReturns:
Map\<String, String\> - updated labelsThrows:
DaytonaException - if label update failspublic void setAutostopInterval(int minutes)
Sets Sandbox auto-stop interval.
Parameters:
minutes int - idle minutes before automatic stopThrows:
DaytonaException - if the update failspublic void setAutoArchiveInterval(int minutes)
Sets Sandbox auto-archive interval.
Parameters:
minutes int - minutes in stopped state before automatic archiveThrows:
DaytonaException - if the update failspublic void setAutoDeleteInterval(int minutes)
Sets Sandbox auto-delete interval.
Parameters:
minutes int - minutes before automatic deletion after stopThrows:
DaytonaException - if the update failspublic void updateNetworkSettings(UpdateSandboxNetworkSettings settings)
Updates outbound network policy on the runner (block all, restore access, or CIDR allow list).
Parameters:
settings UpdateSandboxNetworkSettings - request body; at least one of networkBlockAll or networkAllowList must be setThrows:
DaytonaException - if the update failspublic String getUserHomeDir()
Returns home directory path for Sandbox user.
Returns:
String - absolute home directory pathThrows:
DaytonaException - if the request failspublic String getWorkDir()
Returns current working directory path.
Returns:
String - absolute working directory pathThrows:
DaytonaException - if the request failspublic void waitUntilStarted(long timeoutSeconds)
Waits until Sandbox reaches started state.
Parameters:
timeoutSeconds long - maximum seconds to wait; 0 disables timeoutThrows:
DaytonaException - if timeout is invalid, state becomes failure, or timeout expirespublic void refreshData()
Refreshes local Sandbox fields from latest API state. After refresh, all fields
— including those not returned by Daytona#list — are populated.
Throws:
DaytonaException - if refresh failspublic Sandbox experimentalFork()
Forks this Sandbox, creating a new Sandbox with an identical filesystem. Uses default timeout of 60 seconds.
Returns:
Sandbox - the forked Sandbox in started stateThrows:
DaytonaException - if the fork operation fails or times outpublic Sandbox experimentalFork(String name, long timeoutSeconds)
Forks this Sandbox, creating a new Sandbox with an identical filesystem. The forked Sandbox is a copy-on-write clone of the original.
Parameters:
name String - optional name for the forked Sandbox; null for auto-generatedtimeoutSeconds long - maximum seconds to wait for the forked Sandbox to start; 0 disables timeoutReturns:
Sandbox - the forked Sandbox in started stateThrows:
DaytonaException - if the fork operation fails or times outpublic void experimentalCreateSnapshot(String name)
Creates a snapshot from the current state of this Sandbox. Uses default timeout of 60 seconds.
Parameters:
name String - name for the new snapshotThrows:
DaytonaException - if the snapshot operation failspublic void experimentalCreateSnapshot(String name, long timeoutSeconds)
Creates a snapshot from the current state of this Sandbox. The Sandbox will temporarily enter a 'snapshotting' state and return to its previous state when complete.
Parameters:
name String - name for the new snapshottimeoutSeconds long - reserved timeout parameter for parity with other SDKsThrows:
DaytonaException - if the snapshot operation failspublic String getId()
Returns:
String - Sandbox ID.public String getName()
Returns:
String - Sandbox name.public String getOrganizationId()
Returns:
String - organization ID that owns this Sandbox.public String getSnapshot()
Returns:
String - Daytona snapshot used to create this Sandbox, or null if none.public String getUser()
Returns:
String - OS user running in the Sandbox.public Map<String, String> getLabels()
Returns:
Map\<String, String\> - custom labels attached to the Sandbox.public Boolean getPublic()
Returns:
Boolean - whether the Sandbox HTTP preview is publicly accessible.public String getTarget()
Returns:
String - target region/environment where the Sandbox runs.public int getCpu()
Returns:
int - allocated CPU cores.public int getGpu()
Returns:
int - allocated GPU units.public int getMemory()
Returns:
int - allocated memory in GiB.public int getDisk()
Returns:
int - allocated disk in GiB.public String getState()
Returns:
String - current lifecycle state (e.g. "started", "stopped").public String getErrorReason()
Returns:
String - error message if the Sandbox is in an error state, or null.public Boolean getRecoverable()
Returns:
Boolean - whether the Sandbox error is recoverable, or null if unknown.public String getBackupState()
Returns:
String - current state of the Sandbox backup as a string, or null.public Integer getAutoStopInterval()
Returns:
Integer - auto-stop interval in minutes (0 means disabled).public Integer getAutoArchiveInterval()
Returns:
Integer - auto-archive interval in minutes.public Integer getAutoDeleteInterval()
Returns:
Integer - auto-delete interval in minutes (negative means disabled).public String getCreatedAt()
Returns:
String - when the Sandbox was created, or null.public String getUpdatedAt()
Returns:
String - when the Sandbox was last updated, or null.public String getLastActivityAt()
Returns:
String - when the Sandbox last had activity, or null.public String getToolboxProxyUrl()
Returns:
String - toolbox proxy URL.public Map<String, String> getEnv()
Returns Sandbox environment variables.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
Map\<String, String\> - environment map, or null if not yet populatedpublic Boolean getNetworkBlockAll()
Returns whether all network access is blocked for this Sandbox.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
Boolean - block-all flag, or null if not yet populatedpublic String getNetworkAllowList()
Returns the comma-separated CIDR allow list, if any.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
String - allow list, or nullpublic List<SandboxVolume> getVolumes()
Returns volumes attached to the Sandbox.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
List\<SandboxVolume\> - immutable list of attached volumes, or null if not yet populatedpublic BuildInfo getBuildInfo()
Returns build information if the Sandbox was created from a dynamic build.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
BuildInfo - build info, or nullpublic String getBackupCreatedAt()
Returns the creation timestamp of the last backup.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
String - backup timestamp, or nullpublic Process getProcess()
Returns:
Process - process operations facade.public FileSystem getFs()
Returns:
FileSystem - file-system operations facade.public Git getGit()
Returns:
Git - Git operations facade.