> ## 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 Snapshot

> [!NOTE]
>
> **Note:** The sandbox is paused while the snapshot is being created.   Snapshots are persistent and remain available even after the source sandbox is deleted.

***

## Create a snapshot

Call the method on a running sandbox instance.

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

novita = Novita()
sandbox = novita.sandbox.create("base")

# Prepare state you want to preserve
sandbox.commands.run("pip install requests")

# Capture the current state (the sandbox is paused during this)
snapshot = sandbox.create_snapshot()
print("Snapshot ID:", snapshot.snapshot_id)

sandbox.kill()
```

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

const novita = new Novita()
const sandbox = await novita.sandbox.create('base')

// Prepare state you want to preserve
await sandbox.commands.run('pip install requests')

// Capture the current state (the sandbox is paused during this)
const snapshot = await sandbox.createSnapshot()
console.log('Snapshot ID:', snapshot.snapshotId)

await sandbox.kill()
```

```bash CLI icon="terminal" theme={"system"}
novita snapshot create <sandbox_id>
```

***

## Create a snapshot by sandbox ID

You can also create a snapshot without an instance by passing the sandbox ID to the static method.

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

novita = Novita()
snapshot_id = "<sandboxID>"
snapshot = novita.sandbox.create_snapshot(sandbox_id=snapshot_id)
print("Snapshot ID:", snapshot.snapshot_id)
```

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

const novita = new Novita()
const sandboxId = '<sandboxID>'
const snapshot = await novita.sandbox.createSnapshot(sandboxId)
console.log('Snapshot ID:', snapshot.snapshotId)
```


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