Sandbox
Section titled “Sandbox”Represents a Daytona Sandbox instance.
Exposes lifecycle controls and operation facades for process execution, file-system access, and Git. State changes are streamed over WebSocket by default with polling as a safety net, or observed by polling only when the deprecated polling mode is enabled.
Properties:
processProcess - Process execution interface for this Sandbox.fsFileSystem - File-system operations interface for this Sandbox.gitGit - Git operations interface for this Sandbox.computerUseComputerUse - Computer use (desktop automation) interface for this Sandbox.codeInterpreterCodeInterpreter - Stateful code interpreter for this Sandbox (Python).
Methods
Section titled “Methods”createLspServer()
Section titled “createLspServer()”public LspServer createLspServer(String languageId, String pathToProject)Creates an LSP server instance for the specified language and project.
Parameters:
languageIdString - language server to start (e.g. “typescript”, “python”, “go”)pathToProjectString - absolute path to the project root inside the sandbox
Returns:
LspServer- a newLspServerconfigured for the given language
start()
Section titled “start()”public void start()Starts this Sandbox with default timeout.
Throws:
DaytonaException- if the Sandbox fails to start
start()
Section titled “start()”public void start(long timeoutSeconds)Starts this Sandbox and waits for readiness.
Parameters:
timeoutSecondslong - maximum seconds to wait;0disables timeout
Throws:
DaytonaException- if start fails or times out
stop()
Section titled “stop()”public void stop()Stops this Sandbox with default timeout.
Throws:
DaytonaException- if the Sandbox fails to stop
stop()
Section titled “stop()”public void stop(long timeoutSeconds)Stops this Sandbox and waits until fully stopped.
Parameters:
timeoutSecondslong - maximum seconds to wait;0disables timeout
Throws:
DaytonaException- if stop fails or times out
waitUntilStopped()
Section titled “waitUntilStopped()”public void waitUntilStopped(long timeoutSeconds)Waits until Sandbox reaches stopped (or destroyed) state.
Parameters:
timeoutSecondslong - maximum seconds to wait;0disables timeout
Throws:
DaytonaException- if timeout is invalid, state becomes error, or timeout expires
delete()
Section titled “delete()”public void delete()Deletes this Sandbox.
Fires the delete API call and returns immediately without waiting for the
Sandbox to reach the destroyed state. Use #delete(long, boolean)
with wait=true to block until destruction completes.
Throws:
DaytonaException- if the delete API call fails
delete()
Section titled “delete()”public void delete(long timeoutSeconds)Deletes this Sandbox.
Fires the delete API call and returns immediately. Use
#delete(long, boolean) with wait=true to block until destroyed.
Parameters:
timeoutSecondslong - timeout for the HTTP request (and for waiting whenwaitis true in#delete(long, boolean))
Throws:
DaytonaException- if the delete API call fails
delete()
Section titled “delete()”public void delete(long timeoutSeconds, boolean wait)Deletes this Sandbox, optionally waiting for it to reach the destroyed state.
Parameters:
timeoutSecondslong - maximum seconds to wait whenwaitis true;0disables timeout. Ignored whenwaitis false.waitboolean - iftrue, block until the Sandbox is destroyed
Throws:
DaytonaException- if deletion fails or times out
setLabels()
Section titled “setLabels()”public Map<String, String> setLabels(Map<String, String> labels)Replaces Sandbox labels.
Parameters:
labelsMap<String, String> - label map to apply
Returns:
Map\<String, String\>- updated labels
Throws:
DaytonaException- if label update fails
setAutostopInterval()
Section titled “setAutostopInterval()”public void setAutostopInterval(int minutes)Sets Sandbox auto-stop interval.
Parameters:
minutesint - idle minutes before automatic stop
Throws:
DaytonaException- if the update fails
setAutoPauseInterval()
Section titled “setAutoPauseInterval()”public void setAutoPauseInterval(int minutes)Sets Sandbox auto-pause interval.
Parameters:
minutesint - idle minutes before automatic pause (0 means disabled)
Throws:
DaytonaException- if the update fails
setAutoArchiveInterval()
Section titled “setAutoArchiveInterval()”public void setAutoArchiveInterval(int minutes)Sets Sandbox auto-archive interval.
Parameters:
minutesint - minutes in stopped state before automatic archive
Throws:
DaytonaException- if the update fails
setAutoDeleteInterval()
Section titled “setAutoDeleteInterval()”public void setAutoDeleteInterval(int minutes)Sets Sandbox auto-delete interval.
Parameters:
minutesint - minutes before automatic deletion after stop
Throws:
DaytonaException- if the update fails
setTtl()
Section titled “setTtl()”public void setTtl(int ttlMinutes)Sets Sandbox TTL (time to live) in minutes. Set to 0 to disable the TTL.
The deadline is computed server-side; call #refreshData() and read the updated
value via #getAutoDestroyAt().
Parameters:
ttlMinutesint - minutes until the Sandbox is destroyed, or 0 to disable
Throws:
IllegalArgumentException- if ttlMinutes is negativeDaytonaException- if the update fails
updateNetworkSettings()
Section titled “updateNetworkSettings()”public void updateNetworkSettings(UpdateSandboxNetworkSettings settings)Updates outbound network policy on the runner (block all, restore access, or CIDR allow list).
Parameters:
settingsUpdateSandboxNetworkSettings - request body; at least one of networkBlockAll or networkAllowList must be set
Throws:
DaytonaException- if the update fails
updateSecrets()
Section titled “updateSecrets()”public void updateSecrets(Map<String, String> secrets)Replaces the set of vault secrets mounted in this Sandbox.
Each key is an environment variable name and each value is the name of an existing organization Secret. Pass an empty map to detach all secrets. Attached, detached, and rotated secrets take effect for outbound requests within seconds. New environment variables are only visible to processes spawned after the update; a Sandbox created without secrets must be restarted for newly attached secrets to work.
Parameters:
secretsMap<String, String> - map of environment variable name to organization Secret name
Throws:
DaytonaException- if the update fails
getUserHomeDir()
Section titled “getUserHomeDir()”public String getUserHomeDir()Returns home directory path for Sandbox user.
Returns:
String- absolute home directory path
Throws:
DaytonaException- if the request fails
getMetricsLatest()
Section titled “getMetricsLatest()”public SandboxMetrics getMetricsLatest()Gets the most recent resource usage sample directly from the sandbox daemon.
Unlike #getMetrics, which returns aggregated historical samples, this returns
the single current reading without going through the telemetry backend.
Returns:
SandboxMetrics- the current resource usage sample for the sandbox
Throws:
DaytonaException- if the request fails
getMetrics()
Section titled “getMetrics()”public List<SandboxMetrics> getMetrics(OffsetDateTime start, OffsetDateTime end)Gets historical time-series resource usage metrics for the sandbox.
When the deployment runs a dedicated Analytics API, metrics are fetched from it directly;
otherwise they are fetched through the control-plane telemetry proxy. A null start
defaults to the sandbox creation time; a null end defaults to the current time.
Samples are returned ordered ascending by timestamp.
Parameters:
startOffsetDateTime - start of the time range, ornullfor the sandbox creation timeendOffsetDateTime - end of the time range, ornullfor the current time
Returns:
List\<SandboxMetrics\>- time-ordered usage samples over the requested range
Throws:
DaytonaException- if the request fails
getWorkDir()
Section titled “getWorkDir()”public String getWorkDir()Returns current working directory path.
Returns:
String- absolute working directory path
Throws:
DaytonaException- if the request fails
updateEnv()
Section titled “updateEnv()”public void updateEnv(Map<String, String> env)Updates the Sandbox daemon’s process environment.
Newly spawned processes, sessions, and PTYs inherit the change; already-running processes keep their environment.
Parameters:
envMap<String, String> - environment variables to set in the daemon’s process environment
Throws:
DaytonaException- if the update fails
updateEnv()
Section titled “updateEnv()”public void updateEnv(Map<String, String> env, List<String> unset)Updates the Sandbox daemon’s process environment.
Newly spawned processes, sessions, and PTYs inherit the change; already-running processes keep their environment.
Parameters:
envMap<String, String> - environment variables to set in the daemon’s process environment;nullto set noneunsetList<String> - environment variable names to remove;nullto remove none
Throws:
DaytonaException- if the update fails
downloadUrl()
Section titled “downloadUrl()”public String downloadUrl(String path, Long ttlSeconds)Creates a pre-signed URL for downloading a file from the Sandbox.
The URL works with any HTTP client without auth headers and stays valid across sandbox restarts (downloads succeed only while the sandbox is running). The signing key is cached locally for up to 15 seconds; if the key was rotated from another client, URLs may be rejected until the cache refreshes.
String url = sandbox.downloadUrl("/home/user/report.pdf", null);// curl "$url" -o report.pdfParameters:
pathString - Path to the file in the Sandbox.ttlSecondsLong - How long the URL stays valid, in seconds. Defaults to 3600. Zero or negative means never expires.
Returns:
String- Pre-signed download URL.
Throws:
DaytonaException- if the signing key cannot be fetched.
downloadUrl()
Section titled “downloadUrl()”public String downloadUrl(String path)Creates a pre-signed URL for downloading a file from the Sandbox.
Parameters:
pathString - Path to the file in the Sandbox.
Returns:
String- Pre-signed download URL.
Throws:
DaytonaException- if the signing key cannot be fetched.
uploadUrl()
Section titled “uploadUrl()”public String uploadUrl(String path, Long ttlSeconds)Creates a pre-signed URL for uploading a file to the Sandbox.
Send a POST request with the file as multipart/form-data. The URL works with any HTTP client without auth headers. The signing key is cached locally for up to 15 seconds; if the key was rotated from another client, URLs may be rejected until the cache refreshes.
String url = sandbox.uploadUrl("/home/user/data.bin", null);// curl -X POST -F "file=@local.bin" "$url"Parameters:
pathString - Destination path for the uploaded file in the Sandbox.ttlSecondsLong - How long the URL stays valid, in seconds. Defaults to 3600. Zero or negative means never expires.
Returns:
String- Pre-signed upload URL.
Throws:
DaytonaException- if the signing key cannot be fetched.
uploadUrl()
Section titled “uploadUrl()”public String uploadUrl(String path)Creates a pre-signed URL for uploading a file to the Sandbox.
Parameters:
pathString - Destination path for the uploaded file in the Sandbox.
Returns:
String- Pre-signed upload URL.
Throws:
DaytonaException- if the signing key cannot be fetched.
rotateSigningKey()
Section titled “rotateSigningKey()”public void rotateSigningKey()Rotates the sandbox signing key, invalidating all previously signed URLs.
Throws:
DaytonaException- if the signing key rotation fails.
waitUntilStarted()
Section titled “waitUntilStarted()”public void waitUntilStarted(long timeoutSeconds)Waits until Sandbox reaches started state.
Parameters:
timeoutSecondslong - maximum seconds to wait;0disables timeout
Throws:
DaytonaException- if timeout is invalid, state becomes failure, or timeout expires
waitForResizeComplete()
Section titled “waitForResizeComplete()”public void waitForResizeComplete(long timeoutSeconds)Waits for a resize operation to complete.
Parameters:
timeoutSecondslong - maximum seconds to wait;0disables timeout
Throws:
DaytonaException- if resize times out or fails
refreshData()
Section titled “refreshData()”public 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 fails
fork()
Section titled “fork()”public Sandbox fork()Forks this Sandbox, creating a new Sandbox with an identical filesystem. Uses default timeout of 60 seconds.
Example usage:
Sandbox forked = sandbox.fork();System.out.println(forked.getId());Returns:
Sandbox- the forkedSandboxin started state
Throws:
DaytonaException- if the fork operation fails or times out
fork()
Section titled “fork()”public Sandbox fork(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.
Example usage:
Sandbox forked = sandbox.fork("my-fork", 120);System.out.println(forked.getId());Parameters:
nameString - optional name for the forked Sandbox;nullfor auto-generatedtimeoutSecondslong - maximum seconds to wait for the forked Sandbox to start;0disables timeout
Returns:
Sandbox- the forkedSandboxin started state
Throws:
DaytonaException- if the fork operation fails or times out
experimentalFork()
Section titled “experimentalFork()”public Sandbox experimentalFork()Forks this Sandbox, creating a new Sandbox with an identical filesystem. Uses default timeout of 60 seconds.
Deprecated: Use #fork() instead. This method will be removed in a future version.
Returns:
Sandbox- the forkedSandboxin started state
Throws:
DaytonaException- if the fork operation fails or times out
experimentalFork()
Section titled “experimentalFork()”public 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.
Deprecated: Use #fork(String, long) instead. This method will be removed in a future version.
Parameters:
nameString - optional name for the forked Sandbox;nullfor auto-generatedtimeoutSecondslong - maximum seconds to wait for the forked Sandbox to start;0disables timeout
Returns:
Sandbox- the forkedSandboxin started state
Throws:
DaytonaException- if the fork operation fails or times out
createSnapshot()
Section titled “createSnapshot()”public void createSnapshot(String name)Creates a snapshot from the current state of this Sandbox. Uses default timeout of 60 seconds.
Example usage:
sandbox.createSnapshot("my-snapshot");Parameters:
nameString - name for the new snapshot
Throws:
DaytonaException- if the snapshot operation fails
createSnapshot()
Section titled “createSnapshot()”public void createSnapshot(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.
Example usage:
sandbox.createSnapshot("my-snapshot", 120);Parameters:
nameString - name for the new snapshottimeoutSecondslong - maximum seconds to wait for the snapshot operation to complete;0disables timeout
Throws:
DaytonaException- if the snapshot operation fails
experimentalCreateSnapshot()
Section titled “experimentalCreateSnapshot()”public void experimentalCreateSnapshot(String name)Creates a snapshot from the current state of this Sandbox. Uses default timeout of 60 seconds.
Deprecated: Use #createSnapshot(String) instead. This method will be removed in a future version.
Parameters:
nameString - name for the new snapshot
Throws:
DaytonaException- if the snapshot operation fails
experimentalCreateSnapshot()
Section titled “experimentalCreateSnapshot()”public 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.
Deprecated: Use #createSnapshot(String, long) instead. This method will be removed in a future version.
Parameters:
nameString - name for the new snapshottimeoutSecondslong - maximum seconds to wait for the snapshot operation to complete;0disables timeout
Throws:
DaytonaException- if the snapshot operation fails
pause()
Section titled “pause()”public void pause() throws DaytonaExceptionPauses the Sandbox, freezing all running processes. Uses default timeout of 60 seconds.
Throws:
DaytonaException- if the pause operation fails
pause()
Section titled “pause()”public void pause(long timeoutSeconds) throws DaytonaExceptionPauses the Sandbox, freezing all running processes.
Completes when the Sandbox has left the pausing state — any non-error
terminal state (paused, stopped, archived, etc.) is accepted.
Parameters:
timeoutSecondslong - maximum time to wait in seconds (0 = no timeout)
Throws:
DaytonaException- if timeout is negative or the operation fails/times out
getId()
Section titled “getId()”public String getId()Returns:
String- Sandbox ID.
getName()
Section titled “getName()”public String getName()Returns:
String- Sandbox name.
getOrganizationId()
Section titled “getOrganizationId()”public String getOrganizationId()Returns:
String- organization ID that owns this Sandbox.
getSnapshot()
Section titled “getSnapshot()”public String getSnapshot()Returns:
String- Daytona snapshot used to create this Sandbox, ornullif none.
getUser()
Section titled “getUser()”public String getUser()Returns:
String- OS user running in the Sandbox.
getLabels()
Section titled “getLabels()”public Map<String, String> getLabels()Returns:
Map\<String, String\>- custom labels attached to the Sandbox.
getPublic()
Section titled “getPublic()”public Boolean getPublic()Returns:
Boolean- whether the Sandbox HTTP preview is publicly accessible.
getTarget()
Section titled “getTarget()”public String getTarget()Returns:
String- target region/environment where the Sandbox runs.
getCpu()
Section titled “getCpu()”public int getCpu()Returns:
int- allocated CPU cores.
getGpu()
Section titled “getGpu()”public int getGpu()Returns:
int- allocated GPU units.
isSpot()
Section titled “isSpot()”public boolean isSpot()Returns whether this is a spot GPU Sandbox.
Spot Sandboxes may be instantly terminated to free capacity for on-demand GPU Sandboxes.
Returns:
boolean-truewhen the Sandbox is preemptible.
getSpotEvictedAt()
Section titled “getSpotEvictedAt()”public String getSpotEvictedAt()Returns:
String- when the Sandbox was evicted by spot preemption, ornullwhen it was not.
getMemory()
Section titled “getMemory()”public int getMemory()Returns:
int- allocated memory in GiB.
getDisk()
Section titled “getDisk()”public int getDisk()Returns:
int- allocated disk in GiB.
getState()
Section titled “getState()”public String getState()Returns:
String- current lifecycle state (e.g. “started”, “stopped”).
getErrorReason()
Section titled “getErrorReason()”public String getErrorReason()Returns:
String- error message if the Sandbox is in an error state, ornull.
getRecoverable()
Section titled “getRecoverable()”public Boolean getRecoverable()Returns:
Boolean- whether the Sandbox error is recoverable, ornullif unknown.
getBackupState()
Section titled “getBackupState()”public String getBackupState()Returns:
String- current state of the Sandbox backup as a string, ornull.
getAutoStopInterval()
Section titled “getAutoStopInterval()”public Integer getAutoStopInterval()Returns:
Integer- auto-stop interval in minutes (0 means disabled).
getAutoPauseInterval()
Section titled “getAutoPauseInterval()”public Integer getAutoPauseInterval()Returns:
Integer- auto-pause interval in minutes (0 means disabled).
getAutoArchiveInterval()
Section titled “getAutoArchiveInterval()”public Integer getAutoArchiveInterval()Returns:
Integer- auto-archive interval in minutes.
getAutoDeleteInterval()
Section titled “getAutoDeleteInterval()”public Integer getAutoDeleteInterval()Returns:
Integer- auto-delete interval in minutes (negative means disabled).
getCreatedAt()
Section titled “getCreatedAt()”public String getCreatedAt()Returns:
String- when the Sandbox was created, ornull.
getUpdatedAt()
Section titled “getUpdatedAt()”public String getUpdatedAt()Returns:
String- when the Sandbox was last updated, ornull.
getLastActivityAt()
Section titled “getLastActivityAt()”public String getLastActivityAt()Returns:
String- when the Sandbox last had activity, ornull.
getAutoDestroyAt()
Section titled “getAutoDestroyAt()”public String getAutoDestroyAt()Returns:
String- when the Sandbox expires, ornullif no TTL is set.
getToolboxProxyUrl()
Section titled “getToolboxProxyUrl()”public String getToolboxProxyUrl()Returns:
String- toolbox proxy URL.
getEnv()
Section titled “getEnv()”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, ornullif not yet populated
getNetworkBlockAll()
Section titled “getNetworkBlockAll()”public 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, ornullif not yet populated
getNetworkAllowList()
Section titled “getNetworkAllowList()”public 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, ornull
getDomainAllowList()
Section titled “getDomainAllowList()”public String getDomainAllowList()Returns the comma-separated list of allowed domains, if any.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Returns:
String- allowed domains, ornull
getOutboundProxyUrl()
Section titled “getOutboundProxyUrl()”public String getOutboundProxyUrl()Returns the outbound proxy URL to route the sandbox HTTP(S) traffic through, if any.
Not returned by Daytona#list; call #refreshData() on each item to populate.
Applied via the HTTP(S)_PROXY environment variables; combine with domainAllowList for
network-layer enforcement.
Returns:
String- outbound proxy URL, ornull
getVolumes()
Section titled “getVolumes()”public 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, ornullif not yet populated
getBuildInfo()
Section titled “getBuildInfo()”public 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, ornull
getBackupCreatedAt()
Section titled “getBackupCreatedAt()”public 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, ornull
getProcess()
Section titled “getProcess()”public Process getProcess()Returns:
Process- process operations facade.
getFs()
Section titled “getFs()”public FileSystem getFs()Returns:
FileSystem- file-system operations facade.
getGit()
Section titled “getGit()”public Git getGit()Returns:
Git- Git operations facade.