> ## Documentation Index
> Fetch the complete documentation index at: https://docs.novita.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Volume

`novita.volume.create()` creates a new persistent volume that can be mounted into sandboxes to share and persist data across sandbox lifecycles. It returns a `Volume` instance carrying the volume ID, name, and auth token. You can optionally set a capacity quota at creation time.

## Create a volume

```js JavaScript & TypeScript icon="js" theme={"system"}
import { Novita } from 'novita-sandbox'

const novita = new Novita()

// Create a volume with an optional capacity quota
const volume = await novita.volume.create('my-volume', {
  quotaSizeGiB: 10,   // optional: capacity quota in GiB
})

console.log('Volume ID:', volume.volumeId)
console.log('Name:', volume.name)
```

```python Python icon="python" theme={"system"}
from novita_sandbox import Novita

novita = Novita()

# Create a volume with an optional capacity quota
volume = novita.volume.create(
    "my-volume",
    quota_size_gib=10,      # optional: capacity quota in GiB
)

print("Volume ID:", volume.volume_id)
print("Name:", volume.name)
```

```bash CLI icon="terminal" theme={"system"}
novita volume create --name my-volume --quota-size 10
```

## Create and mount into a sandbox

A common flow is to create a volume, create a sandbox, mount the volume at a path, use it, and clean up. The data written to the mount path persists in the volume after the sandbox is killed.

```python Python icon="python" theme={"system"}
from novita_sandbox import Novita

novita = Novita()

# 1. Create a persistent volume.
volume = novita.volume.create("my-volume", quota_size_gib=10)

# 2. Create a sandbox.
sandbox = novita.sandbox.create()

try:
    # 3. Mount the volume at a path inside the sandbox.
    sandbox.mount_volume(volume.name, "/mnt/data")

    # 4. Write data to the mounted volume — it persists in the volume.
    sandbox.commands.run("echo 'hello volume' > /mnt/data/note.txt")
    result = sandbox.commands.run("cat /mnt/data/note.txt")
    print(result.stdout)
finally:
    # 5. Clean up the sandbox. The volume and its data persist.
    sandbox.kill()
```

> [!TIP]
>
> A volume persists independently of any sandbox. Mount it into a sandbox with `sandbox.mount_volume(name, path)`; data written under the mount path remains in the volume after the sandbox is killed, and can be mounted again into other sandboxes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.