Skip to main content
Sandboxes are in the Node.js and Python SDKs. In Go and Rust, call the sandbox routes with the raw request method. Use an API key scoped to all or sandbox with read_write. The client’s teamId applies to every sandbox call.

Create and use a sandbox

create() returns a Sandbox handle. The sandbox starts as creating, so wait for it before running commands.

Stream command output

Pass a callback to get output as it’s produced. The call still resolves with the exit code once the command ends. If the Gateway answers with plain JSON instead of a stream, the callback gets the whole output once.

Labels

Labels are up to 20 key: value pairs. Filter the list by them, and replace them on a handle.

Network policies

Choose what a sandbox can reach. Leave egress out for the whole internet, block everything with deny-all, or pass an allow list of domains (github.com, *.npmjs.org) and public IPv4 CIDRs.
New connections follow a change at once; open connections are not cut. egressApplied is false for a sandbox created before network policies: the change applies at its next start. An invalid entry (a private range, an internal name, more than 64 entries, an empty allowlist) is a PxxlAPIError with status 400; 409 means the server can’t enforce policies.

Snapshots

Save a running sandbox’s home directory (global installs, dotfiles) and /workspace, then start new sandboxes from it with the installs already done. Memory and running processes aren’t kept. snapshot() waits until the snapshot is ready (about 5 to 15 seconds) unless you pass wait: false, and throws SandboxSnapshotError if saving fails.
The sandbox must be running (409 otherwise), and your plan keeps a set number of snapshots: Plus 5, Pro 25, Enterprise 100 (403 over it). Deleting a snapshot that sandboxes still use is a 409 whose details.sandboxIds lists them. With wait: false (wait=False), poll with pxxl.sandboxes.snapshots.waitUntilReady(snapshot) or get(id). See the snapshot object.

Fast starts

Default-size node, python, and base sandboxes start from a warm pool in about 2 seconds, so waitUntilReady() usually returns almost at once. Nothing to configure.

Background processes

Start a server or watcher with background, see it in the process list, and stop it with a signal.
kill() throws PxxlAPIError with status 404 when there’s no such process.

Binary files

Write bytes and they go base64-encoded; read with binary to get bytes back. Strings are written as text.

The sandbox handle

Read fields from the handle: id, name, status, template, labels, egress, domain, hourlyUsd, isRunning, isPaused, and info for the full sandbox object. In Python, info is a dict and the flags are is_running and is_paused. Fields reflect the last fetch; call refresh() for current ones.

The sandboxes resource

Create options: name, template (base, node, python, go, rust, bun; see templates), size (micro, small, medium, large), cpus, memoryMb, diskGb (2, 5, 10), autoStopMinutes (0 to 1440), env, sourceRepository, previewAccess, labels, egress ({ mode?, allow? }), snapshotId (start from a snapshot; the template comes from it), and teamId. Python takes the same options in snake case. template defaults to base (Debian 13). pxxl.sandboxes also has ID-based methods, such as exec(id, command) and readFile(id, path), if you don’t want a handle.

Errors

API errors throw PxxlAPIError in both SDKs, with the HTTP status. A plan or wallet problem has upgradeRequired (upgrade_required in Python) set. See errors.