Microsandbox CloudBeta

Managed microVMs with native exec streams, stdin, PTY, binary files, volumes and stopped filesystem snapshots. Beta; Node 22 or newer.

Cloud uses its own static capability map. Local pause, retained jobs, memory snapshots, fork and SDK metrics are absent from cloud handles.

Installation and authentication

pnpm add sbox-sdk microsandbox@0.8.3 @microsandbox/remote@0.8.3

Node 22 or newer is required. The full 0.8.3 package omitted its native platform dependencies. Import the matching lean remote distribution to register its binding, or install the full platform binding described in the local adapter guide.

An organization API key or stored Microsandbox remote profile.

Authentication variables for the microsandbox-cloud adapter.
OptionEnv varRequiredDescription
apiKeyMSB_API_KEYoptionalCloud key, required unless a stored profile supplies it.
apiUrlMSB_API_URLoptionalAPI endpoint. Defaults to https://api.microsandbox.dev.
profileMSB_PROFILEoptionalStored remote profile. Pass profile explicitly; cannot combine with explicit key/URL/timeout.
imageMSB_IMAGEoptionalDefault OCI image.

The SDK reads MSB_API_KEY/MSB_API_URL when options are omitted. profile is explicit in TypeScript and mapped from MSB_PROFILE by the CLI. Cloud has a smaller capability map.

import "@microsandbox/remote";
import { createSandboxClient } from "sbox-sdk";
import { microsandboxCloud } from "sbox-sdk/microsandbox";

const client = createSandboxClient({
  provider: microsandboxCloud({
    apiKey: process.env.MSB_API_KEY,
    apiUrl: process.env.MSB_API_URL,
  }),
});
const sandbox = await client.create({ template: "alpine:3.22" });
try {
  console.log(await sandbox.commands.run("echo cloud", { cwd: "/tmp" }));
} finally {
  await sandbox.destroy();
}

The discovery alias sbox-sdk/microsandbox-cloud exports the same cloud factory. MSB_API_KEY and MSB_API_URL are resolved by the SDK when options are omitted. The default endpoint is https://api.microsandbox.dev. Use { profile: "work" } for a stored remote profile. Profile selection cannot combine with explicit key, URL or timeout options. The CLI maps MSB_PROFILE to that explicit option. The factory captures a RemoteContext without changing MSB_BACKEND or other process environment variables.

verify() sends an authenticated list request with limit 1. It never creates or starts a sandbox. Native transport owns its HTTP requests; client.fetch does not replace the SDK's transport.

Supported behavior

Cloud provides native stdout/stderr streaming, exit codes, cwd/env/user overrides, timeouts, stdin, attached PTYs and native binary files. Sandboxes are persistent; destroy() stops and deletes them. State and labels are fetched afresh, and list traverses all pages before applying metadata, state and limit filters.

OCI images, CPU/memory/root disk sizes, env, labels, whole-second idle/max-age limits and creation-time network policies follow the local adapter mapping. Create cloud directory volumes before mounting them. Disk-backed volumes and creating a volume as part of a mount are not mapped.

Filesystem snapshots require a stopped persistent source:

await sandbox.stop();
const snapshot = await sandbox.snapshots.create({ mode: "filesystem" });
const restored = await client.create({ fromSnapshot: snapshot });

Cloud memory snapshots are rejected, and includesMemory remains false for filesystem snapshots. Restore creates a new sandbox ID. Snapshots are separate resources and remain caller-owned after sandbox deletion.

Previews and unsupported features

Microsandbox Services provide public HTTPS, but SDK 0.8.3's Service API has no retained-context overload. It routes through ambient backend/profile settings. This adapter does not change process-wide settings or risk routing another factory's Services to the wrong account, so cloud exposePort is unsupported. No preview auth mode or browser WebSocket auth is advertised. Use Microsandbox's Services tooling separately if public URLs are required.

Retained background jobs, process reconnect/list/kill by ID, pause, fork, memory snapshots and SDK metrics are local-only. Running ExecHandle.kill() still controls its attached command. SSH credentials, template builds, file watching, code interpreters, GPU and region are unsupported. Creation-time network rules and lifecycle limits cannot be changed through network or setTimeout() after creation.

Inline guest env secrets are accepted. Vault references, egress secret refs and network.inject are rejected because placeholder substitution has different semantics from header insertion.

Capabilities

CapabilityLevelNotes
streaming / stdinnativenative exec streams, stderr kept separate, real exit codes
ptynativeattached PTYs on the same sandbox handle
filesUploadnativenative binary file streams
listnativecursor-paginated, then filtered by state, metadata and limit
stopnativedisk persists (preservesDiskOnStop)
snapshotnativefilesystem only, from a stopped sandbox
volumesnativenamed directory volumes
background / killProcessunsupportedretained jobs are local-only
pause / fork / metricsunsupportedlocal-only
exposePortunsupportedSDK Service API has no retained-context overload
egressControlunsupportedno live policy setter; spec.network is applied at create
setTimeoutunsupportedidle and max-age limits can't change after create
privatePreviewunsupported
templateBuildunsupportedbuild OCI images with external tooling
region / gpuunsupportedrejected at create
secretsVaultunsupportedinline env secrets only
sshunsupported
codeInterpreterunsupported
statefulKernelunsupported
filesWatch / proxiedFetchunsupported

idempotency is exact: an unnamed create gets a name derived from the idempotency key and the adapter never replaces an existing sandbox, so a retried create fails with Conflict instead of making a second VM.

How the spec maps

sboxMicrosandbox Cloud
template / templateRef.idimage (OCI reference; default alpine:3.22)
fromSnapshotsandboxes.restore(checkpoint), a new sandbox
name / idempotencyKeysandbox name (sbox-<sha256(key)> when unnamed)
env, env-mode secretsenvs / env
metadatalabels
resources.vcpuscpus (exact)
resources.memoryMBmemory MiB (exact)
resources.diskMBrootDisk MiB (exact; rejected with fromSnapshot)
resources.shmMB / gpu / gpuCountrejected
lifecycle.idleTimeoutMsidleTimeoutSeconds (exact; must be whole seconds)
lifecycle.maxAgeMsmaxDurationSeconds (exact; must be whole seconds)
lifecycle.onIdle / autoResumeonly "stop" / false; other values are rejected
networknetwork.policy rules at create
volumesnamed volume mounts
ports / regionrejected

There are no fixed size tiers, so spec.size uses the default ladder. The adapter declares no label limits.

Verification

Offline MiniShell conformance covers cloud with one named skip for the generic running-snapshot check; separate tests enforce stopped-only snapshots. Real SDK tests send requests to a loopback server with fake keys and check auth, pagination, live state and HTTP errors. No paid cloud sandboxes were created, and live account behavior remains unverified.

Live cloud conformance requires explicit opt-in and can incur charges:

MSB_API_KEY=... MSB_CLOUD_LIVE=1 SBOX_LIVE=microsandbox-cloud pnpm --filter sbox-sdk test:live

On this page