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

# Resize Sandbox

> Increase a running sandbox's CPU, memory, and disk with the SDK or CLI, check per-resource results, and inspect current resources and quotas.

Use `resize` to increase a running sandbox's CPU, memory, or disk without restarting it. Supply the desired **total allocation**, not the amount to add. To set resources before a sandbox starts, see [Create Sandbox](https://docs.novita.ai/guides/sandbox-create.md#specify-cpu-memory-and-disk).

Requires version 2.1.4 or later of whichever SDK (JavaScript/TypeScript or Python) or CLI you use.

> [!NOTE]
>
> Existing processes may need to be restarted or have their configuration adjusted to use the additional resources. For example, a JVM heap limit set with `-Xmx` or a thread pool with a fixed size configured at startup may not automatically increase after a resize.

## Resize a running sandbox

Specify at least one resource. Omitted resources are unchanged. Replace the sandbox ID with an existing, running sandbox and choose targets within your [quota](https://docs.novita.ai/guides/sandbox-quota-limit.md).

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

const result = await Sandbox.resize(
  'YOUR_SANDBOX_ID',
  { cpu: 4, memoryGiB: 8, diskGiB: 40 },
)

for (const [name, item] of Object.entries(result)) {
  if (!item) continue
  console.log(name, item.status, item.current)
  if (item.status === 'failed' || item.status === 'unknown') {
    console.error(name, item.reason ?? item.message)
  }
}
```

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

sandbox = Sandbox.connect("YOUR_SANDBOX_ID")
result = sandbox.resize(cpu=4, memory_gib=8, disk_gib=40)

for name, item in result.items():
    print(name, item["status"], item.get("current"))
    if item["status"] in ("failed", "unknown"):
        print(name, item.get("reason") or item.get("message"))
```

```bash CLI icon="terminal" theme={"system"}
novita sandbox resize <sandboxID> --cpu 4 --memory-gib 8

# Include disk if your quota permits the target size.
novita sbx resize <sandboxID> --disk-gib 40 --output json
```

## Resource values and units

| Resource | JavaScript | Python | CLI | Target unit |
| - | - | - | - | - |
| CPU | `cpu` | `cpu` | `--cpu` | vCPU; only 1, 2, 4, 8, or 16. Other values, such as 3 or 5, are not supported. |
| Memory | `memoryGiB` | `memory_gib` | `--memory-gib` | GiB |
| Disk | `diskGiB` | `disk_gib` | `--disk-gib` | GiB |

* Values must be positive absolute totals. For example, `memoryGiB: 8` means 8 GiB in total, not 8 GiB more.
* Resources can only grow. A target equal to the current value is `skipped`; a lower target fails.
* New memory and disk totals must be whole GiB. An existing non-whole-GiB allocation can be kept unchanged if it represents a whole number of MiB.
* CPU-to-memory ratios from 1:0.5 (for example, 2c1g) through 1:2 are supported.

## Billing after resize

From the time an expansion takes effect, CPU and memory are billed at the new CPU and memory specifications. Disk is not billed while the sandbox is running. After the sandbox is paused, the storage fee is based on the disk capacity.

## Handle partial success

Each requested resource can succeed or fail independently. For example, CPU can increase while memory remains unchanged. A failed resource does **not** roll back successful changes.

> [!WARNING]
>
> Always inspect each resource's `status` and `current` value. A resolved SDK call or CLI exit code of 0 does not mean every resource was resized successfully.

### Result fields

The result contains an entry for each requested resource (`cpu`, `memory`, or `disk`). `requested`, `previous`, and `current` are totals in cores for CPU and GiB for memory and disk.

| Status | Meaning and action |
| - | - |
| `applied` | The target total is active. |
| `skipped` | The resource already matched the target. |
| `failed` | The resource was not resized; check `reason` and `message`. |
| `unknown` | The result is not yet confirmed. [Query sandbox details](#check-current-resources-and-quotas) again later; do not treat the reported allocation as final. |

### Errors

For failed resources, check that targets meet the [value requirements](#resource-values-and-units) and your [quota](https://docs.novita.ai/guides/sandbox-quota-limit.md). Request-level errors can still raise an SDK exception or produce a nonzero CLI exit code.

## Check current resources and quotas

Sandbox details report CPU in cores and memory and disk in **MiB**, unlike resize's GiB values. Check current resources and quota before choosing a target.

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

const info = await Sandbox.getInfo('YOUR_SANDBOX_ID')
console.log(info.cpuCount)   // cores
console.log(info.memoryMB)   // MiB
console.log(info.diskSizeMB) // MiB

const quota = await Sandbox.getQuota()
console.log(quota.limit.maxVcpu, quota.usage.concurrentVcpu)
```

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

sandbox = Sandbox.connect("YOUR_SANDBOX_ID")
info = sandbox.get_info()
print(info.cpu_count)     # cores
print(info.memory_mb)     # MiB
print(info.disk_size_mb)  # MiB

quota = Sandbox.get_quota()
print(quota.limit.max_vcpu, quota.usage.concurrent_vcpu)
```

```bash CLI icon="terminal" theme={"system"}
novita sandbox info <sandboxID>
novita sandbox list
novita sandbox quota
```

## FAQ

### Do I need to create a new template to change resources?

No. Set `resources` when [creating a sandbox](https://docs.novita.ai/guides/sandbox-create.md#specify-cpu-memory-and-disk), or use `resize` to expand a running sandbox. Fields omitted at creation use the template defaults; fields omitted from a resize request keep their current values.

### Why hasn't memory increased even though the command succeeded?

Check the memory entry's `status`. For `failed`, inspect `reason` and `message`; for `unknown`, [query sandbox details](#check-current-resources-and-quotas) again later to confirm the allocation. A CLI exit code of 0 does not mean every resource was resized successfully.

### How should I handle a resize request error?

* `400`: The request parameters or resource values are invalid. Check the error message and ensure targets meet the [value requirements](#resource-values-and-units).
* `403`: The request was denied. Check whether your account or API key has access to the sandbox and follow the returned error message. If the error explicitly indicates insufficient quota, check your [quota](https://docs.novita.ai/guides/sandbox-quota-limit.md) or request an increase.
* `404`: The sandbox does not exist or is unavailable. Verify the sandbox ID and confirm the sandbox still exists.
* `409`: The request conflicts with another operation. Check the sandbox's current state and the error message, then retry after the conflict ends; resize requires a running sandbox.
* `412`: A prerequisite state condition is not met. Query the Sandbox's current status or details, confirm it is in a running state eligible for resize, then retry.

### What happens if expansion fails?

A per-resource `failed` result does not stop the sandbox or roll back successful changes; the failed resource keeps its previous allocation. For request-level errors or an `unknown` result, [query sandbox details](#check-current-resources-and-quotas) to confirm the current sandbox status and resource allocation. See [per-resource statuses](#result-fields).

### Can I shrink a sandbox or reduce its disk?

No. Resize only expands resources, so lower targets fail and disk cannot be reduced. If you need a smaller disk, [create a new sandbox with a suitable disk size](https://docs.novita.ai/guides/sandbox-create.md#specify-cpu-memory-and-disk) that meets the template minimums and your quota.


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