> ## Documentation Index
> Fetch the complete documentation index at: https://novita.ai/docs/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.
</Note>

***

## Create a snapshot

Call the method on a running sandbox instance.

<CodeGroup>
  ```python Python icon="python" theme={"system"}
  import os
  from novita_sandbox import Novita

  novita = Novita(api_key=os.getenv("NOVITA_API_KEY", ""))
  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({
    apiKey: process.env.NOVITA_API_KEY || '',
  })
  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()
  ```
</CodeGroup>

***

## Create a snapshot by sandbox ID

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

<CodeGroup>
  ```python Python icon="python" theme={"system"}
  import os
  from novita_sandbox import Novita

  novita = Novita(api_key=os.getenv("NOVITA_API_KEY", ""))
  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({
    apiKey: process.env.NOVITA_API_KEY || '',
  })
  const sandboxId = '<sandboxID>'
  const snapshot = await novita.sandbox.createSnapshot(sandboxId)
  console.log('Snapshot ID:', snapshot.snapshotId)
  ```
</CodeGroup>
