boxd

Persistent Linux microVMs with memory snapshots and public HTTPS previews.

Install and authenticate

pnpm add sbox-sdk @boxd-sh/sdk
export BOXD_API_KEY=bxd_...

Use Node 20 or newer. The adapter loads the Node gRPC SDK lazily. It does not use @boxd-sh/sdk/web, because that transport cannot run interactive exec or PTY. An edge bundle must externalize this optional peer and use a Node runtime for boxd. Importing the adapter alone does not open a channel or load gRPC.

An API key or session token.

Authentication variables for the boxd adapter.
OptionEnv varRequiredDescription
apiKeyBOXD_API_KEYoptionalboxd API key.
tokenBOXD_TOKENoptionalSession token, takes precedence over the API key.
baseUrlBOXD_BASE_URLoptionalCluster endpoint, defaults to https://boxd.sh:9443.
regionBOXD_REGIONoptionalDefault region, such as fra or nyc.
orgBOXD_ORGoptionalOrganization to create and list machines in.

Node gRPC transport. baseUrl selects a hosted or self-hosted cluster; region selects its region.

token takes precedence over apiKey, then the SDK checks BOXD_TOKEN and BOXD_API_KEY. baseUrl maps to the SDK's baseURL and falls back to BOXD_BASE_URL. The default is https://boxd.sh:9443. Pass region for the cluster's region, for example fra or nyc, and org for an organization. The CLI also reads BOXD_REGION and BOXD_ORG.

Quickstart

import { createSandboxClient } from "sbox-sdk";
import { boxd } from "sbox-sdk/boxd";

const client = createSandboxClient({ provider: boxd() });
try {
  const sandbox = await client.create({
    name: "agent-workspace",
    metadata: { project: "demo" },
    env: { NODE_ENV: "development" },
    resources: { vcpus: 2, memoryMB: 8192 },
    lifecycle: { maxAgeMs: 60 * 60 * 1000 },
  });
  try {
    const result = await sandbox.commands.run("echo out; echo err >&2");
    console.log(result.stdout, result.stderr, result.exitCode);
    await sandbox.files.write("/tmp/binary", new Uint8Array([0, 128, 255]));
    await sandbox.pause();
    await sandbox.resume();
  } finally {
    await sandbox.destroy();
  }
} finally {
  await client.dispose();
}

verify() lists machines without creating anything. Machine lists have no pages; the adapter filters their complete array by metadata, state and limit. Lists are scoped to the configured region and organization. An ordinary named create() is found by getOrCreate() with that exact name. Retried creates derive a stable name from the idempotency key when no name was supplied. Destroyed entries are never reused. getInfo() reads current state rather than the creation response.

Templates and snapshots

const template = await client.templates.build({
  name: "ubuntu-base",
  source: { image: "ubuntu:24.04" },
  env: { APP_MODE: "agent" },
  readyCmd: "test -d /tmp",
});
const sandbox = await client.create({ template });
const snapshot = await sandbox.snapshots.create({ name: "workspace-save" });
const restored = await client.create({ fromSnapshot: snapshot });
const [fork] = await sandbox.fork();
// Destroy all three machines when finished. Delete snapshots/templates separately.

Templates boot a temporary machine, run an optional readiness command, capture its memory and disk in an account snapshot, then delete the temporary machine. Sources are public images or existing snapshots. Cache keys and aliases are stored in snapshot names. The adapter waits until the newly captured version is ready before returning. Dockerfiles, registry auth, template user, workdir and startCmd are refused. Snapshots and forks include memory. Filesystem-only snapshots and restoring a snapshot into an existing machine are unavailable. Snapshot restores inherit size and volumes; requests to change them are rejected. Cancelling an overwrite preserves earlier snapshot versions; the server may still finish the newly submitted version. Snapshot references belong to the configured region and account.

Previews and browser access

const preview = await sandbox.ports.expose(3000);
console.log(preview.url, preview.auth); // public HTTPS route

The adapter creates a named HTTPS proxy sbox-3000 and turns machine-wide bot protection off so the public route can be used by browsers and WebSockets. This affects all routes on the machine. WebSocket URLs use the same host with wss://. Private previews are unsupported; bot protection is not authentication. Ports declared in create() configure named proxies, while ports.expose() also sets their public access behavior. Raw TCP/UDP forwarding is available through sandbox.raw().client.machines.ports.

Capabilities

CapabilityLevelNotes
streaming / stdinnativeseparate stdout/stderr, real exit codes, stdin and EOF
ptynativemerged output, resize
listnativeone unpaged list, filtered locally by metadata, state and limit
stopnativedisk persists (preservesDiskOnStop)
pausenativesuspend keeps RAM (preservesMemoryOnPause)
setTimeoutnativedelete-after deadline
filesUploadnativebinary-safe transfers
snapshot / forknativememory and disk
egressControlnativeallow-all, block-all and hostname/IPv4 allow-list; no deny, inject
exposePortnativepublic HTTPS proxies
volumesnativepersistent disks
templateBuildnativepublic image or snapshot sources, captured as a snapshot
regionnativespec.region or the region option
privatePreviewunsupportedpreviews are public
background / killProcessunsupportedno PID and no reconnect token in the SDK
metricsunsupportedthe SDK reports billing usage only
sshunsupportedneeds a separately linked public key
filesWatch / proxiedFetchunsupported
codeInterpreterunsupported
statefulKernelunsupported
gpu / secretsVaultunsupported

Create contract

  • Idempotency is exact. Machine names are unique, so a duplicate create is a Conflict. An unnamed create() derives the name sbox-<24 hex> from the idempotency key, looks for it first, and adopts its own machine when a retry or a racing process conflicts. A name you choose is never adopted by a plain create(): a machine already holding it makes the call fail with Conflict (only a retry of the same call, or getOrCreate(), adopts it). Machines in a deleting state are not reused.
  • Limits. Metadata becomes machine labels: at most 64 entries, keys up to 63 characters and values up to 256 (from the SDK's label rules; the server also restricts key characters and reserves the boxd/ prefix). Idle and max-age timeouts are rounded up to whole seconds.
FieldSupportBehaviour
resources.vcpus/memoryMBapproximatesmallest 1/4, 2/8, 4/16 or 8/32 (vCPU / GiB) tier that fits both
resources.diskMBapproximatedisk is fixed at 100 GiB; larger requests throw
resources.shmMBrejectedcustom shared memory is unavailable
resources.gpu/gpuCountrejectedno GPUs
lifecycle.idleTimeoutMsapproximateauto-suspend (or auto-destroy with onIdle: "destroy"), whole seconds
lifecycle.maxAgeMsapproximatedelete-after, whole seconds

Idle stop and autoResume: false are refused.

Sizes

spec.size maps onto boxd's four fixed machine sizes, so every preset lands on a real tier. All of them have the fixed 100 GiB disk.

PresetMachine
small1 vCPU, 4 GiB RAM
medium2 vCPU, 8 GiB RAM
large4 vCPU, 16 GiB RAM
xlarge8 vCPU, 32 GiB RAM

Snapshot restores inherit their size, so size or resources together with fromSnapshot or a snapshot template throws Validation.

How the spec maps

sboxboxd
namename (must be unused)
idempotencyKeysbox-<24 hex> name when unnamed; a retried create reuses it
templateimage
fromSnapshot / snapshot templatefromSnapshot
env, inline secretsmachine env
stored secretsmachine spec secrets (default image only, no rename)
metadatalabels
resources.vcpus / memoryMBsize / vcpu + memory, rounded up to a tier
regionregion
lifecycle.idleTimeoutMsautoSuspendTimeout (autoDestroyTimeout for onIdle: "destroy")
lifecycle.maxAgeMs / ttlMsdeleteAfter
networkmachine spec egress (default image only)
volumesconfig.volumes
portsnamed sbox-<port> proxies
Hover a cell to inspect.
Capability support and create contract by provider.
CapabilityIn-Memory19nDocker19nRivet agentOS9nArchil16nMicrosandbox14nMicrosandbox Cloud8nE2B22nDaytona24nVercel16nModal17nTensorlake18nSuperserve16nFly Sprites13nFreestyle11nTogether11nMaritime15nboxd15nLuxor Agent Cloud14nBuddy Sandboxes10nInstabox14nUpstash Box13nStyne18nAgent3713nBaseten14nBlaxel18nBoat13nBeam13nRailway11nNorthflank13nFly Machines10nAWS Lambda MicroVMs10nMorph10nCloudflare14nCodeSandbox7nRunloop6n
lifecycle
list
stop
pause
setTimeout
exec
background
streaming
killProcess
pty
stdin
filesystem
filesWatch
filesUpload
code
codeInterpreter
statefulKernel
network
exposePort
privatePreview
egressControl
ssh
proxiedFetch
snapshot
snapshot
fork
volumes
templateBuild
meta
gpu
region
secretsVault
metrics
create contract
idempotency
spec fidelity
vcpus
memoryMB
diskMB
shmMB
gpu
idleTimeoutMs
maxAgeMs
size presets
small
medium
large
xlarge
limits
maxPorts01503250
maxLabels30564520
labelKeyLength63596363
labelValueLength256256256
minIdleTimeout1m1m1s5m1m
idleTimeoutStep1s1m1s1s1s1s1s1s1s1s1m1s1s1s
minMaxAge1m1s5m5m
maxAgeStep1s1s1m1s1s1s1s1s1s1s1s1s1s1s1s1s
native · exact · native tier emulated · approximate · best-effort · default ladder unsupported · ignored · none✕ rejected
  • Exec streams keep stdout and stderr separate and preserve real exit codes. PTY streams merge them, as terminals normally do. Stdin, EOF and resize are supported. Commands honor env and cwd. The SDK does not expose a PID or a PTY reconnect token. Background reconnect and killing arbitrary PIDs are unavailable.
  • kill() and timeouts cancel the gRPC stream. Current boxd servers terminate its process group with TERM, then KILL. The streaming API has no timeout parameter, so the adapter applies timeoutMs with a timer and closes the stream. user selection and arbitrary signal delivery are refused.
  • Sizes are 1 vCPU / 4 GiB, 2 / 8, 4 / 16 and 8 / 32. The adapter chooses the smallest satisfying size. Disk allocation is fixed at 100 GiB. GPUs and custom shared memory allocation are unavailable.
  • Idle pause and idle destroy map to native timers, rounded up to seconds. Idle stop and autoResume: false are refused. setTimeout() sets the delete-after deadline. Pausing preserves RAM; stopping preserves disk.
  • Egress allows hostnames and public IPv4 addresses, or none to block all. CIDR ranges, deny rules and credential injection are refused. Default-image creates use machine specs to apply egress at birth. Custom image creates with egress or stored secret references are refused; build a snapshot template first.
  • Inline secrets become environment variables. Stored secrets can be referenced by name through machine specs; renaming them is refused. This adapter does not manage the account secret vault.
  • Volumes use native persistent disks and create-time mounts. They can attach to only one machine at a time. Delete disks separately after destroying machines.
  • Native file transfers preserve binary data. Directory operations and stat use machines.fs, which requires a current guest agent. Older agents report AgentOutdatedError; reboot the machine. The adapter avoids listDir's 5,000 entry cap by using the current filesystem API.
  • SSH requires a separately linked public key; the adapter cannot mint a private credential. Resource usage is billing accounting, so metrics is unsupported. File watches and code interpreter sessions are also unsupported.
  • The adapter uses the SDK's gRPC transport, not the core's injected fetch. Call client.dispose() to cancel local streams and close channels. It does not delete persistent machines, snapshots or disks.

Validation uses typed SDK fakes with MiniShell and local transport probes. Hosted account behavior and self-hosted server compatibility require live account tests.

On this page