Skip to main content
Volumes are durable storage that outlives any sandbox and can be mounted into several at once. This example creates a volume, mounts it read-write in one sandbox and read-only in another, and shows a write flowing between them.
Requires a deployment with the shared-volume backend enabled (the hosted private beta has it).

Setup

uv pip install "nullspace-sdk==0.1.9"
export NULLSPACE_API_KEY=ns_live_...
export NULLSPACE_API_URL=https://api.your-nullspace-domain

Python

shared_volume_example.py
import uuid

from nullspace import Sandbox, Volume, VolumeMount

volume = Volume.create(f"shared-{uuid.uuid4().hex[:8]}")
writer = reader = None
try:
    writer = Sandbox.create(
        template="base", timeout=120,
        volumes=[volume.mount("/workspace/shared")],
    )
    reader = Sandbox.create(
        template="base", timeout=120,
        volumes=[VolumeMount(ref=volume.name, mount_path="/workspace/shared",
                             read_only=True)],
    )

    writer.files.write("/workspace/shared/hello.txt", "hello from shared volume\n")
    print("reader saw:", reader.files.read("/workspace/shared/hello.txt").strip())
finally:
    for sandbox in (writer, reader):
        if sandbox is not None:
            sandbox.kill()
    volume.delete()

Expected output

reader saw: hello from shared volume
Writes land in the volume, not the sandbox rootfs — destroy both sandboxes and the data stays until volume.delete(). The read-only mount makes the reader’s side of the tree immutable; writes there fail with a permission error. Related: Volumes overview · Mounting volumes