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

# Kill Sandbox

Killing a sandbox shuts it down and permanently removes it. A killed sandbox cannot be resumed or reconnected. You can kill sandboxes from the CLI or programmatically through the SDK.

## Kill a connected sandbox

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

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

  // ... use the sandbox ...

  await sandbox.kill()
  ```

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

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

  # ... use the sandbox ...

  sandbox.kill()
  ```
</CodeGroup>

## Kill by sandbox ID

Use the namespace `kill` method when you only have the sandbox ID. It returns `true` if the sandbox was found and killed, and `false` if no sandbox with that ID exists.

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

  const novita = new Novita()
  const killed = await novita.sandbox.kill('sbx-123')
  if (!killed) {
    console.log('Sandbox not found')
  }
  ```

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

  novita = Novita()
  killed = novita.sandbox.kill("sbx-123")
  if not killed:
      print("Sandbox not found")
  ```

  ```bash CLI icon="terminal" theme={"system"}
  # Kill a sandbox by ID (alias: sandbox kl)
  novita-sandbox-cli sandbox kill <sandboxID>
  ```
</CodeGroup>

## Kill all sandboxes

The CLI can kill every running sandbox at once with `-a` / `--all`, optionally filtered by state or metadata.

```bash CLI icon="terminal" theme={"system"}
# Kill all running sandboxes
novita-sandbox-cli sandbox kill -a

# Filter which ones to kill by state or metadata
novita-sandbox-cli sandbox kill -a --state running
novita-sandbox-cli sandbox kill -a --metadata env=test
```
