---
title: Sandbox CLI and SDK Reference (TypeScript, Python, Go)
description: Complete reference for cvm sandbox commands (create, exec, cp, ls, port-forward, url, snapshot, restore, fork, sleep, resume, delete) and TypeScript, Python, and Go SDK clients.
canonical: https://docs.caveman.so/sandboxes/cli-and-sdks
product: Caveman Cloud
tab: Documentation
group: Sandboxes
---

# Sandbox CLI and SDK Reference (TypeScript, Python, Go)

> Complete reference for cvm sandbox commands (create, exec, cp, ls, port-forward, url, snapshot, restore, fork, sleep, resume, delete) and TypeScript, Python, and Go SDK clients.

Control Firecracker sandboxes from the `cvm` CLI or programmatically from TypeScript (`@caveman-ai/sdk/sandboxes`), Python (`caveman_cloud`), and Go (`github.com/caveman-ai/sdk-go`).

## Complete CLI lifecycle

```bash
export CAVE_TOKEN="cave_live_..."   # or run `cvm key quick` after `cvm login`

# Create a sandbox and wait until running
cvm sandbox create --name scratch --size 2cpu-4gb --sleep-after 10m --network internet

# Run commands (stdout/stderr kept separate; exits with the command's exit code)
cvm sandbox exec SANDBOX_ID -- uname -a
cvm sandbox exec -e NODE_ENV=test -w /workspace SANDBOX_ID -- npm test

# Interactive terminal (-t matches local terminal size; -i forwards stdin)
cvm sandbox exec -t -i SANDBOX_ID -- bash
echo "hello" | cvm sandbox exec -i SANDBOX_ID -- cat

# Copy files in or out (atomic rename on copy-out; preserves executable bits)
cvm sandbox cp ./run.sh SANDBOX_ID:/home/user/
cvm sandbox cp SANDBOX_ID:/home/user/output.json ./output.json
cvm sandbox ls SANDBOX_ID /home/user

# Forward a sandbox loopback port to 127.0.0.1 locally
cvm sandbox port-forward SANDBOX_ID 8080
cvm sandbox port-forward SANDBOX_ID 9000:3000

# Expose a port at a private HTTPS URL (or --public / --private)
cvm sandbox url SANDBOX_ID 3000 --ttl 1h
cvm sandbox url SANDBOX_ID 3000 --public
cvm sandbox url SANDBOX_ID 3000 --private

# Snapshot, restore, fork, and manage snapshots
# Note: keeping 2 sandboxes at once or sizing above 2x8 requires a paid plan
cvm sandbox snapshot SANDBOX_ID --name clean
cvm sandbox snapshots SANDBOX_ID
cvm sandbox restore SANDBOX_ID SNAPSHOT_ID
cvm sandbox fork SANDBOX_ID SNAPSHOT_ID --name try-2 --size 4cpu-16gb
cvm sandbox snapshot-delete SANDBOX_ID SNAPSHOT_ID --yes

# Sleep (stops compute, keeps disk), resume, list, and delete
cvm sandbox sleep SANDBOX_ID --wait
cvm sandbox resume SANDBOX_ID
cvm sandbox list
cvm sandbox get SANDBOX_ID
cvm sandbox delete SANDBOX_ID --yes
```

### Key flags on `cvm sandbox create`

| Flag | Default / values | Behavior |
| --- | --- | --- |
| `--name NAME` | optional | Human-readable sandbox label |
| `--size SIZE` | installation default | vCPU and RAM spec such as `1cpu-2gb`, `2cpu-4gb`, `2cpu-8gb`, `4cpu-16gb` (up to your plan ceiling) |
| `--package PKG` | `standard` | `standard`, `browser`, `desktop`, or `agent_box` |
| `--target TARGET` | `auto` | `auto`, `cloud`, or `mac` |
| `--compute-class CLASS` | `standard` | `standard`, `performance`, or `nested` |
| `--region REGION` | default region | Target region such as `us-east` or `eu-central` |
| `--nested-kvm` | off | Enable `/dev/kvm` and nested container/Docker execution |
| `--network MODE` | `internet` | `none`, `internet`, or `allowlist` (pair with `--egress-allow HOST` / `--egress-deny HOST`) |
| `--sleep-after DUR` | `10m` | Auto-sleep after idle duration (`10m`, `2h`, or `0` to disable) |
| `--pause-after DUR` | package default | Fast idle pause window (`5s`, `30s`, or `0`) |
| `--lifetime DUR` | none | Hard auto-delete TTL (`1m` to `30d`) regardless of activity |
| `--auto-snapshot DUR` | off | Periodic rolling snapshots (`60s`, `5m`, `0`) with `--auto-snapshot-keep N` |
| `--end-user ID` | none | Scope sandbox under B2B2C end-user quota isolation |
| `--wake-on-http` | off | Automatically wake a sleeping sandbox when its port URL receives HTTP traffic |
| `--no-wait` | wait until running | Return immediately while provisioning |

### Org computer pools (`cvm pools`)

Manage shared N:M computer pools across Cloud and connected local Mac hosts:

```bash
cvm pools list
cvm pools create ci-runners
cvm pools computers ci-runners
cvm pools archive ci-runners
```

## TypeScript SDK (`@caveman-ai/sdk/sandboxes`)

```bash
npm install @caveman-ai/sdk
```

```ts
import { Sandboxes } from "@caveman-ai/sdk/sandboxes";

const sandboxes = new Sandboxes({
  controlURL: process.env.CAVE_API_URL ?? "https://api.caveman.so",
  apiKey: process.env.CAVE_TOKEN!,
});

const sb = await sandboxes.create({ name: "scratch", size: "2cpu-4gb" });
const out = await sb.exec(["uname", "-a"]);
console.log(out.stdout);

await sb.sleep();
await sb.delete();
```

## Python SDK (`caveman_cloud`)

```bash
python -m pip install https://github.com/caveman-ai/cloud-sdk/releases/download/v2.0.0/caveman_sdk-2.0.0-py3-none-any.whl
```

```python
import os
from caveman_cloud import Sandboxes

sandboxes = Sandboxes(
    control_url=os.environ.get("CAVE_API_URL", "https://api.caveman.so"),
    api_key=os.environ["CAVE_TOKEN"],
)

sb = sandboxes.create(name="scratch")
res = sb.exec(["uname", "-a"])
print(res.stdout)
sb.delete()
```

## Go SDK (`github.com/caveman-ai/sdk-go`)

```bash
go get github.com/caveman-ai/sdk-go
```

```go
package main

import (
	"context"
	"fmt"
	"os"

	caveman "github.com/caveman-ai/sdk-go"
)

func main() {
	ctx := context.Background()
	client, err := caveman.NewSandboxes(caveman.SandboxesConfig{
		ControlURL: "https://api.caveman.so",
		APIKey:     os.Getenv("CAVE_TOKEN"),
	})
	if err != nil {
		panic(err)
	}
	sb, err := client.Create(ctx, caveman.CreateSandboxInput{Name: "scratch"})
	if err != nil {
		panic(err)
	}
	defer client.Delete(ctx, sb.ID)

	res, err := client.Exec(ctx, sb.ID, []string{"uname", "-a"})
	if err != nil {
		panic(err)
	}
	fmt.Print(res.Stdout)
}
```

## Limits and error codes

- On **Hobby (\$0/mo)**, Cloud workspaces include **30 hours/mo** of `2x4` sandboxes (recurring monthly), up to **3 concurrent sandboxes** (`24 GiB` awake), **3 kept sandboxes** (auto-archived after 7d idle), `10/min` starts (`1,000/mo`), `1 hour` max awake session, and max shape **`2x8`**. Upgrade to **Pro (\$25/mo)** (`20` concurrent / `160 GiB`, `30 → 120/min`, `24h`, up to `8x32`, `25` kept), **Scale (\$300/mo)** (`100` concurrent / `800 GiB`, `120 → 600/min`, unlimited session, up to `16x64`, `100` kept), or **Business (\$750/mo)** (`300` concurrent / `2.4 TiB`, `300 → 1,500/min`, up to `16x64+`, `300` kept, Warm Snapshot Pools `<200ms`), or bolt on a **Concurrency Pack (+\$50/mo)** for `+25` concurrent sandboxes (`+200 GiB` awake). See [Billing](/governance/billing#sandboxes-agent-harness-and-drives) for all sandbox limits and metered rates.
- Running `cvm sandbox exec` on a sleeping sandbox returns `cave_code_computer_not_running` (exit `4`): call `cvm sandbox resume SANDBOX_ID` first.
- Each service-account key retains up to `32` snapshots at once (`cave_code_computer_limit_snapshots`, exit `4`).
- `cvm sandbox url` requires the target installation to have port URLs enabled (`cave_sandbox_ports_off`, exit `4`); `cvm sandbox port-forward` works on every installation.
- Port URL tokens (`Caveman-Port-Token` header or browser open link) are short-lived credentials; treat them as secrets while active.
