Snapshots
Use a recent @nodeops-createos/sandbox SDK exposing sandbox.createSnapshot() and client.snapshots. Capture requires a running sandbox without external disks and the owner's account credential. It does not pause the source permanently.
import { createClient, pollUntil } from "@nodeops-createos/sandbox";
const client = createClient(); // CREATEOS_SANDBOX_API_KEY
const source = await client.getSandbox("sb_REPLACE_WITH_RUNNING_ID");
const capture = await source.createSnapshot({
type: "disk",
name: "configured-workspace",
});
console.log("Snapshot ID:", capture.id);
const ready = await pollUntil({
poll: () => client.snapshots.get(capture.id),
done: (snapshot) => snapshot.status === "ready",
failed: (snapshot) =>
snapshot.status === "failed" || snapshot.status === "deleting"
? `Snapshot is ${snapshot.status}`
: undefined,
timeoutMs: 300_000,
});
const restored = await client.createSandbox({ snapshot_id: ready.id });
try {
const { result } = await restored.runCommand("ls", ["/"]);
console.log(result.stdout);
} finally {
await restored.destroy();
}
// Keep the snapshot for reuse, or explicitly delete it when no longer needed:
await client.snapshots.delete(ready.id);A polling timeout does not cancel capture. Keep the logged ID, inspect it with client.snapshots.get(id), and delete it once it is ready or failed if it is no longer needed. Do not destroy a source while its capture still needs it; the API rejects conflicting operations with 409.
| Operation | TypeScript method |
|---|---|
| Capture | sandbox.createSnapshot({ type: "disk" | "full", name? }, options?) |
| List | client.snapshots.list(options?) |
| Iterate | client.snapshots.iterate(options?) |
| Inspect | client.snapshots.get(id, options?) |
| Delete | client.snapshots.delete(id, options?) |
| Restore | client.createSandbox({ snapshot_id: id, ... }, options?) |
Do not combine snapshot_id with rootfs. A disk restore may change shape and grow its disk; a full restore must retain captured CPU, memory and disk size. The snapshot remains usable after its source is deleted. Deleting a snapshot removes it from API visibility but is not immediate artifact erasure. See the REST reference for fields, quota, errors and retention.