The Sandbox CLI, based on the Docker CLI, allows you to manage sandboxes, execute commands, copy files, and more from your terminal. This page provides a complete reference for all available commands.
Use the CLI for manual testing and debugging, or use the JS SDK or Python SDK to automate sandbox workflows in your application.
Sandboxes are identified by name (unique within your project) and are persistent by default: when stopped, the filesystem is snapshotted and restored on the next resume. Use sandbox remove to delete a sandbox permanently.
# List all running sandboxessandbox list# List all sandboxes (including stopped ones)sandbox list--all# List sandboxes for a specific projectsandbox list--projectmy-nextjs-app# Filter by name prefix and sortsandbox list--name-prefixci---sort-byname--sort-orderasc# Filter by tagsandbox list--tagenv=staging--limit100# Page through results using the cursor reported by the previous pagesandbox list--cursor<token>
# Create a basic Node.js sandboxsandbox create# Create a sandbox with an explicit namesandbox create--namemy-sandbox# Create a sandbox with 1 vCPU and open an interactive shellsandbox create--vcpus1--connect# Create a Python sandbox with custom timeoutsandbox create--runtimepython3.13--timeout1h# Create sandbox with port forwardingsandbox create--publish-port8080--projectmy-project# Create sandbox silently (no output)sandbox create--silent# Create sandbox from a snapshotsandbox create--snapshotsnap_abc123# Create a non-persistent (ephemeral) sandboxsandbox create--nameci-job--non-persistent# Tag a sandbox at creation timesandbox create--namemy-sandbox--tagenv=staging--tagteam=infra# Set snapshot expiration and retentionsandbox create--namemy-sandbox--snapshot-expiration7d--keep-last-snapshots1# Create sandbox without Internet accesssandbox create--network-policydeny-all# Create sandbox with restricted Internet access (limited to Vercel's AI gateway)sandbox create--allowed-domainai-gateway.vercel.sh
A persistent sandbox snapshots its filesystem every time a session stops, so its snapshots accumulate over time. Use --keep-last-snapshots to keep only the N most recent. When a new snapshot brings the total above the limit, the oldest snapshots are no longer kept. The --delete-evicted-snapshots flag controls what happens to them: delete them immediately, or leave them to expire on their own.
--keep-last-snapshots <count>: keep only the N most recent snapshots. count must be an integer from 1 to 10. This flag enables the retention policy, and the two flags below require it.
--keep-last-snapshots-for <duration>: the expiration applied to the snapshots you keep, for example 7d or 30d. Use none or 0 for no expiration. When omitted, kept snapshots fall back to the sandbox's default snapshot expiration (--snapshot-expiration).
--delete-evicted-snapshots <true|false>: what happens to a snapshot once it is no longer among the most recent kept ones. true (the default) deletes it immediately; false keeps it until its existing expiration instead.
Fork an existing sandbox into a new one. The fork is seeded from the source sandbox's current snapshot and inherits its config. Any option you pass overrides the copied value. If the source has no current snapshot, the fork falls back to creating a fresh sandbox with the source's runtime plus the copied config.
env is not copied (encrypted server-side); pass --env to set environment variables on the fork. Tags passed via --tag fully replace the source's tags (no per-key merge).
# Fork with every supported field copied from the sourcesandbox forkmy-source# Override the name and bump vCPUs; env vars must be re-suppliedsandbox forkmy-source--namemy-forked-sandbox--vcpus4--envFOO=1
View and update sandbox configuration. Each subcommand updates one parameter; all parameters are also available together through the SDK's sandbox.update().
# Inspect the current configuration of a sandboxsandbox configlistmy-sandbox# Update vCPUs and timeoutsandbox configvcpusmy-sandbox4sandbox configtimeoutmy-sandbox30m# Toggle persistencesandbox configpersistentmy-sandboxfalse# Update snapshot retentionsandbox configsnapshot-expirationmy-sandbox14dsandbox configkeep-last-snapshotsmy-sandbox1# Replace the exposed port listsandbox configportsmy-sandbox-p3000-p8000# Clear all exposed portssandbox configportsmy-sandbox# Replace the tag setsandbox configtagsmy-sandbox--tagenv=production--tagteam=infra# Roll back to a previous snapshotsandbox configcurrent-snapshotmy-sandboxsnap_abc123# Update the sandbox firewall to deny all egress trafficsandbox confignetwork-policymy-sandbox--network-policydeny-all# Update the sandbox firewall to allow all egress trafficsandbox confignetwork-policymy-sandbox--modeallow-all# Update the sandbox firewall to specific rulessandbox confignetwork-policymy-sandbox--allowed-domainvercel.com--allowed-domainai-gateway.vercel.sh
# Copy file from local to sandboxsandbox copy./local-file.txtmy-sandbox:/app/remote-file.txt# Copy file from sandbox to localsandbox copymy-sandbox:/app/output.log./output.log# Copy directory from sandbox to localsandbox copymy-sandbox:/app/dist/./build/
# Execute a simple command in a sandboxsandbox execmy-sandbox--ls-la# Run with environment variablessandbox exec--envDEBUG=truemy-sandbox--npmtest# Execute interactively with sudosandbox exec--interactive--sudomy-sandbox--sh# Run command in specific working directorysandbox exec--workdir/appmy-sandbox--pythonscript.py# Stop the current session after the command exitssandbox exec--stopmy-sandbox--npmbuild
# Connect to an existing sandboxsandbox connectmy-sandbox# Connect with a specific working directorysandbox connect--workdir/appmy-sandbox# Connect with environment variables and sudosandbox connect--envDEBUG=true--sudomy-sandbox
Stop the current session of one or more sandboxes. For persistent sandboxes (the default), the filesystem is snapshotted first so the sandbox can be resumed later with the same name. To delete a sandbox permanently, use sandbox remove.
# Stop a single sandboxsandbox stopmy-sandbox# Stop multiple sandboxessandbox stopmy-sandboxanother-sandbox# Stop sandbox for a specific projectsandbox stop--projectmy-projectmy-sandbox
Permanently delete one or more sandboxes, along with all of their snapshots and sessions. Once removed, a sandbox cannot be recovered. Use this instead of sandbox stop when you no longer need the sandbox at all.
Create (or resume) a sandbox and run a command in it. When --name matches an existing sandbox, the sandbox is resumed and any create-only flags are ignored.
# Run a simple Node.js script in a fresh sandboxsandbox run--node--version# Run with custom environment and timeoutsandbox run--envNODE_ENV=production--timeout10m--npmstart# Run interactively with port forwardingsandbox run--interactive--publish-port3000--tty--npmrundev# Resume an existing sandbox if it exists; otherwise create itsandbox run--namemy-sandbox--npmtest# Stop the current session when the command exitssandbox run--namemy-sandbox--stop--npmbuild# Permanently delete the sandbox after the command exitssandbox run--rm--python3script.py
# Create a snapshot of a running sandboxsandbox snapshotmy-sandbox--stop# Create a snapshot that expires 14 days after its last usesandbox snapshotmy-sandbox--stop--expiration14d# Create a snapshot that never expiressandbox snapshotmy-sandbox--stop--expiration0
# List snapshots for the current projectsandbox snapshotslist# List snapshots for a specific projectsandbox snapshotslist--projectmy-project# Filter snapshots by sandbox namesandbox snapshotslist--namemy-sandbox# Page through resultssandbox snapshotslist--limit50--cursor<token>
# Get details of a specific snapshotsandbox snapshotsgetsnap_1234567890# Get snapshot details for a specific projectsandbox snapshotsget--projectmy-projectsnap_1234567890
# Delete a single snapshotsandbox snapshotsdeletesnap_1234567890# Delete multiple snapshots for a specific projectsandbox snapshotsdelete--projectmy-projectsnap_1234567890snap_0987654321
Walk the snapshot ancestry tree starting from a sandbox's current snapshot. Snapshots form a parent → child tree whenever you create a sandbox from another snapshot.
# Walk ancestors of the sandbox's current snapshot (default)sandbox snapshotstreemy-sandbox# Walk descendantssandbox snapshotstreemy-sandbox--sort-orderasc# Continue from a specific snapshotsandbox snapshotstreemy-sandbox--cursorsnap_abc123
Inspect VM sessions for a sandbox. A session represents one running VM instance of a sandbox; persistent sandboxes can have many sessions over time, separated by snapshots.
# List running sessionssandbox sessionslistmy-sandbox# List all sessions (including stopped ones)sandbox sessionslistmy-sandbox--all# Sort and paginatesandbox sessionslistmy-sandbox--sort-orderasc--limit100
For interactive work, create a named sandbox that stays running:
sandbox create--namemy-sandbox--timeout30m
sandbox create prints the sandbox's name. Use that name to interact with the sandbox. Because persistent sandboxes can be resumed, you can also reconnect later by running sandbox exec my-sandbox -- ... or sandbox connect my-sandbox.
# Copy your code to the sandboxsandbox copy./my-app.jsmy-sandbox:/home/sandbox/# Run itsandbox execmy-sandbox--node/home/sandbox/my-app.js# Copy results backsandbox copymy-sandbox:/home/sandbox/output.json./results.json
# Create a named sandboxNAME=$(sandbox create--name "ai-test-$(date +%s)" --timeout15m--silent)# Copy AI-generated codesandbox copy./ai-generated.js $NAME:/app/# Test it interactivelysandbox exec--interactive--tty $NAME --bash# Now inside: cd /app && node ai-generated.js# Clean up (remove permanently)sandbox remove $NAME
# Create a named sandbox with more timesandbox create--namedebug-build--timeout1h# Copy your projectsandbox copy./my-project/debug-build:/app/# Try buildingsandbox exec--workdir/appdebug-build--npmrunbuild# If it fails, debug interactivelysandbox exec-itdebug-build--bash
# Create with port exposuresandbox create--namedev--timeout30m--publish-port3000# Start your dev serversandbox exec--workdir/appdev--npmrundev# Access at the provided URL (printed by `sandbox create`)# Visit: https://<random-id>.vercel.run