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--imagevercel/sandbox/python--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 sandbox in a specific region, with failover regionssandbox create--regionsfo1--failover-regionsiad1,cle1# 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# Mount a drive with read-only access (requires private beta access and beta CLI)sandbox create--mountcache:/data:read-only
Comma-separated regions the sandbox can fail over to (e.g. sfo1,cle1). Must not include the main region. Not supported with --mount. Available on Pro and Enterprise plans, excluding Pro trials.
--snapshot-expiration <duration>
-
Default snapshot TTL. Defaults to 30d. Use none or 0 for no expiration.
--keep-last-snapshots <count>
-
Retention policy: keep only the N (1–10) most recent snapshots of this sandbox.
--keep-last-snapshots-for <dur>
-
Expiration applied to kept snapshots. Use none or 0 for no expiration.
--delete-evicted-snapshots <bool>
-
true (default) deletes evicted snapshots immediately; false keeps them until their existing expiration. See Snapshot retention.
--network-policy <mode>
-
Base network mode to start the sandbox with ('allow-all' - default or 'deny-all'). Leave unset if using more specific rules.
--allowed-domain <domain>
-
List of domains (or pattern) to allow access to (only applicable in 'custom' mode). Use wildcard * to match multiple domains or subdomains.
--allowed-cidr <cidr>
-
List of address ranges to allow access to (only applicable in 'custom' mode). Traffic to those addresses will bypass domain matching.
--denied-cidr <cidr>
-
List of address ranges to deny access to (only applicable in 'custom' mode). Those take precedence over allowed domains and addresses.
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 image 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).
The fork runs in the source sandbox's region unless you pass --region. The fork also inherits the source's failover regions. Pass --failover-regions to replace them. If the source has a snapshot, that snapshot must be available in the target region.
# 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
Name for the forked sandbox. Must be unique per project. Generated if omitted.
--timeout <duration>
-
Override the session timeout inherited from the source.
--vcpus <count>
-
Override the vCPU count. Each vCPU includes 2048 MB of memory.
--publish-port <port>
-p
Publish a port. Repeatable. Replaces the inherited port list if provided.
--env <key=value>
-e
Environment variables for the fork. Not copied from the source. Repeatable.
--tag <key=value>
-t
Tag the fork. Repeatable. When provided, fully replaces the tags copied from the source.
--region <region>
-
Override the region copied from the source. If the source has a snapshot, it must be available in this region.
--failover-regions <region,...>
-
Comma-separated regions the fork can fail over to (e.g. sfo1,cle1). Must not include the main region. Not supported for sandboxes with mounted drives. Available on Pro and Enterprise plans, excluding Pro trials.
--snapshot-expiration <duration>
-
Override the default snapshot TTL (e.g. 7d, 30d). Use none or 0 for no expiration.
--keep-last-snapshots <count>
-
Override the retention policy (1–10).
--keep-last-snapshots-for <dur>
-
Expiration applied to kept snapshots. Use none or 0 for no expiration.
--delete-evicted-snapshots <bool>
-
true (default) deletes evicted snapshots immediately; false keeps them until their existing expiration. See Snapshot retention.
--network-policy <mode>
-
Override the base network mode (allow-all or deny-all). Leave unset to use the inherited rules or --allowed-domain / --allowed-cidr / --denied-cidr.
--allowed-domain <domain>
-
Domain to allow traffic to (creates a custom network policy). Supports wildcards.
--allowed-cidr <cidr>
-
CIDR to allow traffic to. Takes precedence over --allowed-domain.
--denied-cidr <cidr>
-
CIDR to deny traffic to. Takes precedence over allowed domains and CIDRs.
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 the failover regionssandbox configfailover-regionsmy-sandboxiad1,cle1sandbox configfailover-regionsmy-sandboxnone# 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 sessions. Once removed, a sandbox cannot be recovered. Use this instead of sandbox stop when you no longer need the sandbox at all.
Removing a sandbox keeps its snapshots, because several sandboxes can start from the same snapshot. Delete those separately with sandbox snapshots delete.
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# Run a command with a read-only drive mounted (requires private beta access and beta CLI)sandbox run--mountcache:/data:read-only--ls/data
# 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
# List drivessandbox driveslist# Filter drives by name and sort ascendingsandbox driveslist--name-prefixcache---sort-orderasc# Page through results using the cursor reported by the previous pagesandbox driveslist--limit100--cursor<token>
# Create or retrieve a drive with the default 100 GiB maximum sizesandbox drivesget-or-createcache# Create or retrieve a drive with a maximum size of 10 GiBsandbox drivesget-or-createcache--max-size10737418240# Create or retrieve a drive stored in the sfo1 regionsandbox drivesget-or-createcache--regionsfo1
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
From the Vercel docs graph (built 2026-08-29T06:32:40.963Z), spanning vercel.com docs + KB, nextjs.org, ai-sdk.dev, and other Vercel documentation sites. Full graph as JSON: https://vercel.com/docs/graph.json
Semantically closest pages
JS SDK Reference — A comprehensive reference for the Vercel Sandbox JavaScript SDK, which lets you run code in a secure, isolated environme
Snapshots — Save and restore sandbox state with snapshots for faster startups and environment sharing.
Persistence — Sandboxes automatically save their filesystem state when stopped and restore it when resumed. No manual snapshot managem
Understanding Vercel — Learn all about Vercel's Pro Plan free trial, including features, usage limits, and options post-trial. Learn how to man
General settings — Configure basic settings for your Vercel project, including the project name, build and development settings, root direc
Drives — Persistent storage that can be mounted into sandboxes and shared across runs.
Images — Start sandboxes from Vercel's Managed Images, or custom OCI images stored in Vercel Container Registry to ship your own
Sandbox Regions — Choose the regions where Vercel Sandbox runs your sandboxes, set a project default, and configure failover regions.
Snapshots — Save and restore sandbox state with snapshots for faster startups and environment sharing.
Tags — Categorize sandboxes by environment, team, or any other criteria using key-value tags.
Python SDK Reference — Reference for the Vercel Sandbox Python SDK, including sandbox lifecycle, processes, files, snapshots, persistence, and
JS SDK Reference — A comprehensive reference for the Vercel Sandbox JavaScript SDK, which lets you run code in a secure, isolated environme
How do I use a Vercel API Access Token? — An Access Token is required in order to use the Vercel API. Tokens can be created and managed at the level of your accou
Pages that link here (18)
By site: vercel-changelog (4) · vercel-kb (1) · vercel-docs (13)
The Complete Guide to Vercel Drives — Learn how Vercel Drives provide persistent storage for Vercel Sandboxes, and how to create, mount, list, and delete a dr
From vercel-docs
Vercel CLI Overview — Learn how to use the Vercel command-line interface \(CLI\) to manage and configure your Vercel Projects from the command
vercel sandbox — Interact with Vercel Sandbox from the Vercel CLI: list, create, connect, exec, copy, stop, and snapshot sandboxes from y
Vercel Sandbox — Vercel Sandbox allows you to run arbitrary code in isolated, ephemeral Linux VMs.
Understanding Sandboxes — Learn how Vercel Sandboxes provide on-demand, isolated compute environments for running untrusted code, testing applicat
Drives — Persistent storage that can be mounted into sandboxes and shared across runs.
Persistence — Sandboxes automatically save their filesystem state when stopped and restore it when resumed. No manual snapshot managem
Sandbox Regions — Choose the regions where Vercel Sandbox runs your sandboxes, set a project default, and configure failover regions.
Snapshots — Save and restore sandbox state with snapshots for faster startups and environment sharing.
Tags — Categorize sandboxes by environment, team, or any other criteria using key-value tags.
Quickstart — Learn how to run your first code in a Vercel Sandbox.