---
title: "Sandbox"
hideTitleOnPage: true
---

## Sandbox

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).

### Methods

#### createLspServer()
```java
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 sandbox

**Returns**:

- `LspServer` - a new `LspServer` configured for the given language

#### start()
```java
public void start()
```

Starts this Sandbox with default timeout.

**Throws**:

- `DaytonaException` - if the Sandbox fails to start

#### start()
```java
public void start(long timeoutSeconds)
```

Starts this Sandbox and waits for readiness.

**Parameters**:

- `timeoutSeconds` _long_ - maximum seconds to wait; `0` disables timeout

**Throws**:

- `DaytonaException` - if start fails or times out

#### stop()
```java
public void stop()
```

Stops this Sandbox with default timeout.

**Throws**:

- `DaytonaException` - if the Sandbox fails to stop

#### stop()
```java
public void stop(long timeoutSeconds)
```

Stops this Sandbox and waits until fully stopped.

**Parameters**:

- `timeoutSeconds` _long_ - maximum seconds to wait; `0` disables timeout

**Throws**:

- `DaytonaException` - if stop fails or times out

#### waitUntilStopped()
```java
public void waitUntilStopped(long timeoutSeconds)
```

Waits until Sandbox reaches `stopped` (or `destroyed`) state.

**Parameters**:

- `timeoutSeconds` _long_ - maximum seconds to wait; `0` disables timeout

**Throws**:

- `DaytonaException` - if timeout is invalid, state becomes error, or timeout expires

#### delete()
```java
public void delete()
```

Deletes this Sandbox with default timeout behavior.

**Throws**:

- `DaytonaException` - if deletion fails

#### delete()
```java
public void delete(long timeoutSeconds)
```

Deletes this Sandbox.

**Parameters**:

- `timeoutSeconds` _long_ - reserved timeout parameter for parity with other SDKs

**Throws**:

- `DaytonaException` - if deletion fails

#### setLabels()
```java
public Map<String, String> setLabels(Map<String, String> labels)
```

Replaces Sandbox labels.

**Parameters**:

- `labels` _Map\<String, String\>_ - label map to apply

**Returns**:

- `Map\<String, String\>` - updated labels

**Throws**:

- `DaytonaException` - if label update fails

#### setAutostopInterval()
```java
public void setAutostopInterval(int minutes)
```

Sets Sandbox auto-stop interval.

**Parameters**:

- `minutes` _int_ - idle minutes before automatic stop

**Throws**:

- `DaytonaException` - if the update fails

#### setAutoArchiveInterval()
```java
public void setAutoArchiveInterval(int minutes)
```

Sets Sandbox auto-archive interval.

**Parameters**:

- `minutes` _int_ - minutes in stopped state before automatic archive

**Throws**:

- `DaytonaException` - if the update fails

#### setAutoDeleteInterval()
```java
public void setAutoDeleteInterval(int minutes)
```

Sets Sandbox auto-delete interval.

**Parameters**:

- `minutes` _int_ - minutes before automatic deletion after stop

**Throws**:

- `DaytonaException` - if the update fails

#### updateNetworkSettings()
```java
public 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 set

**Throws**:

- `DaytonaException` - if the update fails

#### getUserHomeDir()
```java
public String getUserHomeDir()
```

Returns home directory path for Sandbox user.

**Returns**:

- `String` - absolute home directory path

**Throws**:

- `DaytonaException` - if the request fails

#### getWorkDir()
```java
public String getWorkDir()
```

Returns current working directory path.

**Returns**:

- `String` - absolute working directory path

**Throws**:

- `DaytonaException` - if the request fails

#### waitUntilStarted()
```java
public void waitUntilStarted(long timeoutSeconds)
```

Waits until Sandbox reaches `started` state.

**Parameters**:

- `timeoutSeconds` _long_ - maximum seconds to wait; `0` disables timeout

**Throws**:

- `DaytonaException` - if timeout is invalid, state becomes failure, or timeout expires

#### refreshData()
```java
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

#### experimentalFork()
```java
public 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 state

**Throws**:

- `DaytonaException` - if the fork operation fails or times out

#### experimentalFork()
```java
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.

**Parameters**:

- `name` _String_ - optional name for the forked Sandbox; `null` for auto-generated
- `timeoutSeconds` _long_ - maximum seconds to wait for the forked Sandbox to start; `0` disables timeout

**Returns**:

- `Sandbox` - the forked `Sandbox` in started state

**Throws**:

- `DaytonaException` - if the fork operation fails or times out

#### experimentalCreateSnapshot()
```java
public 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 snapshot

**Throws**:

- `DaytonaException` - if the snapshot operation fails

#### experimentalCreateSnapshot()
```java
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.

**Parameters**:

- `name` _String_ - name for the new snapshot
- `timeoutSeconds` _long_ - reserved timeout parameter for parity with other SDKs

**Throws**:

- `DaytonaException` - if the snapshot operation fails

#### getId()
```java
public String getId()
```

**Returns**:

- `String` - Sandbox ID.

#### getName()
```java
public String getName()
```

**Returns**:

- `String` - Sandbox name.

#### getOrganizationId()
```java
public String getOrganizationId()
```

**Returns**:

- `String` - organization ID that owns this Sandbox.

#### getSnapshot()
```java
public String getSnapshot()
```

**Returns**:

- `String` - Daytona snapshot used to create this Sandbox, or `null` if none.

#### getUser()
```java
public String getUser()
```

**Returns**:

- `String` - OS user running in the Sandbox.

#### getLabels()
```java
public Map<String, String> getLabels()
```

**Returns**:

- `Map\<String, String\>` - custom labels attached to the Sandbox.

#### getPublic()
```java
public Boolean getPublic()
```

**Returns**:

- `Boolean` - whether the Sandbox HTTP preview is publicly accessible.

#### getTarget()
```java
public String getTarget()
```

**Returns**:

- `String` - target region/environment where the Sandbox runs.

#### getCpu()
```java
public int getCpu()
```

**Returns**:

- `int` - allocated CPU cores.

#### getGpu()
```java
public int getGpu()
```

**Returns**:

- `int` - allocated GPU units.

#### getMemory()
```java
public int getMemory()
```

**Returns**:

- `int` - allocated memory in GiB.

#### getDisk()
```java
public int getDisk()
```

**Returns**:

- `int` - allocated disk in GiB.

#### getState()
```java
public String getState()
```

**Returns**:

- `String` - current lifecycle state (e.g. "started", "stopped").

#### getErrorReason()
```java
public String getErrorReason()
```

**Returns**:

- `String` - error message if the Sandbox is in an error state, or `null`.

#### getRecoverable()
```java
public Boolean getRecoverable()
```

**Returns**:

- `Boolean` - whether the Sandbox error is recoverable, or `null` if unknown.

#### getBackupState()
```java
public String getBackupState()
```

**Returns**:

- `String` - current state of the Sandbox backup as a string, or `null`.

#### getAutoStopInterval()
```java
public Integer getAutoStopInterval()
```

**Returns**:

- `Integer` - auto-stop interval in minutes (0 means disabled).

#### getAutoArchiveInterval()
```java
public Integer getAutoArchiveInterval()
```

**Returns**:

- `Integer` - auto-archive interval in minutes.

#### getAutoDeleteInterval()
```java
public Integer getAutoDeleteInterval()
```

**Returns**:

- `Integer` - auto-delete interval in minutes (negative means disabled).

#### getCreatedAt()
```java
public String getCreatedAt()
```

**Returns**:

- `String` - when the Sandbox was created, or `null`.

#### getUpdatedAt()
```java
public String getUpdatedAt()
```

**Returns**:

- `String` - when the Sandbox was last updated, or `null`.

#### getLastActivityAt()
```java
public String getLastActivityAt()
```

**Returns**:

- `String` - when the Sandbox last had activity, or `null`.

#### getToolboxProxyUrl()
```java
public String getToolboxProxyUrl()
```

**Returns**:

- `String` - toolbox proxy URL.

#### getEnv()
```java
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 populated

#### getNetworkBlockAll()
```java
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, or `null` if not yet populated

#### getNetworkAllowList()
```java
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, or `null`

#### getVolumes()
```java
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, or `null` if not yet populated

#### getBuildInfo()
```java
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, or `null`

#### getBackupCreatedAt()
```java
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, or `null`

#### getProcess()
```java
public Process getProcess()
```

**Returns**:

- `Process` - process operations facade.

#### getFs()
```java
public FileSystem getFs()
```

**Returns**:

- `FileSystem` - file-system operations facade.

#### getGit()
```java
public Git getGit()
```

**Returns**:

- `Git` - Git operations facade.
