Skip to main content
Ephemeral sandboxes are short-lived, disposable environments that are automatically destroyed when their timeout expires. They’re designed for one-off tasks like code execution, CI/CD jobs, testing, and AI agent tool calls.

Lifecycle

  1. Create with a timeout (default: 5 minutes, max: 24 hours)
  2. Use — execute commands, upload/download files
  3. Extend — call keepalive to push back the expiry
  4. Destroy — happens automatically at expiry, or manually
A background reaper loop runs every 10 seconds and destroys any ephemeral sandboxes past their expires_at timestamp.

Creating an ephemeral sandbox

zwrm sandbox create --template python --timeout 10m
Flags:
  • --template (required) — Template name or ID
  • --timeout — Duration until auto-destroy (default: 5m, max: 24h)
  • --size — VM preset (default: shared-cpu-1x)
  • --env KEY=VALUE — Environment variables (repeatable)
  • --egress-mode — Outbound firewall mode: allow_all or deny_all
  • --egress-allow-cidr CIDR — Allow outbound to this CIDR (repeatable; implies deny_all)
  • --egress-deny-cidr CIDR — Explicitly deny outbound to this CIDR (repeatable)
  • --egress-allow-port PORT — Restrict allowed CIDRs to this TCP port (repeatable)

Extending the timeout

Use keepalive to extend the sandbox’s lifetime before it expires:
zwrm sandbox keepalive sbx_abc123 --timeout 30m
The maximum timeout is 24 hours (86400s). Keepalive requests exceeding this are clamped to the maximum.

Executing commands

Run a command inside the sandbox. The command executes inside the VM via the in-VM agent daemon and returns stdout, stderr, exit code, and duration.
# Simple command
zwrm sandbox exec sbx_abc123 -- python3 -c "print('hello')"

# With timeout and working directory
zwrm sandbox exec sbx_abc123 --timeout 60s --workdir /app -- make test
The CLI streams stdout/stderr directly and exits with the command’s exit code.
Default execution timeout is 30 seconds. Maximum is 5 minutes. Commands that exceed the timeout are killed with SIGKILL.

File operations

Upload

Upload files up to 100 MB. Parent directories are created automatically.
zwrm sandbox upload sbx_abc123 ./main.py /home/user/main.py

Download

zwrm sandbox download sbx_abc123 /home/user/output.json ./output.json

List directory

curl "http://localhost:8080/v1/sandboxes/sbx_abc123/files/home/user?list=true"
Response:
{
  "entries": [
    {"name": "main.py", "size": 1024, "type": "file", "modified": "2026-04-05T14:30:00Z"},
    {"name": "output", "size": 4096, "type": "directory", "modified": "2026-04-05T14:31:00Z"}
  ]
}

Automatic cleanup

The reaper loop runs every 10 seconds and destroys expired sandboxes. Cleanup includes:
  • Stopping the Firecracker VM process
  • Removing the TAP network device
  • Releasing the IP allocation
  • Deleting the CoW overlay file
  • Updating the database status to destroyed
No manual intervention is required — expired sandboxes are cleaned up automatically.