SandboxBuilder
These entry points live onSandboxBuilder and SandboxHandle; they are the bridge between sandboxes and snapshot artifacts.
sandbox.fromSnapshot()
Example
Example
.image(); the snapshot already pins the image. Documented in full on the Sandbox page.
Parameters
pathOrNamestringBare name (resolved under the default snapshots directory) or filesystem path to an artifact directory.
Returns
The same builder, for chaining.
SandboxHandle
handle.snapshot()
~/.microsandbox/snapshots/<name>/). Called on a SandboxHandle. The sandbox must be stopped or crashed; running sandboxes are rejected with a SnapshotSandboxRunning error. To place the artifact elsewhere, use Snapshot.save() / Snapshot.load() or move the self-contained artifact directory.
Parameters
namestringBare name; becomes the artifact directory under the default snapshots dir.
Returns
The created snapshot artifact.
Example
Example
Snapshot
Instance properties
ASnapshot is a snapshot artifact on disk. The artifact directory is the source of truth; the local database index is a rebuildable cache.
snap.path
snap.digest
sha256:hex). The snapshot’s identity.
snap.sizeBytes
snap.imageRef
snap.imageManifestDigest
snap.format
snap.scope
"disk" for a disk-only snapshot, "resumable" once resumable snapshots land. Always "disk" today. See SnapshotScope.
snap.fstype
"ext4").
snap.parent
null for a root.
snap.createdAt
snap.labels
[key, value] pairs.
snap.sourceSandbox
null when the manifest has no source recorded.
Static methods
Snapshot.builder()
name, resolved under the default snapshots directory (~/.microsandbox/snapshots/<name>/) or under .destDir() when set. The fluent builder is what powers the CLI internally. The source sandbox is set with .fromSandbox(), which is required. See SnapshotBuilder for all setters.
Parameters
namestringBare snapshot name; becomes the artifact directory under the default snapshots dir.
Returns
Builder for configuring the snapshot.
Example
Example
Snapshot.open()
Example
Example
verify() for content checks.
Parameters
pathOrNamestringBare name (resolved under the default snapshots dir) or filesystem path.
Returns
The opened snapshot.
Snapshot.get()
Example
Example
SnapshotHandle backed by the local index row.
Parameters
nameOrDigeststringName, digest (
sha256:…), or path of an indexed snapshot.Returns
Index-backed handle.
Snapshot.list()
Example
Example
Returns
All indexed snapshot handles.
Snapshot.listDir()
Parameters
dirstringDirectory to scan for artifact subdirectories.
Returns
Parsed snapshots found in the directory.
Snapshot.remove()
Example
Example
force is set.
Parameters
pathOrNamestringPath, name, or digest of the snapshot to remove.
opts.forcebooleanRemove even if the snapshot has indexed children. Defaults to
false.Snapshot.reindex()
Example
Example
Parameters
dirstringDirectory to scan. Defaults to the configured snapshots dir.
Returns
Promise<number>
Count of artifacts indexed.
Snapshot.save()
.tar.zst archive. The recorded manifest is archived as-is, so create the snapshot with recordIntegrity() if receivers must verify content. See SaveOpts for bundling options.
Parameters
nameOrPathstringName or path of the snapshot to bundle.
outstringOutput archive path.
optsSaveOptsBundling options. All fields default to
false.Example
Example
Snapshot.load()
.tar.zst or .tar) into the snapshots directory. Structural and archive-entry checks run during import; recorded payload integrity is preserved for explicit verify(). Compression is detected from magic bytes.
Parameters
archivestringPath to the archive to unpack.
deststringDestination directory. Defaults to the snapshots directory.
Returns
Handle to the loaded snapshot.
Example
Example
Instance methods
snap.verify()
Example
Example
upper.kind is "notRecorded" when no integrity was recorded.
Returns
Verification result.
SnapshotHandle
A metadata and lifecycle handle for an existing snapshot.Returned by Snapshot.get(), Snapshot.list(), Snapshot.load()
snapshotHandle.digest
string
Manifest digest (sha256:hex), the canonical identity.
snapshotHandle.name
string \| null
Convenience name; null for digest-only entries.
snapshotHandle.parentDigest
string \| null
Parent snapshot’s manifest digest, or null for a root.
snapshotHandle.scope
SnapshotScope
Snapshot payload scope ("disk" today).
snapshotHandle.imageRef
string
Image reference the snapshot was taken from.
snapshotHandle.format
"raw" \| "qcow2"
On-disk format of the upper layer.
snapshotHandle.sizeBytes
bigint \| null
Apparent size of the upper file at index time.
snapshotHandle.createdAt
Date
Snapshot creation time (from manifest).
snapshotHandle.path
string
Local artifact directory path.
snapshotHandle.open()
Snapshot.list()); fetch a live handle via Snapshot.get() first.
snapshotHandle.remove()
force is set. Throws if this handle is read-only.
SnapshotBuilder
Fluent builder for a snapshot, returned bySnapshot.builder(name). Every setter mutates in place and returns this, so calls chain. The source sandbox is required: call .fromSandbox() before .create().
snapshot.fromSandbox()
.create() fails without it.
Parameters
sourceSandboxstringName of the stopped sandbox to capture.
snapshot.destDir()
destDir/<name>; the name stays the snapshot’s identity either way.
Parameters
destDirstringParent directory to create the artifact in (e.g. a larger volume).
snapshot.label()
key=value label to the snapshot manifest. May be called repeatedly.
Parameters
keystringLabel key.
valuestringLabel value.
snapshot.force()
snapshot.recordIntegrity()
snapshot.resumable()
"resumable" snapshot (disk plus VM state). Accepted by the builder, but .create() currently returns an Unsupported error; resumable snapshots have not landed yet.
snapshot.create()
Example
Example
Returns
The created snapshot artifact.
Types
SaveOpts interface
Bundle options forSnapshot.save(). All fields default to false.
Used by Snapshot.save()
SnapshotScope type
Scope of what a snapshot captures. Every snapshot today is"disk"; "resumable" (disk plus VM state) is reserved for resumable snapshots.
Returned by snap.scope · SnapshotHandle.scope
SnapshotVerifyReport union
Result ofsnap.verify(). The upper discriminant is "notRecorded" when no integrity hash was stored at create time, or "verified" when the recorded hash matched the recomputed one.
Returned by snap.verify()