# Sandboxes (/docs/sandboxes)

Daytona provides **full composable computers** &mdash; **sandboxes** &mdash; for AI agents. Sandboxes are isolated runtime environments you can manage programmatically to run code. Each sandbox runs in isolation, giving it a dedicated kernel, filesystem, network stack, and allocated vCPU, RAM, and disk. Agents and developers get access to a full composable computer where they can install packages, run servers, compile code, and manage processes.

Sandboxes run as **Linux containers** by default. Daytona also provides [VM sandboxes](#vm-sandboxes) with a dedicated [Linux VM](/docs/linux-sandboxes) or [Windows](/docs/windows-sandboxes) operating system, [GPU sandboxes](#gpu-sandboxes) with **NVIDIA** and **AMD GPU** acceleration for CUDA development, 3D and graphics workloads, and other GPU-accelerated compute, and [macOS sandboxes](/docs/macos-sandboxes) running on dedicated Apple silicon hardware.

<DocLinkCardGrid>
  <DocLinkCard
    title="Container"
    href="#create-sandboxes"
    icon="package"
    description="Default Linux container runtime for running processes and executing code."
    features={['<90ms', 'Dynamic builds', 'Docker images']}
  />
  <DocLinkCard
    title="Linux VM"
    href="#vm-sandboxes"
    icon="vm"
    description="Linux OS runtime in a virtual machine for running Linux-specific tools and workflows."
    features={['Fork', 'Pause/resume', 'Memory snapshots']}
  />
  <DocLinkCard
    title="Windows"
    href="#vm-sandboxes"
    icon="vm"
    description="Windows OS runtime in a virtual machine for running Windows applications and tooling."
    features={['Fork', 'Pause/resume', 'Memory snapshots']}
  />
  <DocLinkCard
    title="macOS"
    href="#macos-sandboxes"
    icon="vm"
    description="macOS runtime for automating applications and desktop interactions."
    features={['Computer Use', 'VNC', 'SSH']}
  />
  <DocLinkCard
    title="GPU"
    href="#gpu-sandboxes"
    icon="gpu"
    description="NVIDIA and AMD GPU runtime for CUDA development, 3D and graphics workloads, and other GPU-accelerated compute."
    features={['H100/H200/B200/B300', 'RTX', 'MI355X']}
  />
</DocLinkCardGrid>

## Create sandboxes [#create-sandboxes]

Create a sandbox.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona

daytona = Daytona()
sandbox = daytona.create()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	_, _ = client.Create(ctx, nil)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            Sandbox sandbox = daytona.create();
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{}'
```

</TabItem>
</Tabs>

### Snapshots [#snapshots]

Create a sandbox from a [default snapshot](/docs/snapshots#default-snapshots).

| **Snapshot**            | **vCPU** | **Memory** | **Storage** | **GPU** | **Sandbox Class** |
| ----------------------- | -------- | ---------- | ----------- | ------- | ----------------- |
| **`daytona-small`**     | 1        | 1GiB       | 3GiB        |         | Container         |
| **`daytona-medium`**    | 2        | 4GiB       | 8GiB        |         | Container         |
| **`daytona-large`**     | 4        | 8GiB       | 10GiB       |         | Container         |
| **`daytona-gpu`**       | 1        | 1GiB       | 1GiB        | 1       | GPU               |
| **`daytona-vm-small`**  | 1        | 1GiB       | 3GiB        |         | Linux VM          |
| **`daytona-vm-medium`** | 2        | 4GiB       | 8GiB        |         | Linux VM          |
| **`daytona-vm-large`**  | 4        | 8GiB       | 10GiB       |         | Linux VM          |
| **`windows-small`**     | 1        | 4GiB       | 30GiB       |         | Windows           |
| **`windows-medium`**    | 2        | 8GiB       | 50GiB       |         | Windows           |
| **`windows-large`**     | 4        | 16GiB      | 50GiB       |         | Windows           |

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Select a <Button>Snapshot</Button>
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(
        snapshot="daytona-small",
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  snapshot: 'daytona-small',
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'daytona-small'
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	params := types.SnapshotParams{
		Snapshot: "daytona-small",
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("daytona-small");
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --snapshot daytona-small
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "daytona-small"
}'
```

</TabItem>
</Tabs>

### Images [#images]

Create a sandbox from an image. The image must be publicly accessible and include either a tag or a digest (e.g. **`ubuntu:22.04`**); the **`latest`**/**`lts`**/**`stable`** tags are not supported.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Enter an <Button>Image</Button> (e.g. **`ubuntu:22.04`**) as the source for the sandbox
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromImageParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromImageParams(
        image="ubuntu:22.04",
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona, Image } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  image: Image.base('ubuntu:22.04'),
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromImageParams.new(
    image: Daytona::Image.base('ubuntu:22.04')
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	_, _ = client.Create(ctx, types.ImageParams{
		Image: "ubuntu:22.04",
	})
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromImageParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromImageParams params = new CreateSandboxFromImageParams();
            params.setImage("ubuntu:22.04");
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "buildInfo": {
    "dockerfileContent": "FROM ubuntu:22.04\n"
  }
}'
```

</TabItem>
</Tabs>

### Resources [#resources]

Create a sandbox with custom resources.

Sandboxes have **1 vCPU**, **1GB RAM**, and **3GiB disk** by default. Organizations get a maximum sandbox resource limit of **4 vCPUs**, **8GB RAM**, and **10GB disk**.

| **Resource** | **Unit** | **Default** | **Minimum** | **Maximum** |
| ------------ | -------- | ----------- | ----------- | ----------- |
| CPU          | vCPU     | **`1`**     | **`1`**     | **`4`**     |
| Memory       | GiB      | **`1`**     | **`1`**     | **`8`**     |
| Disk         | GiB      | **`3`**     | **`1`**     | **`10`**    |

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Enter an <Button>Image</Button> (e.g. **`ubuntu:22.04`**) as the source for the sandbox
4. Set <Button>Resources</Button> (**`cpu`**, **`memory`**, **`disk`**) to the values within your organization's limits
5. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromImageParams, Image, Resources

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromImageParams(
        image="ubuntu:22.04",
        resources=Resources(cpu=2, memory=4, disk=8),
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona, Image } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  image: Image.base('ubuntu:22.04'),
  resources: { cpu: 2, memory: 4, disk: 8 },
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromImageParams.new(
    image: Daytona::Image.base('ubuntu:22.04'),
    resources: Daytona::Resources.new(
      cpu: 2,
      memory: 4,
      disk: 8
    )
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	_, _ = client.Create(ctx, types.ImageParams{
		Image: "ubuntu:22.04",
		Resources: &types.Resources{
			CPU:    2,
			Memory: 4,
			Disk:   8,
		},
	})
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromImageParams;
import io.daytona.sdk.model.Resources;

final class CreateSandboxResources {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromImageParams params = new CreateSandboxFromImageParams();
            params.setImage("ubuntu:22.04");
            Resources resources = new Resources();
            resources.setCpu(2);
            resources.setMemory(4);
            resources.setDisk(8);
            params.setResources(resources);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --cpu 2 --memory 4 --disk 8
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "buildInfo": {
    "dockerfileContent": "FROM ubuntu:22.04\n"
  },
  "cpu": 2,
  "memory": 4,
  "disk": 8
}'
```

</TabItem>
</Tabs>

<a id="multiple-runtime-support"></a>
### Languages [#languages]

Create a sandbox with a specific language runtime.

Daytona sandboxes support **Python**, **TypeScript**, and **JavaScript** programming language runtimes for direct code execution inside the sandbox. The language parameter controls which programming language runtime is used for the sandbox. If omitted, it defaults to Python.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()

# Python runtime (default)
sandbox = daytona.create(CreateSandboxFromSnapshotParams(language="python"))
response = sandbox.process.code_run('print("Hello from Python")')
print(response.result)

# TypeScript runtime
sandbox = daytona.create(CreateSandboxFromSnapshotParams(language="typescript"))
response = sandbox.process.code_run('console.log("Hello from TypeScript")')
print(response.result)

# JavaScript runtime
sandbox = daytona.create(CreateSandboxFromSnapshotParams(language="javascript"))
response = sandbox.process.code_run('console.log("Hello from JavaScript")')
print(response.result)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()

// Python runtime (default)
let sandbox = await daytona.create({ language: 'python' })
let response = await sandbox.process.codeRun('print("Hello from Python")')
console.log(response.result)

// TypeScript runtime
sandbox = await daytona.create({ language: 'typescript' })
response = await sandbox.process.codeRun('console.log("Hello from TypeScript")')
console.log(response.result)

// JavaScript runtime
sandbox = await daytona.create({ language: 'javascript' })
response = await sandbox.process.codeRun('console.log("Hello from JavaScript")')
console.log(response.result)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new

# Python runtime (default)
sandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(
  language: Daytona::CodeLanguage::PYTHON
))
response = sandbox.process.code_run(code: 'print("Hello from Python")')
puts response.result

# TypeScript runtime
sandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(
  language: Daytona::CodeLanguage::TYPESCRIPT
))
response = sandbox.process.code_run(code: 'console.log("Hello from TypeScript")')
puts response.result

# JavaScript runtime
sandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(
  language: Daytona::CodeLanguage::JAVASCRIPT
))
response = sandbox.process.code_run(code: 'console.log("Hello from JavaScript")')
puts response.result
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, err := daytona.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	// Python runtime (default)
	sandbox, err := client.Create(ctx, types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{Language: types.CodeLanguagePython},
	})
	if err != nil {
		log.Fatal(err)
	}
	result, err := sandbox.Process.CodeRun(ctx, `print("Hello from Python")`)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(result.Result)

	// TypeScript runtime
	sandbox, err = client.Create(ctx, types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{Language: types.CodeLanguageTypeScript},
	})
	if err != nil {
		log.Fatal(err)
	}
	result, err = sandbox.Process.CodeRun(ctx, `console.log("Hello from TypeScript")`)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(result.Result)

	// JavaScript runtime
	sandbox, err = client.Create(ctx, types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{Language: types.CodeLanguageJavaScript},
	})
	if err != nil {
		log.Fatal(err)
	}
	result, err = sandbox.Process.CodeRun(ctx, `console.log("Hello from JavaScript")`)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(result.Result)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;
import io.daytona.sdk.model.ExecuteResponse;

Daytona daytona = new Daytona();

// Python runtime (default)
CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
params.setLanguage("python");
Sandbox sandbox = daytona.create(params);
ExecuteResponse response = sandbox.process.codeRun("print(\"Hello from Python\")");
System.out.println(response.getResult());

// TypeScript runtime
params = new CreateSandboxFromSnapshotParams();
params.setLanguage("typescript");
sandbox = daytona.create(params);
response = sandbox.process.codeRun("console.log(\"Hello from TypeScript\")");
System.out.println(response.getResult());

// JavaScript runtime
params = new CreateSandboxFromSnapshotParams();
params.setLanguage("javascript");
sandbox = daytona.create(params);
response = sandbox.process.codeRun("console.log(\"Hello from JavaScript\")");
System.out.println(response.getResult());
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
# Python runtime (default)
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "labels": {
    "code-toolbox-language": "python"
  }
}'

# TypeScript runtime
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "labels": {
    "code-toolbox-language": "typescript"
  }
}'

# JavaScript runtime
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "labels": {
    "code-toolbox-language": "javascript"
  }
}'
```

</TabItem>
</Tabs>

### Environment variables [#environment-variables]

Create a sandbox with environment variables. Use [secrets](/docs/secrets) for API keys, tokens, and passwords.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Click <Button>Add Variable</Button> and enter key-value pairs for each environment variable
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    env_vars={"DEBUG": "true", "LOG_LEVEL": "info"},
))
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  envVars: { DEBUG: 'true', LOG_LEVEL: 'info' },
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(
  env_vars: { 'DEBUG' => 'true', 'LOG_LEVEL' => 'info' }
))
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"log"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, err := daytona.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	sandbox, err := client.Create(context.Background(), types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{
			EnvVars: map[string]string{
				"DEBUG":     "true",
				"LOG_LEVEL": "info",
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Sandbox ID: %s", sandbox.ID)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

import java.util.Map;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setEnvVars(Map.of("DEBUG", "true", "LOG_LEVEL", "info"));
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create -e DEBUG=true -e LOG_LEVEL=info
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "env": {
    "DEBUG": "true",
    "LOG_LEVEL": "info"
  }
}'
```

</TabItem>
</Tabs>

### Regions [#regions]

Create a sandbox in a specific [region](/docs/regions).

| **Region**    | **Target** |
| ------------- | ---------- |
| United States | **`us`**   |
| Europe        | **`eu`**   |

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Set <Button>Region</Button> to the target region you want to create the sandbox in
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, DaytonaConfig

daytona = Daytona(DaytonaConfig(target="us"))
sandbox = daytona.create()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona({ target: 'us' })
const sandbox = await daytona.create()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new(Daytona::Config.new(target: 'us'))
sandbox = daytona.create
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClientWithConfig(&types.DaytonaConfig{
		Target: "us",
	})
	ctx := context.Background()
	_, _ = client.Create(ctx, nil)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.DaytonaConfig;
import io.daytona.sdk.Sandbox;

public class App {
    public static void main(String[] args) {
        DaytonaConfig config = new DaytonaConfig.Builder()
                .apiKey(System.getenv("DAYTONA_API_KEY"))
                .target("us")
                .build();

        try (Daytona daytona = new Daytona(config)) {
            Sandbox sandbox = daytona.create();
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "target": "us"
}'
```

</TabItem>
</Tabs>

### VM sandboxes [#vm-sandboxes]

Daytona provides **VM sandboxes** for workloads that require a full virtual machine with a dedicated [Linux VM](/docs/linux-sandboxes) or [Windows](/docs/windows-sandboxes) operating system. VM sandboxes are distinct from container sandboxes and support VM-only capabilities:

- [Fork sandboxes](#fork-sandboxes)
- [Pause and resume sandboxes](#pause--resume-sandboxes)
- [Create snapshot from sandbox](/docs/snapshots#create-snapshot-from-sandbox)
- [Nested virtualization](#nested-virtualization) (Linux VM only)

<Callout type="note" title="Limitations">
VM sandboxes can currently only be created from existing VM snapshots. Dynamic builds through the declarative builder are supported for container sandboxes only.
</Callout>

<Tabs>
<TabItem label="Linux VM" icon="linux">
<Tabs syncKey="linux-vm-create">
<TabItem label="Custom">

Create a Linux VM sandbox.

1. Go to [Daytona Snapshots ↗](https://app.daytona.io/dashboard/snapshots)
2. Click <Button>Create Snapshot</Button>
3. Enter <Button>Snapshot Name</Button> (e.g. **`my-vm-snapshot`**)
4. Enter an <Button>Image</Button> (e.g. **`ubuntu:22.04`**)
5. Select <Button>Sandbox Class</Button>: **`LINUX_VM`**
6. Click <Button>Create</Button>
7. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
8. Click <Button>Create Sandbox</Button>
9. Select a VM <Button>Snapshot</Button> (e.g. **`my-vm-snapshot`**)
10. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import (
    Daytona,
    CreateSnapshotParams,
    CreateSandboxFromSnapshotParams,
    SandboxClass,
)

daytona = Daytona()

# 1. Create a VM snapshot (Linux VM class)
daytona.snapshot.create(
    CreateSnapshotParams(
        name="my-vm-snapshot",
        image="ubuntu:22.04",
        sandbox_class=SandboxClass.LINUX_VM,
    )
)

# 2. Create a VM sandbox from the snapshot
sandbox = daytona.create(CreateSandboxFromSnapshotParams(snapshot="my-vm-snapshot"))
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona, SandboxClass } from "@daytona/sdk";

const daytona = new Daytona();

// 1. Create a VM snapshot (Linux VM class)
await daytona.snapshot.create({
  name: "my-vm-snapshot",
  image: "ubuntu:22.04",
  sandboxClass: SandboxClass.LINUX_VM,
});

// 2. Create a VM sandbox from the snapshot
const sandbox = await daytona.create({ snapshot: "my-vm-snapshot" });
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new

# 1. Create a VM snapshot (Linux VM class)
daytona.snapshot.create(
  Daytona::CreateSnapshotParams.new(
    name: 'my-vm-snapshot',
    image: 'ubuntu:22.04',
    sandbox_class: DaytonaApiClient::SandboxClass::LINUX_VM
  )
)

# 2. Create a VM sandbox from the snapshot
sandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(snapshot: 'my-vm-snapshot'))
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()

	// 1. Create a VM snapshot (Linux VM class)
	sandboxClass := types.SandboxClassLinuxVM
	_, logCh, _ := client.Snapshot.Create(ctx, &types.CreateSnapshotParams{
		Name:         "my-vm-snapshot",
		Image:        "ubuntu:22.04",
		SandboxClass: &sandboxClass,
	})
	for range logCh {
	}

	// 2. Create a VM sandbox from the snapshot
	_, _ = client.Create(ctx, types.SnapshotParams{
		Snapshot: "my-vm-snapshot",
	})
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.api.client.model.SandboxClass;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            // 1. Create a VM snapshot (Linux VM class)
            daytona.snapshot().create("my-vm-snapshot", "ubuntu:22.04", SandboxClass.LINUX_VM);

            // 2. Create a VM sandbox from the snapshot
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("my-vm-snapshot");
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
# 1. Create a VM snapshot (Linux VM class)
daytona snapshot create my-vm-snapshot --image ubuntu:22.04 --sandbox-class linux-vm

# 2. Create a VM sandbox from the snapshot
daytona create --snapshot my-vm-snapshot
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
# 1. Create a VM snapshot (Linux VM class)
curl https://app.daytona.io/api/snapshots \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
    "name": "my-vm-snapshot",
    "imageName": "ubuntu:22.04",
    "sandboxClass": "linux-vm"
  }'

# 2. Create a VM sandbox from the snapshot
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
    "snapshot": "my-vm-snapshot"
  }'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Default">

Create a Linux VM sandbox from a default snapshot.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Select a VM <Button>Snapshot</Button>: **`daytona-vm-small`**, **`daytona-vm-medium`**, **`daytona-vm-large`**
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(CreateSandboxFromSnapshotParams(snapshot="daytona-vm-small"))
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({ snapshot: 'daytona-vm-small' })
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'daytona-vm-small'
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	params := types.SnapshotParams{
		Snapshot: "daytona-vm-small",
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("daytona-vm-small");
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --snapshot daytona-vm-small
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "daytona-vm-small"
}'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Windows" icon="seti:windows">

Create a Windows sandbox.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Select a Windows <Button>Snapshot</Button>: **`windows-small`**, **`windows-medium`**, **`windows-large`**
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(
        snapshot="windows-small",
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  snapshot: 'windows-small',
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'windows-small'
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	params := types.SnapshotParams{
		Snapshot: "windows-small",
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("windows-small");
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --snapshot windows-small
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "windows-small"
}'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

#### Nested virtualization [#nested-virtualization]

Daytona provides nested virtualization for Linux VM sandboxes. Nested virtualization exposes KVM (`/dev/kvm`) inside the guest, so the sandbox can run its own virtual machines with hardware acceleration.

<Callout type="note">
KVM sandboxes must be enabled for your organization. Contact [support@daytona.io](mailto:support@daytona.io).
</Callout>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(
        snapshot="daytona-vm-small",
        kvm=True,
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  snapshot: 'daytona-vm-small',
  kvm: true,
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'daytona-vm-small',
    kvm: true
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	params := types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{
			Kvm: true,
		},
		Snapshot: "daytona-vm-small",
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("daytona-vm-small");
            params.setKvm(true);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --snapshot daytona-vm-small --kvm
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "daytona-vm-small",
  "kvm": true
}'
```

</TabItem>
</Tabs>

### macOS sandboxes [#macos-sandboxes]

Daytona provides [macOS sandboxes](/docs/macos-sandboxes) for agents that need a macOS operating system.

1. Go to [use.computer ↗](https://use.computer/)
2. Obtain an API key
3. Reserve a Mac
4. Use the API key to create a macOS sandbox

```bash
curl 'https://api.use.computer/v1/sandboxes' \
  --request POST \
  --header 'Authorization: Bearer YOUR_USE_COMPUTER_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{"type":"macos"}'
```

### GPU sandboxes [#gpu-sandboxes]

Daytona provides [GPU sandboxes](/docs/gpu-sandboxes) for agents doing GPU-accelerated work, such as writing and profiling CUDA kernels, 3D and graphics workloads, and other GPU-accelerated compute. GPU sandboxes are ephemeral and support up to **8 GPUs**. Resource limits scale with the number of GPU units: each GPU adds up to **16 vCPUs**, **192GB RAM**, and **512GB disk**. Supported **NVIDIA** and **AMD** GPU types:

- **NVIDIA H100**
- **NVIDIA H200**
- **NVIDIA B200**
- **NVIDIA B300**
- **NVIDIA RTX Pro 6000**
- **NVIDIA RTX 4090**
- **NVIDIA RTX 5090**
- **AMD Instinct MI355X**

GPU sandboxes are on-demand. See [spot GPU sandboxes](#spot-gpu-sandboxes) for preemptible GPU capacity. Use the [GPU capacity](#gpu-capacity) endpoint to check available GPU units before creating a sandbox. When no GPU capacity is available, a GPU sandbox waits until capacity frees up.

GPU sandboxes on shared regions run in the [earth region](/docs/regions#earth-region). Daytona selects the shared region, ignores the requested target, and reports `earth` as the sandbox `target`. GPU sandboxes on [dedicated](/docs/regions#dedicated-regions) and [custom](/docs/regions#custom-regions) regions keep their real region ID. To run GPU sandboxes in a specific geographic location, contact [support@daytona.io](mailto:support@daytona.io).

<Tabs syncKey="gpu-create">
<TabItem label="Custom">

Create a GPU sandbox with custom GPU resources: units and types.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Enter an <Button>Image</Button> (e.g. **`pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime`**)
4. Set <Button>GPU</Button> to the number of GPU units (e.g. **`1`**)
5. Select <Button>GPU Type</Button>: **`H100`**, **`H200`**, **`B200`**, **`B300`**, **`RTX-PRO-6000`**, **`RTX-4090`**, **`RTX-5090`**, **`MI355X`**

    The GPU type field accepts a single value or an ordered list of preferred types.

    Daytona uses the first available type in the order you provide. This lets you fall back from a preferred GPU to an alternative when the first choice is not available.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromImageParams, Resources, GpuType

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromImageParams(
        image="pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime",
        auto_delete_interval=0,
        resources=Resources(
            gpu=1,
            gpu_type=[GpuType.H100, GpuType.RTX_PRO_6000],
        ),
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona, GpuType } from "@daytona/sdk";

const daytona = new Daytona()
const sandbox = await daytona.create({
  image: "pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime",
  autoDeleteInterval: 0,
  resources: {
    gpu: 1,
    gpuType: [GpuType.H100, GpuType.RTX_PRO_6000],
  },
});
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromImageParams.new(
    image: 'pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime',
    auto_delete_interval: 0,
    resources: Daytona::Resources.new(
      gpu: 1,
      gpu_type: [Daytona::GpuType::H100, Daytona::GpuType::RTX_PRO_6000]
    )
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	autoDelete := 0
	_, _ = client.Create(ctx, types.ImageParams{
		Image: "pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime",
		SandboxBaseParams: types.SandboxBaseParams{
			AutoDeleteInterval: &autoDelete,
		},
		Resources: &types.Resources{
			GPU:     1,
			GpuType: []types.GpuType{types.GpuTypeH100, types.GpuTypeRtxPro6000},
		},
	})
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromImageParams;
import io.daytona.sdk.model.Resources;
import io.daytona.api.client.model.GpuType;
import java.util.List;

final class CreateGpuSandbox {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromImageParams params = new CreateSandboxFromImageParams();
            params.setImage("pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime");
            params.setAutoDeleteInterval(0);
            Resources resources = new Resources();
            resources.setGpu(1);
            resources.setGpuType(List.of(GpuType.H100, GpuType.RTX_PRO_6000));
            params.setResources(resources);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "buildInfo": {
    "dockerfileContent": "FROM pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime\n"
  },
  "autoDeleteInterval": 0,
  "gpu": 1,
  "gpuType": ["H100", "RTX-PRO-6000"]
}'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Default">

Create a GPU sandbox from a default snapshot.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Select a GPU <Button>Snapshot</Button>: **`daytona-gpu`**
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(
        snapshot="daytona-gpu",
        auto_delete_interval=0,
    ),
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from "@daytona/sdk";

const daytona = new Daytona()
const sandbox = await daytona.create({
  snapshot: "daytona-gpu",
  ephemeral: true,
});
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'daytona-gpu',
    ephemeral: true
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	params := types.SnapshotParams{
		Snapshot: "daytona-gpu",
		SandboxBaseParams: types.SandboxBaseParams{
			Ephemeral: true,
		},
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("daytona-gpu");
            params.setAutoDeleteInterval(0);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --snapshot daytona-gpu --auto-delete 0
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "daytona-gpu",
  "autoDeleteInterval": 0
}'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

### Spot GPU sandboxes [#spot-gpu-sandboxes]

Spot GPU sandboxes are preemptible and run on GPU capacity that is not being used by reserved (on-demand) sandboxes. They support the same GPU types, unit counts, and resource limits as on-demand GPU sandboxes. 

A spot GPU sandbox can be terminated at any time without notice when an on-demand GPU sandbox needs the capacity. Daytona does not send a preemption warning or a dedicated preemption webhook. Design workloads to tolerate immediate interruption.

When a spot GPU sandbox is destroyed, normal [sandbox lifecycle state](#sandbox-lifecycle) updates still apply. Daytona records when the preemption occurred with a `spotEvictedAt` timestamp. Sandboxes destroyed by spot GPU preemption remain retrievable for 24 hours.

Spot GPU sandboxes require Tier 2 or higher. Spot GPU sandboxes do not count against the organization's GPU quota. Available GPU capacity is the only limit. If no spot GPU is available, create fails immediately.

<Tabs syncKey="gpu-create">
<TabItem label="Custom">

Create a spot GPU sandbox with custom GPU resources: units and types.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromImageParams, Resources, GpuType

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromImageParams(
        image="pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime",
        auto_delete_interval=0,
        spot=True,
        resources=Resources(gpu=1, gpu_type=GpuType.H100),
    )
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona, GpuType } from "@daytona/sdk";

const daytona = new Daytona()
const sandbox = await daytona.create({
  image: "pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime",
  autoDeleteInterval: 0,
  spot: true,
  resources: {
    gpu: 1,
    gpuType: GpuType.H100,
  },
});
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromImageParams.new(
    image: 'pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime',
    auto_delete_interval: 0,
    spot: true,
    resources: Daytona::Resources.new(gpu: 1, gpu_type: Daytona::GpuType::H100)
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	autoDelete := 0
	_, _ = client.Create(ctx, types.ImageParams{
		Image: "pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime",
		SandboxBaseParams: types.SandboxBaseParams{
			AutoDeleteInterval: &autoDelete,
			Spot:               true,
		},
		Resources: &types.Resources{
			GPU:     1,
			GpuType: []types.GpuType{types.GpuTypeH100},
		},
	})
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromImageParams;
import io.daytona.sdk.model.Resources;
import io.daytona.api.client.model.GpuType;
import java.util.List;

final class CreateSpotGpuSandbox {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromImageParams params = new CreateSandboxFromImageParams();
            params.setImage("pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime");
            params.setAutoDeleteInterval(0);
            params.setSpot(true);
            Resources resources = new Resources();
            resources.setGpu(1);
            resources.setGpuType(List.of(GpuType.H100));
            params.setResources(resources);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "buildInfo": {
    "dockerfileContent": "FROM pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime\n"
  },
  "autoDeleteInterval": 0,
  "spot": true,
  "gpu": 1,
  "gpuType": ["H100"]
}'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Default">

Create a spot GPU sandbox from a default snapshot.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(
        snapshot="daytona-gpu",
        auto_delete_interval=0,
        spot=True,
    ),
)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from "@daytona/sdk";

const daytona = new Daytona()
const sandbox = await daytona.create({
  snapshot: "daytona-gpu",
  autoDeleteInterval: 0,
  spot: true,
});
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'daytona-gpu',
    auto_delete_interval: 0,
    spot: true
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()
	autoDelete := 0
	params := types.SnapshotParams{
		Snapshot: "daytona-gpu",
		SandboxBaseParams: types.SandboxBaseParams{
			AutoDeleteInterval: &autoDelete,
			Spot:               true,
		},
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("daytona-gpu");
            params.setAutoDeleteInterval(0);
            params.setSpot(true);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "daytona-gpu",
  "autoDeleteInterval": 0,
  "spot": true
}'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

### GPU capacity [#gpu-capacity]

Get the available GPU capacity. The response lists available GPU units by GPU type, split into on-demand and spot. Capacity is aggregated across all shared regions in the [earth region](/docs/regions#earth-region) and changes as sandboxes are created and deleted. The response does not reserve capacity and does not apply the organization's GPU quota. On-demand GPU sandboxes remain subject to the quota. Spot GPU sandboxes are limited only by available capacity.

<Tabs syncKey="language">
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/organizations/ORGANIZATION_ID/gpu-capacity' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

Response example:

```json
{
  "observedAt": "2026-09-14T17:31:05.412Z",
  "capacity": [
    { "gpuType": "H100", "availableOnDemand": 12, "availableSpot": 4 },
    { "gpuType": "H200", "availableOnDemand": 0, "availableSpot": 0 },
    { "gpuType": "RTX-PRO-6000", "availableOnDemand": 6, "availableSpot": 6 }
  ]
}
```

| **Field**               | **Description**                                                                                                      |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **`observedAt`**        | Time the capacity was calculated. Responses are cached for up to five seconds.                                       |
| **`capacity`**          | One entry per GPU type.                                                                                              |
| **`gpuType`**           | **`H100`**, **`H200`**, **`B200`**, **`B300`**, **`RTX-PRO-6000`**, **`RTX-4090`**, **`RTX-5090`**, or **`MI355X`**. |
| **`availableOnDemand`** | GPU units available to on-demand GPU sandboxes. Includes units held by spot GPU sandboxes that Daytona can reclaim.  |
| **`availableSpot`**     | GPU units currently free for spot GPU sandboxes.                                                                     |

### Ephemeral sandboxes [#ephemeral-sandboxes]

Create an ephemeral sandbox. Ephemeral sandboxes are automatically deleted when stopped.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Set <Button>Ephemeral</Button> or set the [auto-delete interval](#auto-delete-interval) to **`0`**
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
params = CreateSandboxFromSnapshotParams(
    ephemeral=True,
    auto_stop_interval=5,
)
sandbox = daytona.create(params)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()
const sandbox = await daytona.create({
  ephemeral: true,
  autoStopInterval: 5,
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new
params = Daytona::CreateSandboxFromSnapshotParams.new(
  ephemeral: true,
  auto_stop_interval: 5
)
sandbox = daytona.create(params)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()

	autoStopInterval := 5
	params := types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{
			Language:         types.CodeLanguagePython,
			Ephemeral:        true,
			AutoStopInterval: &autoStopInterval,
		},
	}
	_, _ = client.Create(ctx, params)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setAutoDeleteInterval(0);
            params.setAutoStopInterval(5);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona create --auto-delete 0 --auto-stop 5
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "autoDeleteInterval": 0,
  "autoStopInterval": 5
}'
```

</TabItem>
</Tabs>

### Linked sandboxes [#linked-sandboxes]

Create a linked sandbox. Linked sandboxes attach ephemeral child sandboxes to a parent. Daytona schedules each child on the same runner as the parent and joins them into a shared link network so the group can communicate over local connections.

- **Lifecycle**

  Linked sandboxes are always ephemeral and cannot be persisted or resumed after stop. The [auto-delete interval](#auto-delete-interval) must be exactly `0` on create; this is enforced, not a default. The [auto-stop interval](#auto-stop-interval) sets the idle period in minutes after which the child sandbox stops. Once stopped, linked children are auto-deleted. Deleting the parent deletes all of its linked children (cascade). One parent may have many linked children (1:N).

- **Networking**

  Linked sandboxes share an internal link network. Connections work in both directions: the parent can reach each child and each child can reach the parent. Every sandbox on the link network is registered under its sandbox name and ID as DNS aliases, so either works as the host. For example: `telnet LINKED_SANDBOX_ID 5555` from the parent reaches port `5555` on the linked child sandbox.

1. Create a parent sandbox
2. Create one or more child sandboxes that reference the parent's sandbox ID. 

This records the relationship on the child sandbox as the linked sandbox ID. Omitting the linked sandbox parameter yields an unlinked sandbox.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams, Daytona

daytona = Daytona()

parent = daytona.create()

child = daytona.create(
    CreateSandboxFromSnapshotParams(
        linked_sandbox=parent.id,
        ephemeral=True,
    )
)

# The link network registers each sandbox under its name as a DNS alias
response = child.process.exec(f"curl http://{parent.name}:3000/")
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
import { Daytona } from '@daytona/sdk'

const daytona = new Daytona()

const parent = await daytona.create()

const child = await daytona.create({
  linkedSandbox: parent.id,
  ephemeral: true,
})

// The link network registers each sandbox under its name as a DNS alias
const response = await child.process.executeCommand(
  `curl http://${parent.name}:3000/`
)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
require 'daytona'

daytona = Daytona::Daytona.new

parent = daytona.create

child = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    linked_sandbox: parent.id,
    ephemeral: true
  )
)

# The link network registers each sandbox under its name and ID as DNS aliases.
# The Ruby SDK does not expose the sandbox name, so address the parent by ID.
response = child.process.exec(command: "curl http://#{parent.id}:3000/")
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
package main

import (
	"context"
	"fmt"

	"github.com/daytona/clients/sdk-go/pkg/daytona"
	"github.com/daytona/clients/sdk-go/pkg/types"
)

func main() {
	client, _ := daytona.NewClient()
	ctx := context.Background()

	parent, _ := client.Create(ctx, types.SnapshotParams{})

	child, _ := client.Create(ctx, types.SnapshotParams{
		SandboxBaseParams: types.SandboxBaseParams{
			LinkedSandbox: parent.ID,
			Ephemeral:     true,
		},
	})

	// The link network registers each sandbox under its name as a DNS alias
	response, _ := child.Process.ExecuteCommand(ctx, fmt.Sprintf("curl http://%s:3000/", parent.Name))
	fmt.Println(response.Result)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;
import io.daytona.sdk.model.ExecuteResponse;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            Sandbox parent = daytona.create();

            CreateSandboxFromSnapshotParams childParams = new CreateSandboxFromSnapshotParams();
            childParams.setLinkedSandbox(parent.getId());
            childParams.setAutoDeleteInterval(0); // linked sandboxes must be ephemeral
            Sandbox child = daytona.create(childParams);

            // The link network registers each sandbox under its name as a DNS alias
            ExecuteResponse response = child.getProcess()
                    .executeCommand("curl http://" + parent.getName() + ":3000/");
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
# Create parent sandbox
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{}'

# Create linked child sandbox (replace PARENT_SANDBOX_ID with the id from the first response)
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "linkedSandbox": "PARENT_SANDBOX_ID",
  "autoDeleteInterval": 0
}'
```

</TabItem>
</Tabs>

## Sandbox operations [#sandbox-operations]

Sandbox operations manage sandboxes after creation. They cover discovery, inspection, and updates to sandbox metadata and resources. Once a sandbox exists, you can find it among others in your organization, inspect its configuration, and update attributes such as metadata and allocated resources. A sandbox transitions between states such as started, stopped, paused, and archived as part of the [sandbox lifecycle](#sandbox-lifecycle).

### List sandboxes [#list-sandboxes]

List sandboxes.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
for sandbox in daytona.list():
    print(sandbox.id)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
for await (const sandbox of daytona.list()) {
  console.log(sandbox.id)
}
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
daytona.list.each { |sandbox| puts sandbox.id }
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
iter := client.List(ctx, nil)
for iter.Next() {
    sandbox := iter.Value()
    fmt.Println(sandbox.ID)
}
if err := iter.Err(); err != nil {
    log.Fatal(err)
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
for (Sandbox sandbox : daytona.list()) {
    System.out.println(sandbox.getId());
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona list [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Get sandbox [#get-sandbox]

Get a sandbox by ID or name.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox = daytona.get("my-sandbox-id-or-name")
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.get('my-sandbox-id-or-name')
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.get('my-sandbox-id-or-name')
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox, err := client.Get(ctx, "my-sandbox-id-or-name")
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
Sandbox sandbox = daytona.get("my-sandbox-id-or-name");
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona info [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Label sandboxes [#label-sandboxes]

Set sandbox labels.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Click <Button>Add Labels</Button>
4. Enter the labels in key-value pairs

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.set_labels({
    "team": "platform",
    "env": "staging",
})
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.setLabels({
  team: 'platform',
  env: 'staging',
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.labels = {
  team: 'platform',
  env: 'staging'
}
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
err := sandbox.SetLabels(ctx, map[string]string{
	"team": "platform",
	"env":  "staging",
})
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
Map<String, String> labels = new HashMap<>();
labels.put("team", "platform");
labels.put("env", "staging");
sandbox.setLabels(labels);
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/labels' \
  --request PUT \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "labels": {
    "team": "platform",
    "env": "staging"
  }
}'
```

</TabItem>
</Tabs>

### Resize sandboxes [#resize-sandboxes]

Resizing updates the sandbox resource allocation (CPU, memory, and disk) for that sandbox. CPU and memory control compute capacity for running workloads, while disk controls the persistent filesystem capacity.

On a running sandbox, you can increase CPU and memory without interruption. To decrease CPU or memory, or to increase disk capacity, stop the sandbox first. Disk size can only be increased and cannot be decreased.

<Callout type="note">
Sandbox resizing must be enabled for your organization. Contact [support@daytona.io](mailto:support@daytona.io).
</Callout>

1. Choose the new **CPU**, **memory**, and **disk** values within your organization's limits
2. Ensure the sandbox is **stopped** if you need to decrease CPU or memory, or increase disk
3. **Resize** the sandbox with the new resource values
4. **Start** the sandbox

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import Resources

# Resize a started sandbox (CPU and memory can be increased)
sandbox.resize(Resources(cpu=2, memory=4))

# Resize a stopped sandbox (CPU and memory can change, disk can only increase)
sandbox.stop()
sandbox.resize(Resources(cpu=4, memory=8, disk=20))
sandbox.start()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
// Resize a started sandbox (CPU and memory can be increased)
await sandbox.resize({ cpu: 2, memory: 4 })

// Resize a stopped sandbox (CPU and memory can change, disk can only increase)
await sandbox.stop()
await sandbox.resize({ cpu: 4, memory: 8, disk: 20 })
await sandbox.start()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
# Resize a started sandbox (CPU and memory can be increased)
sandbox.resize(Daytona::Resources.new(cpu: 2, memory: 4))

# Resize a stopped sandbox (CPU and memory can change, disk can only increase)
sandbox.stop
sandbox.resize(Daytona::Resources.new(cpu: 4, memory: 8, disk: 20))
sandbox.start
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Resize a started sandbox (CPU and memory can be increased)
err := sandbox.Resize(ctx, &types.Resources{CPU: 2, Memory: 4})

// Resize a stopped sandbox (CPU and memory can change, disk can only increase)
err = sandbox.Stop(ctx)
err = sandbox.Resize(ctx, &types.Resources{CPU: 4, Memory: 8, Disk: 20})
err = sandbox.Start(ctx)
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/resize' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "cpu": 2,
  "memory": 4,
  "disk": 20
}'
```

</TabItem>
</Tabs>

To verify CPU and memory limits inside the sandbox after resizing, read `cgroup` values directly. Tools such as `nproc`, `free`, `top`, `htop`, `/proc/cpuinfo`, and `/proc/meminfo` read host-level values and do not reflect sandbox resource limits.

```bash
cat /sys/fs/cgroup/cpu.max      # "<quota> <period>" (cores = quota / period)
cat /sys/fs/cgroup/memory.max   # bytes
df -h /                         # disk
```

## Sandbox lifecycle [#sandbox-lifecycle]

Every sandbox moves through a lifecycle. A sandbox can have several different states. Each state reflects the status of your sandbox. A sandbox transitions between states in response to user actions, or through [automated lifecycle management](#automated-lifecycle-management) based on inactivity intervals. Available lifecycle features depend on the sandbox class.

<SandboxDiagram />

| **Lifecycle feature**                             | **Container** | **Linux VM** | **Windows** | **GPU** |
| ------------------------------------------------- | ------------- | ------------ | ----------- | ------- |
| Start sandboxes                                   | ✓             | ✓            | ✓           | ✓       |
| Pause / resume sandboxes                          | ✗             | ✓            | ✓           | ✗       |
| Stop sandboxes                                    | ✓             | ✓            | ✓           | ✓       |
| Archive sandboxes                                 | ✓             | ✗            | ✗           | ✗       |
| Fork sandboxes                                    | ✗             | ✓            | ✓           | ✗       |
| Snapshot from sandbox <br />(filesystem only)     | ✓             | ✓            | ✓           | ✓       |
| Snapshot from sandbox <br />(filesystem + memory) | ✗             | ✓            | ✓           | ✗       |

<Collapsible title="Sandbox states">

| **State**         | **Description**                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------- |
| Creating          | The sandbox is provisioning and will be ready to use.                                       |
| Pulling Snapshot  | The sandbox is pulling a [**snapshot**](/docs/snapshots) to provide a base environment.  |
| Building Snapshot | The sandbox is building a [**snapshot**](/docs/snapshots) to provide a base environment. |
| Pending Build     | The sandbox build is pending and will start shortly. GPU sandboxes wait in this state until [GPU capacity](#gpu-capacity) is available. |
| Build Failed      | The sandbox build failed and needs to be retried.                                           |
| Starting          | The sandbox is starting and will be ready to use.                                           |
| Started           | The sandbox has started and is ready to use.                                                |
| Stopping          | The sandbox is stopping and will no longer accept requests.                                 |
| Stopped           | The sandbox has stopped and is no longer running. Container sandboxes keep their filesystem on the runner. VM sandboxes offload filesystem state to nearby storage. |
| Pausing           | The VM sandbox is pausing while its filesystem and memory state are preserved.              |
| Paused            | The VM sandbox is paused with filesystem and memory state preserved. State is offloaded to nearby storage. |
| Resuming          | The VM sandbox is resuming from a paused state and will be ready to use.                    |
| Archiving         | The container sandbox filesystem is being moved to object storage.                          |
| Archived          | The container sandbox filesystem is stored in object storage.                               |
| Restoring         | The sandbox is being restored and will be ready to use shortly.                             |
| Resizing          | The sandbox is being resized to a new set of resources.                                     |
| Snapshotting      | The sandbox is creating a [**snapshot**](/docs/snapshots) of its filesystem and memory.  |
| Forking           | The sandbox is being forked into a new independent sandbox.                                 |
| Deleting          | The sandbox is deleting and will be removed.                                                |
| Deleted           | The sandbox has been deleted and no longer exists.                                          |
| Error             | The sandbox is in an error state and needs to be recovered.                                 |
| Unknown           | The default sandbox state before it is created.                                             |

</Collapsible>

A sandbox can transition between states in response to various actions. The following table lists the initial state, target state, and trigger for the transition.

<Collapsible title="State transitions">

| **Initial state** | **Target state**  | **Trigger**                                                                       |
| ----------------- | ----------------- | --------------------------------------------------------------------------------- |
| Unknown           | Pulling Snapshot  | The base snapshot is being pulled to provide the sandbox environment.             |
| Unknown           | Building Snapshot | The sandbox uses a declarative image build, which begins building.                |
| Pending Build     | Building Snapshot | The queued image build starts.                                                    |
| Building Snapshot | Build Failed      | The image build fails or times out.                                               |
| Pulling Snapshot  | Creating          | The snapshot is available and the sandbox container is created.                   |
| Building Snapshot | Creating          | The snapshot finishes building and the sandbox container is created.              |
| Creating          | Started           | The sandbox container finishes initializing and is running.                       |
| Stopped           | Starting          | A start is requested and the sandbox boots.                                       |
| Stopped           | Restoring         | A start is requested and the sandbox is restored from a backup.                   |
| Archived          | Restoring         | A start is requested and the archived filesystem is restored from object storage. |
| Restoring         | Started           | The restore completes and the sandbox is running.                                 |
| Starting          | Started           | The sandbox is running and ready to accept requests.                              |
| Started           | Stopping          | A stop is requested, or the auto-stop interval is exceeded.                       |
| Stopping          | Stopped           | The sandbox process exits and its memory state is cleared.                        |
| Started           | Pausing           | A pause is requested, or the auto-pause interval is exceeded.                     |
| Pausing           | Paused            | The filesystem and memory state are preserved.                                    |
| Paused            | Resuming          | A start is requested on a paused sandbox.                                         |
| Paused            | Stopping          | A stop is requested on a paused sandbox.                                          |
| Resuming          | Started           | The sandbox resumes from memory and is running.                                   |
| Stopped           | Archiving         | An archive is requested, or the auto-archive interval is exceeded.                |
| Archiving         | Archived          | The backup completes and the filesystem is moved to object storage.               |
| Started           | Resizing          | CPU or memory is increased on a running sandbox.                                  |
| Stopped           | Resizing          | Resources are changed on a stopped sandbox.                                       |
| Resizing          | Started           | The running sandbox returns to service after resizing.                            |
| Resizing          | Stopped           | The stopped sandbox completes resizing.                                           |
| Started           | Snapshotting      | A snapshot of the filesystem and memory is created.                               |
| Stopped           | Snapshotting      | A snapshot of the filesystem is created.                                          |
| Snapshotting      | Started           | The snapshot completes and the sandbox returns to service.                        |
| Snapshotting      | Stopped           | The snapshot completes and the sandbox remains stopped.                           |
| Started           | Forking           | The sandbox is forked into a new independent sandbox.                             |
| Forking           | Started           | The fork completes and the sandbox returns to service.                            |
| Started           | Deleting          | A delete is requested, or the auto-delete interval is exceeded.                   |
| Stopped           | Deleting          | A delete is requested.                                                            |
| Archived          | Deleted           | An archived sandbox is deleted directly without being restored.                   |
| Deleting          | Deleted           | The sandbox is removed and its resources are released.                            |
| Started           | Error             | An operation fails or times out.                                                  |
| Error             | Restoring         | A recover is requested for a recoverable error and the sandbox is restored.       |
| Error             | Archiving         | An errored sandbox with a completed backup is archived to preserve its state.     |

</Collapsible>

### Start sandboxes [#start-sandboxes]

Start a sandbox.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click the start icon <Button>▶</Button> next to the sandbox you want to start

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.start()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.start()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.start
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Start(ctx)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.start();
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona start [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/start' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

<a id="pause-sandboxes"></a>
### Pause / resume sandboxes [#pause--resume-sandboxes]

Pause and resume a sandbox.

<Tabs syncKey="sandbox-class">
<TabItem label="Container" icon="seti:docker">

Pause is not supported for container sandboxes. The filesystem can be preserved on stop, but memory state is not. Use <u>[**stop**](#stop-sandboxes)</u> to shut down a container sandbox when it is not in use.

</TabItem>
<TabItem label="Linux VM" icon="linux">

The filesystem and memory state are preserved, and CPU is no longer consumed.

1. Ensure the Linux VM sandbox is **started**
2. **Pause** the Linux VM sandbox
3. Wait for the Linux VM sandbox to reach the **paused** state
4. **Resume** (start) the Linux VM sandbox again when you need to resume it

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.pause()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.pause()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.pause
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Pause(ctx)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.pause();
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona pause [SANDBOX_ID] | [SANDBOX_NAME]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/pause' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Windows" icon="seti:windows">

The filesystem and memory state are preserved, and CPU is no longer consumed.

1. Ensure the Windows sandbox is **started**
2. **Pause** the Windows sandbox
3. Wait for the Windows sandbox to reach the **paused** state
4. **Resume** (start) the Windows sandbox again when you need to resume it

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.pause()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.pause()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.pause
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Pause(ctx)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.pause();
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona pause [SANDBOX_ID] | [SANDBOX_NAME]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/pause' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

### Stop sandboxes [#stop-sandboxes]

Stop a sandbox. The sandbox moves to the **stopped** state when shutdown completes. While a stop is in progress, the sandbox is in the **stopping** state and does not accept new requests.

<Tabs syncKey="sandbox-class">
<TabItem label="Container" icon="seti:docker">

Stopping terminates the running container. The filesystem is preserved, but memory state is not. Container sandboxes do not support pause; stop is the way to shut down a container sandbox when it is not in use.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click the stop icon (**⏹**) next to the sandbox you want to stop

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.stop()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.stop()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.stop
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Stop(ctx)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.stop();
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona stop [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/stop' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Linux VM" icon="linux">

Stopping shuts down the virtual machine while preserving the filesystem. Memory state is cleared. To preserve running process state without consuming CPU, use <u>[**pause / resume**](#pause--resume-sandboxes)</u>.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click the stop icon (**⏹**) next to the sandbox you want to stop

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.stop()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.stop()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.stop
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Stop(ctx)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.stop();
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona stop [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/stop' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Windows" icon="seti:windows">

Stopping shuts down the virtual machine while preserving the filesystem. Memory state is cleared. To preserve running process state without consuming CPU, use <u>[**pause / resume**](#pause--resume-sandboxes)</u>.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click the stop icon (**⏹**) next to the sandbox you want to stop

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.stop()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.stop()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.stop
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Stop(ctx)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.stop();
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona stop [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/stop' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

<Callout type="note" title="Force stop">
If you need a faster shutdown, use force stop (`force=true` / `--force`) to terminate the sandbox immediately. Force stop is ungraceful and should be used when quick termination is more important than process cleanup. Avoid force stop for normal shutdowns where the process should flush buffers, write final state, or run cleanup.
</Callout>

### Archive sandboxes [#archive-sandboxes]

Archive a sandbox.

<Tabs syncKey="sandbox-class">
<TabItem label="Container" icon="seti:docker">

Archive moves a stopped sandbox's filesystem to object storage and frees disk quota.

1. Ensure the sandbox is **stopped**
2. **Archive** the sandbox
3. Wait for the sandbox to reach the **archived** state
4. **Start** the sandbox again when you need to use it

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.archive()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.archive()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.archive
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
sandbox.Archive(ctx)
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona archive [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/archive' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Linux VM" icon="linux">

Archive is not supported for Linux VM sandboxes. Stopping a Linux VM sandbox already offloads filesystem state and releases disk quota, so a separate archive step is not needed.

</TabItem>
<TabItem label="Windows" icon="seti:windows">

Archive is not supported for Windows sandboxes. Stopping a Windows sandbox already offloads filesystem state and releases disk quota, so a separate archive step is not needed.

</TabItem>
</Tabs>

### Delete sandboxes [#delete-sandboxes]

Delete a sandbox. 

<Callout type="note">
By default delete is fire-and-forget: it returns as soon as the API accepts the deletion request, without waiting for the sandbox to be destroyed. Pass the `wait` flag to block until the sandbox reaches the destroyed state.
</Callout>

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Delete</Button> next to the sandbox you want to delete.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.delete()

# Block until the sandbox is destroyed
sandbox.delete(timeout=60, wait=True)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.delete()

// Block until the sandbox is destroyed
await sandbox.delete(60, true)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.delete

# Block until the sandbox is destroyed
sandbox.delete(60, wait: true)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
err = sandbox.Delete(ctx)

// Block until the sandbox is destroyed
err = sandbox.DeleteAndWait(ctx, 60*time.Second)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
sandbox.delete();

// Block until the sandbox is destroyed
sandbox.delete(60, true);
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
daytona delete [SANDBOX_ID] | [SANDBOX_NAME] [flags]
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}' \
  --request DELETE \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Recover sandboxes [#recover-sandboxes]

Recover a sandbox.

1. Ensure the sandbox is in **error** state
2. Check that the sandbox is **recoverable**
3. Resolve any underlying issue that requires user intervention
4. **Recover** the sandbox and wait for it to be ready

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
# Check if the sandbox is recoverable
if sandbox.recoverable:
    sandbox.recover()
```

```python
sandbox.recover()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
// Check if the sandbox is recoverable
if (sandbox.recoverable) {
  await sandbox.recover()
}
```

```typescript
await sandbox.recover()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
# Check if the sandbox is in an error state before recovering
if sandbox.state == 'error'
  sandbox.recover
end
```

```ruby
sandbox.recover
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/recover' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/recover' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Fork sandboxes [#fork-sandboxes]

Fork a sandbox.

<Tabs syncKey="sandbox-class">
<TabItem label="Container" icon="seti:docker">

Forking is not supported for container sandboxes. Use <u>[**create snapshot from sandbox**](/docs/snapshots#create-snapshot-from-sandbox)</u> to capture filesystem state, then create a new sandbox from that snapshot.

</TabItem>
<TabItem label="Linux VM" icon="linux">

Forking creates a duplicate of a Linux VM sandbox's filesystem and memory state in a new sandbox. The forked sandbox is fully independent: it can be started, stopped, and deleted without affecting the original.

Daytona tracks the parent-child relationship in a fork tree, so you can trace a fork's lineage back to the sandbox it was created from. You can fork a fork to build branches. The parent sandbox cannot be deleted while it has active fork children.

A fork of a [KVM sandbox](#nested-virtualization) inherits the `kvm` setting. Forking a KVM sandbox returns a `403` error if KVM sandboxes are not enabled for your organization.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click the three-dot menu (**⋮**) next to the started Linux VM sandbox you want to fork
3. Select <Button>Fork</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
# Fork sandbox through the Sandbox instance
forked = sandbox.fork(name="my-forked-sandbox")
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
// Fork sandbox through the Sandbox instance
const forkedSandbox = await sandbox.fork({ name: "my-forked-sandbox" });

// Or use the Daytona helper method
const helperForkedSandbox = await daytona.fork(sandbox, { name: "my-forked-sandbox" });
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
# Fork sandbox through the Sandbox instance
forkedSandbox = sandbox.fork(name: "my-forked-sandbox")
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Fork sandbox through the Sandbox instance
name := "my-forked-sandbox"
forkedSandbox, err := sandbox.Fork(ctx, &name)
if err != nil {
    return err
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
// Fork sandbox through the Sandbox instance
Sandbox forkedSandbox = sandbox.fork("my-forked-sandbox", 60);
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/fork' \
  --request POST \
  --header 'X-Daytona-Organization-ID: YOUR_ORGANIZATION_ID' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "name": "my-forked-sandbox"
}'
```

Query fork relationships:

```bash
# List direct fork children of a sandbox
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/forks' \
  --header 'Authorization: Bearer YOUR_API_KEY'

# Get the parent sandbox of a fork
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/parent' \
  --header 'Authorization: Bearer YOUR_API_KEY'

# Get the full ancestor chain (parent, grandparent, and so on)
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/ancestors' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Windows" icon="seti:windows">

Forking creates a duplicate of a Windows sandbox's filesystem and memory state in a new sandbox. The forked sandbox is fully independent: it can be started, stopped, and deleted without affecting the original.

Daytona tracks the parent-child relationship in a fork tree, so you can trace a fork's lineage back to the sandbox it was created from. You can fork a fork to build branches. The parent sandbox cannot be deleted while it has active fork children.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click the three-dot menu (**⋮**) next to the started Windows sandbox you want to fork
3. Select <Button>Fork</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
# Fork sandbox through the Sandbox instance
forked = sandbox.fork(name="my-forked-sandbox")
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
// Fork sandbox through the Sandbox instance
const forkedSandbox = await sandbox.fork({ name: "my-forked-sandbox" });

// Or use the Daytona helper method
const helperForkedSandbox = await daytona.fork(sandbox, { name: "my-forked-sandbox" });
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
# Fork sandbox through the Sandbox instance
forkedSandbox = sandbox.fork(name: "my-forked-sandbox")
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Fork sandbox through the Sandbox instance
name := "my-forked-sandbox"
forkedSandbox, err := sandbox.Fork(ctx, &name)
if err != nil {
    return err
}
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
// Fork sandbox through the Sandbox instance
Sandbox forkedSandbox = sandbox.fork("my-forked-sandbox", 60);
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/fork' \
  --request POST \
  --header 'X-Daytona-Organization-ID: YOUR_ORGANIZATION_ID' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "name": "my-forked-sandbox"
}'
```

Query fork relationships:

```bash
# List direct fork children of a sandbox
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/forks' \
  --header 'Authorization: Bearer YOUR_API_KEY'

# Get the parent sandbox of a fork
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/parent' \
  --header 'Authorization: Bearer YOUR_API_KEY'

# Get the full ancestor chain (parent, grandparent, and so on)
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/ancestors' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
</Tabs>

## Automated lifecycle management [#automated-lifecycle-management]

Sandboxes can be managed automatically based on user-defined deadlines. Inactivity and stopped-time intervals stop, pause, archive, or delete a sandbox when it is idle. Wall-clock TTL destroys a sandbox after a fixed deadline regardless of state.

- **[Auto-stop interval](#auto-stop-interval)**: stop a sandbox after a specified period of inactivity
- **[Auto-pause interval](#auto-pause-interval)**: pause a VM sandbox after a specified period of inactivity
- **[Auto-archive interval](#auto-archive-interval)**: archive a sandbox after a specified period of inactivity
- **[Auto-delete interval](#auto-delete-interval)**: delete a sandbox after a specified period of inactivity
- **[Wall-clock TTL](#wall-clock-ttl)**: destroy a sandbox after a fixed wall-clock deadline, regardless of state
- **[Update sandbox last activity](#update-sandbox-last-activity)**: signal activity to reset the inactivity timer
- **[Running indefinitely](#running-indefinitely)**: run a sandbox indefinitely

<div id="auto-stop-interval"></div>
### Auto-stop sandboxes [#auto-stop-sandboxes]

The auto-stop interval sets the amount of time after which a running sandbox is automatically stopped. The auto-stop triggers even if there are internal processes running in the sandbox.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Set **`auto-stop`** interval to the desired value in minutes
    - **`0`**: disables the auto-stop functionality, allowing the sandbox to run indefinitely
    - if not set, the default interval of 15 minutes is used
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="my-snapshot",
    # Disables the auto-stop feature - default is 15 minutes
    auto_stop_interval=0,
))
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'my-snapshot',
  // Disables the auto-stop feature - default is 15 minutes
  autoStopInterval: 0,
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'my-snapshot',
    # Disables the auto-stop feature - default is 15 minutes
    auto_stop_interval: 0
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Create a sandbox with auto-stop disabled
autoStopInterval := 0
params := types.SnapshotParams{
    Snapshot: "my-snapshot",
    SandboxBaseParams: types.SandboxBaseParams{
        AutoStopInterval: &autoStopInterval,
    },
}
sandbox, err := client.Create(ctx, params)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("my-snapshot");
            // Disables the auto-stop feature - default is 15 minutes
            params.setAutoStopInterval(0);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/autostop/{interval}' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

The system differentiates between "internal processes" and "active user interaction". Merely having a script or background task running is not sufficient to keep the sandbox alive.

##### What resets the timer [#what-resets-the-timer]

The inactivity timer resets only for specific external interactions:

- Updates to [sandbox lifecycle states](#sandbox-lifecycle)
- Network requests through [sandbox previews](/docs/preview)
- Active [SSH connections](/docs/ssh-access)
- API requests to the [Daytona Toolbox SDK](/docs/api/#daytona-toolbox)

##### What does not reset the timer [#what-does-not-reset-the-timer]

The following do not reset the timer:

- SDK requests that are not toolbox actions
- Background scripts (e.g., `npm run dev` run as a fire-and-forget command)
- Long-running tasks without external interaction
- Processes that don't involve active monitoring

If you run a long-running task like LLM inference that takes more than 15 minutes to complete without any external interaction, the sandbox may auto-stop mid-process because the process itself doesn't count as "activity", therefore the timer is not reset.

<div id="auto-pause-interval"></div>
### Auto-pause sandboxes [#auto-pause-sandboxes]

The auto-pause interval sets the amount of time after which an idle VM sandbox is automatically [paused](#pause--resume-sandboxes). Auto-pause applies only to [VM sandboxes](#vm-sandboxes) and is mutually exclusive with the [auto-stop interval](#auto-stop-interval): at most one of the two intervals may be non-zero. Ephemeral sandboxes cannot have auto-pause enabled.

The interval is set in minutes:

- **`0`**: disables the auto-pause functionality
- if neither auto-pause nor auto-stop is set, non-ephemeral sandbox classes that support pausing default to an auto-pause interval of 60 minutes with auto-stop disabled

The sandbox pauses after no new events occur for the specified interval. Events include sandbox state changes and interactions with the sandbox through the SDK. Interactions through [sandbox previews](/docs/preview) do not reset the timer.

<Tabs syncKey="sandbox-class">
<TabItem label="Container" icon="seti:docker">

Auto-pause is not supported for container sandboxes. Use <u>[**auto-stop**](#auto-stop-interval)</u> to stop a container sandbox after a period of inactivity.

</TabItem>
<TabItem label="Linux VM" icon="linux">

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Select a Linux VM snapshot
4. Set **`auto-pause`** interval to the desired value in minutes
    - **`0`**: disables the auto-pause functionality
    - if neither auto-pause nor auto-stop is set, the default interval of 60 minutes is used with auto-stop disabled
5. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="daytona-vm-small",
    # Auto-pause after 1 hour of inactivity
    auto_pause_interval=60,
))

# Update the auto-pause interval on an existing sandbox
sandbox.set_auto_pause_interval(60)

# Disable auto-pause
sandbox.set_auto_pause_interval(0)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'daytona-vm-small',
  // Auto-pause after 1 hour of inactivity
  autoPauseInterval: 60,
})

// Update the auto-pause interval on an existing sandbox
await sandbox.setAutoPauseInterval(60)

// Disable auto-pause
await sandbox.setAutoPauseInterval(0)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'daytona-vm-small',
    # Auto-pause after 1 hour of inactivity
    auto_pause_interval: 60
  )
)

# Update the auto-pause interval on an existing sandbox
sandbox.auto_pause_interval = 60

# Disable auto-pause
sandbox.auto_pause_interval = 0
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Auto-pause after 1 hour of inactivity
autoPauseInterval := 60
params := types.SnapshotParams{
    Snapshot: "daytona-vm-small",
    SandboxBaseParams: types.SandboxBaseParams{
        AutoPauseInterval: &autoPauseInterval,
    },
}
sandbox, err := client.Create(ctx, params)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("daytona-vm-small");
            // Auto-pause after 1 hour of inactivity
            params.setAutoPauseInterval(60);
            Sandbox sandbox = daytona.create(params);

            // Update the auto-pause interval on an existing sandbox
            sandbox.setAutoPauseInterval(60);

            // Disable auto-pause
            sandbox.setAutoPauseInterval(0);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/autopause/{interval}' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="Windows" icon="seti:windows">

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Select a Windows snapshot
4. Set **`auto-pause`** interval to the desired value in minutes
    - **`0`**: disables the auto-pause functionality
    - if neither auto-pause nor auto-stop is set, the default interval of 60 minutes is used with auto-stop disabled
5. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="windows-small",
    # Auto-pause after 1 hour of inactivity
    auto_pause_interval=60,
))

# Update the auto-pause interval on an existing sandbox
sandbox.set_auto_pause_interval(60)

# Disable auto-pause
sandbox.set_auto_pause_interval(0)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'windows-small',
  // Auto-pause after 1 hour of inactivity
  autoPauseInterval: 60,
})

// Update the auto-pause interval on an existing sandbox
await sandbox.setAutoPauseInterval(60)

// Disable auto-pause
await sandbox.setAutoPauseInterval(0)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'windows-small',
    # Auto-pause after 1 hour of inactivity
    auto_pause_interval: 60
  )
)

# Update the auto-pause interval on an existing sandbox
sandbox.auto_pause_interval = 60

# Disable auto-pause
sandbox.auto_pause_interval = 0
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Auto-pause after 1 hour of inactivity
autoPauseInterval := 60
params := types.SnapshotParams{
    Snapshot: "windows-small",
    SandboxBaseParams: types.SandboxBaseParams{
        AutoPauseInterval: &autoPauseInterval,
    },
}
sandbox, err := client.Create(ctx, params)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("windows-small");
            // Auto-pause after 1 hour of inactivity
            params.setAutoPauseInterval(60);
            Sandbox sandbox = daytona.create(params);

            // Update the auto-pause interval on an existing sandbox
            sandbox.setAutoPauseInterval(60);

            // Disable auto-pause
            sandbox.setAutoPauseInterval(0);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/autopause/{interval}' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

</TabItem>
<TabItem label="GPU" icon="seti:cu">

Auto-pause is not supported for GPU sandboxes. GPU sandboxes are ephemeral and cannot have auto-pause enabled.

</TabItem>
</Tabs>

<div id="auto-archive-interval"></div>
### Auto-archive sandboxes [#auto-archive-sandboxes]

The auto-archive interval sets the amount of time after which a continuously stopped sandbox is automatically archived. Auto-archive applies only to container sandboxes. VM sandboxes are excluded.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Set **`auto-archive`** interval to the desired value in minutes
    - **`0`**: the maximum interval of 30 days is used
    - if not set, the default interval of 7 days is used
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="my-snapshot",
    # Auto-archive after a sandbox has been stopped for 1 hour
    auto_archive_interval=60,
))
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'my-snapshot',
  // Auto-archive after a sandbox has been stopped for 1 hour
  autoArchiveInterval: 60,
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'my-snapshot',
    # Auto-archive after a sandbox has been stopped for 1 hour
    auto_archive_interval: 60
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Create a sandbox with auto-archive after 1 hour
autoArchiveInterval := 60
params := types.SnapshotParams{
    Snapshot: "my-snapshot",
    SandboxBaseParams: types.SandboxBaseParams{
        AutoArchiveInterval: &autoArchiveInterval,
    },
}
sandbox, err := client.Create(ctx, params)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("my-snapshot");
            // Auto-archive after a sandbox has been stopped for 1 hour
            params.setAutoArchiveInterval(60);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/autoarchive/{interval}' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

<div id="auto-delete-interval"></div>
### Auto-delete sandboxes [#auto-delete-sandboxes]

The auto-delete interval sets the amount of time after which a continuously stopped sandbox is automatically deleted.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Set **`auto-delete`** to the desired value in minutes
    - `-1`: disables the auto-delete functionality
    - `0`: the sandbox is deleted immediately after it is stopped
    - if not set, the sandbox is not deleted automatically
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="my-snapshot",
    # Auto-delete after a sandbox has been stopped for 1 hour
    auto_delete_interval=60,
))

# Delete the sandbox immediately after it has been stopped
sandbox.set_auto_delete_interval(0)

# Disable auto-deletion
sandbox.set_auto_delete_interval(-1)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'my-snapshot',
  // Auto-delete after a sandbox has been stopped for 1 hour
  autoDeleteInterval: 60,
})

// Delete the sandbox immediately after it has been stopped
await sandbox.setAutoDeleteInterval(0)

// Disable auto-deletion
await sandbox.setAutoDeleteInterval(-1)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'my-snapshot',
    # Auto-delete after a sandbox has been stopped for 1 hour
    auto_delete_interval: 60
  )
)

# Delete the sandbox immediately after it has been stopped
sandbox.auto_delete_interval = 0

# Disable auto-deletion
sandbox.auto_delete_interval = -1
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Create a sandbox with auto-delete after 1 hour
autoDeleteInterval := 60
params := types.SnapshotParams{
    Snapshot: "my-snapshot",
    SandboxBaseParams: types.SandboxBaseParams{
        AutoDeleteInterval: &autoDeleteInterval,
    },
}
sandbox, err := client.Create(ctx, params)

// Delete the sandbox immediately after it has been stopped
zeroInterval := 0
err = sandbox.SetAutoDeleteInterval(ctx, &zeroInterval)

// Disable auto-deletion
disableInterval := -1
err = sandbox.SetAutoDeleteInterval(ctx, &disableInterval)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("my-snapshot");
            // Auto-delete after a sandbox has been stopped for 1 hour
            params.setAutoDeleteInterval(60);
            Sandbox sandbox = daytona.create(params);

            // Delete the sandbox immediately after it has been stopped
            sandbox.setAutoDeleteInterval(0);

            // Disable auto-deletion
            sandbox.setAutoDeleteInterval(-1);
        }
    }
}
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/autodelete/{interval}' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Wall-clock TTL [#wall-clock-ttl]

The wall-clock TTL (time-to-live) sets a hard upper bound on how long a sandbox may exist. Unlike the [auto-delete interval](#auto-delete-interval), which counts time only while the sandbox is stopped, TTL runs as wall-clock time from creation (or from the moment you last set it) and destroys the sandbox in any state: started, stopped, paused, or archived.

Set `ttl_minutes` when creating a sandbox, or update it later. The value is in minutes:

- **`0`**: disables the TTL
- if not set, the sandbox has no TTL deadline

Calling `set_ttl` after creation resets the deadline from the current moment. Use wall-clock TTL for agent sessions, CI jobs, and any sandbox that must not outlive a fixed deadline.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="my-snapshot",
    # Destroy the sandbox 2 hours after creation, regardless of state
    ttl_minutes=120,
))

# Reset the deadline to 1 hour from now
sandbox.set_ttl(60)

# Disable the TTL
sandbox.set_ttl(0)
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'my-snapshot',
  // Destroy the sandbox 2 hours after creation, regardless of state
  ttlMinutes: 120,
})

// Reset the deadline to 1 hour from now
await sandbox.setTtl(60)

// Disable the TTL
await sandbox.setTtl(0)
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'my-snapshot',
    # Destroy the sandbox 2 hours after creation, regardless of state
    ttl_minutes: 120
  )
)

# Reset the deadline to 1 hour from now
sandbox.ttl_minutes = 60

# Disable the TTL
sandbox.ttl_minutes = 0
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Destroy the sandbox 2 hours after creation, regardless of state
ttlMinutes := 120
params := types.SnapshotParams{
    Snapshot: "my-snapshot",
    SandboxBaseParams: types.SandboxBaseParams{
        TtlMinutes: &ttlMinutes,
    },
}
sandbox, err := client.Create(ctx, params)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("my-snapshot");
            // Destroy the sandbox 2 hours after creation, regardless of state
            params.setTtlMinutes(120);
            Sandbox sandbox = daytona.create(params);

            // Reset the deadline to 1 hour from now
            sandbox.setTtl(60);

            // Disable the TTL
            sandbox.setTtl(0);
        }
    }
}
```

</TabItem>
<TabItem label="CLI" icon="seti:shell">

```bash
# Destroy the sandbox 2 hours after creation, regardless of state
daytona create --ttl 120
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
# Create with a 2-hour wall-clock TTL
curl 'https://app.daytona.io/api/sandbox' \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data '{
  "snapshot": "my-snapshot",
  "ttlMinutes": 120
}'

# Reset the deadline to 1 hour from now
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/ttl/60' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'

# Disable the TTL
curl 'https://app.daytona.io/api/sandbox/{sandboxIdOrName}/ttl/0' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Update sandbox last activity [#update-sandbox-last-activity]

Update a sandbox's last activity timestamp.

This updates the sandbox's recorded activity time without changing its runtime state. It is useful when your workflow is driven by external systems or background orchestration that may not reset inactivity tracking.

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
sandbox.refresh_activity()
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
await sandbox.refreshActivity()
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox.refresh_activity
```

</TabItem>
<TabItem label="API" icon="seti:json">

```bash
curl 'https://app.daytona.io/api/sandbox/{sandboxId}/last-activity' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

</TabItem>
</Tabs>

### Running indefinitely [#running-indefinitely]

Run sandboxes indefinitely.

By default, Daytona sandboxes auto-stop after 15 minutes of inactivity. To keep a sandbox running without interruption from inactivity, set the auto-stop interval to `0` when creating a new sandbox. Disabling auto-stop does not disable [wall-clock TTL](#wall-clock-ttl): if `ttl_minutes` is set, the sandbox is still destroyed when that deadline elapses.

1. Go to [Daytona Sandboxes ↗](https://app.daytona.io/dashboard/sandboxes)
2. Click <Button>Create Sandbox</Button>
3. Set **`auto-stop`** to **`0`**
4. Click <Button>Create</Button>

<Tabs syncKey="language">
<TabItem label="Python" icon="seti:python">

```python
from daytona import CreateSandboxFromSnapshotParams

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    snapshot="my_awesome_snapshot",
    # Disables the auto-stop feature - default is 15 minutes
    auto_stop_interval=0,
))
```

</TabItem>
<TabItem label="TypeScript" icon="seti:typescript">

```typescript
const sandbox = await daytona.create({
  snapshot: 'my_awesome_snapshot',
  // Disables the auto-stop feature - default is 15 minutes
  autoStopInterval: 0,
})
```

</TabItem>
<TabItem label="Ruby" icon="seti:ruby">

```ruby
sandbox = daytona.create(
  Daytona::CreateSandboxFromSnapshotParams.new(
    snapshot: 'my_awesome_snapshot',
    # Disables the auto-stop feature - default is 15 minutes
    auto_stop_interval: 0
  )
)
```

</TabItem>
<TabItem label="Go" icon="seti:go">

```go
// Disables the auto-stop feature - default is 15 minutes
autoStopInterval := 0
params := types.SnapshotParams{
    Snapshot: "my_awesome_snapshot",
    SandboxBaseParams: types.SandboxBaseParams{
        AutoStopInterval: &autoStopInterval,
    },
}
sandbox, err := client.Create(ctx, params)
```

</TabItem>
<TabItem label="Java" icon="seti:java">

```java
import io.daytona.sdk.Daytona;
import io.daytona.sdk.Sandbox;
import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;

public class App {
    public static void main(String[] args) {
        try (Daytona daytona = new Daytona()) {
            CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams();
            params.setSnapshot("my_awesome_snapshot");
            // Disables the auto-stop feature - default is 15 minutes
            params.setAutoStopInterval(0);
            Sandbox sandbox = daytona.create(params);
        }
    }
}
```

</TabItem>
</Tabs>
