Platform

Sandboxes

Launch short-lived, isolated VMs for code execution, previews, and agent work.

View as Markdown

A Sandbox is an isolated VM you create on demand and throw away when you're done. Use one to run untrusted code, give an agent its own machine, preview a dev server, or open a graphical desktop. Every Sandbox starts from a template and has a lifetime; when the lifetime ends, the Sandbox and everything on it are deleted.

Need a long-lived development machine instead? See Dev VMs.

Quickstart

ccp sandbox create launches a template applied in your organization. Apply one built on the development image, then launch from it:

sandbox.yaml
apiVersion: sandboxes.clusterbase.ai/v1
kind: SandboxTemplate
metadata:
  name: dev
spec:
  base: development
  resources:
    vcpu: 2
    memory_mb: 1024
  steps:
    - run: mkdir -p /workspace
ccp apply --file sandbox.yaml --wait
ccp sandbox create --template dev --ttl 1h
ccp sandbox list
ccp sandbox delete sbx_...

create prints the new Sandbox's ID. Pass --org-id to choose an organization, or let CCP use your active organization.

Choose a template

TemplateWhat it isHow to launch it
developmentDevelopment machine with common language tools, git, gh, and a public preview port.A template with base: development, or the API.
desktopGraphical Linux desktop with a browser. See Sandbox desktops.A template with base: desktop, or the API.
Your own templateAny base plus your packages, setup step, and ports. See Sandbox templates.ccp apply, then ccp sandbox create --template <name>.

--template takes the name of a template you applied; development and desktop on their own aren't template names.

Launch a built-in template through the API

The CLI has no command for the built-in templates, so create them with the Sandboxes API:

curl -X POST https://api.clusterbase.dev/api/v1/sandboxes \
  -H "Authorization: Bearer $(ccp auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d "{\"template_id\":\"development\",\"organization_id\":\"$CCP_ORG_ID\",\"ttl_seconds\":3600}"

template_id is development or desktop. ttl_seconds accepts 60 to 86400, or 0 for a Sandbox with no expiry. The response is the new Sandbox, including its id and services: 201 when it's running, or 202 when it was accepted but isn't running yet.

Launch from an environment revision

Copy a published revision's envr_ ID from Published environments on the console's Environments page:

ccp sandbox create --environment-revision envr_<id> --ttl 1h

Pass exactly one of --template and --environment-revision. A revision Sandbox uses the revision's pinned image, so later template edits don't change it. An archived revision can't launch new Sandboxes; Sandboxes already running from it keep working. Creating it provisions the machine only; it doesn't start a Build chat, run the revision's setup script, or run CI.

Lifetime

--ttl sets how long the Sandbox lives, from 1m to 24h (default 15m). The lifetime is fixed when you create the Sandbox; when it ends, the Sandbox is deleted along with its files.

To keep a Sandbox with no expiry, retain it:

curl -X POST https://api.clusterbase.dev/api/v1/sandboxes/sbx_.../retain \
  -H "Authorization: Bearer $(ccp auth print-access-token)"

Retaining is immediate and safe to repeat. It can't revive a Sandbox that is already being deleted. A retained Sandbox shows persistent in ccp sandbox list; with --json, each entry has id, organization_id, status, and expires_at (null for a Sandbox with no expiry). Access grants such as ccp sandbox connect keep their own short expiry.

Idle pause

development and desktop Sandboxes pause after 15 minutes without activity and resume automatically on the next request. While paused, the Sandbox keeps its files, uncommitted Git work, and running processes, and compute billing stops.

TemplateCounts as activityResumes on
developmentAgent tool calls and requests to its servicesThe next tool call or command
desktopA connected viewer, a control lease, or agent computer useThe next ccp sandbox desktop, ccp sandbox connect, or computer-use call

A background process on its own doesn't keep a Sandbox awake. Pausing doesn't extend the lifetime: a Sandbox with a TTL is still deleted on schedule.

Connect to a service

A template can declare HTTP or WebSocket services on its ports. Create short-lived access to one:

ccp sandbox connect sbx_... cdp --ttl 5m --json
{ "endpoint": "wss://...", "token": "sbxt_...", "expires_at": "..." }

Send the token as Authorization: Bearer <token> on the HTTPS request or the WebSocket upgrade. --ttl accepts 1s to 1h (default 15m) and never outlasts the Sandbox. Declared services are always private, and undeclared ports aren't reachable from outside the Sandbox.

Public preview

Every development Sandbox has a public HTTP service named preview on port 8000. Start your dev server on that port and share the URL; anyone with the link can open it. Until the server answers, the URL shows a waiting page that switches to your app automatically.

The preview URL is in the services list of the create response and of later get and list calls while the Sandbox runs. Ports in your own templates are always private; only the built-in preview service is public.

GitHub access

Link your GitHub account before you create the Sandbox. A development Sandbox launched with repositories, environment variables, or Storage inputs, and a desktop Sandbox launched with a GitHub checkout, then authenticate git and gh as you, with your existing repository permissions. Build and managed agents launch Sandboxes this way. The credential renews itself while the Sandbox runs.

ccp sandbox create passes no launch inputs, so its Sandboxes start without GitHub credentials. If GitHub isn't linked, the Sandbox starts without Git credentials and private checkouts fail; if GitHub is linked but your credential can't be read, the launch fails. Linking GitHub later doesn't update an existing Sandbox; create a new one.

CCP CLI inside a Sandbox

development and desktop Sandboxes include ccp, with cb and clusterbase as aliases. All three run the same CLI with the same organization and project settings; run cb org current --json to check which organization it uses.

Watch Sandboxes in the console

Open Sandboxes in the console to see active Sandboxes in the selected organization. To find a deleted or failed Sandbox, switch from Active to All states or select its status. Enter part of its ID in Search by ID to search across pages, and use Next and Previous to browse matches. Open a Sandbox for details, or delete it from the row menu or detail page.

For a Sandbox preparing a Storage folder, the console shows sync progress. If the folder doesn't fit, it shows how much space or how many files it needs; shrink the folder or use an environment with more capacity.

Filter and page through the inventory API

Use ccp sandbox list for a summary, or call the HTTP API to filter and page through the organization's inventory:

curl --get https://api.clusterbase.dev/api/v1/sandboxes \
  -H "Authorization: Bearer $(ccp auth print-access-token)" \
  --data-urlencode "org_id=$CCP_ORG_ID" \
  --data-urlencode 'state=deleted' \
  --data-urlencode 'search=sbx_'
Query parameterEffect
org_idRequired organization ID.
stateall (default), active (excludes deleted and failed), or a Sandbox status such as deleted.
searchCase-insensitive match on part of the Sandbox ID.
afterPass the previous response's next_cursor with the same filters. Omit it for the first page.

The response contains sandboxes (newest first), counts (organization totals by status), and matched (the number matching the filters across all pages). next_cursor is null on the last page. For example, a search with no matches can return {"sandboxes": [], "counts": {"running": 2}, "matched": 0, "next_cursor": null}.

Delete a Sandbox

ccp sandbox delete sbx_...

delete (alias rm) asks for confirmation; pass --yes in scripts and CI. Deletion runs in the background: the Sandbox shows destroying until cleanup finishes and then deleted. Its capacity may not be free right away, so an equal-sized replacement can briefly fail to start. Deleting an already-deleted Sandbox is harmless.

Read workspace files

Read a running Sandbox's workspace without declaring a port:

curl "https://api.clusterbase.dev/api/v1/sandboxes/sbx_.../files?path=/workspace" \
  -H "Authorization: Bearer $(ccp auth print-access-token)"

curl "https://api.clusterbase.dev/api/v1/sandboxes/sbx_.../files/content?path=/workspace/notes.txt" \
  -H "Authorization: Bearer $(ccp auth print-access-token)"

/files lists one directory (directories first, hidden files included), with each entry's name, path, kind, and size. /files/content returns up to 1 MiB of a UTF-8 text file. URL-encode paths. Both are read-only and can't reach outside the workspace.

StatusMeaning
400The path is invalid.
403The path is outside the workspace, or you no longer have access to the organization.
404The path doesn't exist.
409The Sandbox isn't running.
413The file is too large to read.
415The file isn't text.

Errors

ErrorWhat happenedWhat to do
Sandbox resource not found (API: template_not_found)No applied template with that name in the organization.Check the name, or apply the template.
Sandbox template is not ready (API: template_not_ready)The template's latest build hasn't finished.Wait for the build (ccp apply --wait), then retry.
Sandbox quota exceeded (API: node_capacity_exhausted)No capacity was available. No Sandbox was created.Retry later.
Sandbox creation pendingThe Sandbox was accepted but isn't running yet.Keep the printed ID and check it with ccp sandbox list. Don't create it again.
node activity demand capacity exhaustedThe Sandbox's host is busy.Let running commands finish, then retry on the same Sandbox.
Sandbox service temporarily unavailable (API: sandbox_unavailable, 503)The request, such as a deletion, wasn't accepted.Retry with backoff.

If create times out (Sandbox request canceled or deadline exceeded), the Sandbox may still exist: run ccp sandbox list before trying again, because each retry creates another Sandbox.

See ccp sandbox for every flag.

On this page