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

# What happens when my Novita account balance runs out?

> New sandboxes fail with a 402 error and running sandboxes are terminated, losing their data. Set a low-balance alert and top up before that happens.

When your available balance, including vouchers, can't cover your bill, the account is overdue: new sandboxes can't start, and running sandboxes are terminated, which loses their data. Creating a sandbox returns `SandboxException: 402: insufficient balance` until you top up.

## Details

| What happens | When |
| - | - |
| `sandbox.create` fails with `402: insufficient balance` | Balance can't cover a new sandbox |
| Running sandboxes are terminated and their data is lost | The account becomes overdue |
| Notification emails are sent | After the account becomes overdue |
| Low-balance email | When balance drops below the alert threshold you set |

Persist anything you can't afford to lose — push code to Git, save [snapshots](https://docs.novita.ai/guides/sandbox-snapshot-create.md), or copy files out with [download](https://docs.novita.ai/guides/sandbox-filesystem-download.md).

## How to

1. Set a [low balance alert](https://novita.ai/billing/balance-warning) so you're emailed before the balance runs out.
2. Check balance and vouchers on the [Payments](https://novita.ai/billing) page, and top up there.
3. Handle the error in code so a batch stops cleanly instead of retrying:

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

try:
    sandbox = Novita().sandbox.create()
except SandboxException as e:
    if "402" in str(e):
        raise SystemExit("Top up your Novita balance: https://novita.ai/billing")
    raise
```

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

try {
  const sandbox = await new Novita().sandbox.create()
} catch (e) {
  if (String(e).includes('402')) throw new Error('Top up your Novita balance: https://novita.ai/billing')
  throw e
}
```

Learn more: [Pricing — overdue payment notice](https://docs.novita.ai/guides/sandbox-pricing.md#overdue-payment-notice)

## Related questions

* [How much does Novita Sandbox cost?](https://docs.novita.ai/guides/sandbox-faq-pricing.md)
* [Is there a free tier for Novita Sandbox?](https://docs.novita.ai/guides/sandbox-faq-free-tier.md)
* [Are paused Novita sandboxes billed?](https://docs.novita.ai/guides/sandbox-faq-paused-sandboxes.md)


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