> ## Documentation Index
> Fetch the complete documentation index at: https://www.agent37.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Resize an instance

> Change an instance's CPU, memory, or disk while keeping its id and URLs.

```bash curl wrap theme={null}
curl -X POST \
  https://api.agent37.com/v1/instances/ab12cd34ef/resize \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "cpu": 4,
    "memory": 8,
    "disk": 6
  }'
```

```python Python wrap theme={null}
import requests

response = requests.post(
    "https://api.agent37.com/v1/instances/ab12cd34ef/resize",
    headers={
        "Authorization": "Bearer sk_live_...",
        "Content-Type": "application/json"
    },
    json={
        "cpu": 4,
        "memory": 8,
        "disk": 6
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/resize",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_live_...",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "cpu": 4,
      "memory": 8,
      "disk": 6
    }),
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

```json 200 wrap theme={null}
{
  "id": "ab12cd34ef",
  "status": "running",
  "resources": {
    "cpu": 4,
    "memory": 8,
    "disk": 6
  }
}
```

Authenticate with `Authorization: Bearer sk_live_...` on `https://api.agent37.com`.

## Path parameters

**id** `string` *required*

The instance id, returned when you create an instance.

## Request body

**cpu** `integer`

Target vCPUs: up to 4, or 8 with 64 GB of memory on a VM or Performance instance. Send a valid CPU and memory shape; omitted values keep their current value. Unlike create, resize does not adjust a shape for you: a pair that is not a shape returns `400` with the valid ones listed.

**memory** `integer`

Target memory in GB. See [instance sizing](https://www.agent37.com/docs/agents-api/instance-sizing.md) for valid shapes.

**disk** `integer`

Target disk in GB. Disk can grow but cannot shrink. At least one dimension must change.

## Behavior and errors

`POST /v1/instances/{id}/resize` changes a running instance's size, keeping its id and URLs. The body uses the same vocabulary as create's `resources`, and omitted fields keep their current value, so `{ "disk": 10 }` grows disk alone and `{ "cpu": 4, "memory": 8 }` moves to another shape (disk carries over unchanged). `cpu` and `memory` go in either direction, so the call that scales an instance up for a burst is the one that scales it back down afterwards. `disk` only ever grows: a smaller one returns `400`, since the quota sits on a tree that already holds the data. At least one dimension has to change, or the call returns `400`. The ack carries the new `resources`, and the meter bills at the new rate from the moment of the resize (see [Billing](https://www.agent37.com/docs/agents-api/billing.md)).

More memory counts toward the workspace's [memory limit](https://www.agent37.com/docs/agents-api/billing.md#memory-limit) like any instance does: a resize that would take the running total past it returns `409 instance_limit_reached` and changes nothing.

A smaller shape takes effect the moment the container is recreated, so leave room for what the agent actually uses: an instance that goes past its memory limit is killed whole, not just the process that asked for the memory. [Metrics](https://www.agent37.com/docs/agents-api/metrics.md) show its real working set, which is the number to size against.

When its current host has room, the container is recreated in place with the new limits, like `restart`: the disk, instance id, and URLs are kept, in-memory state is lost, and the instance is back in seconds. A shrink always fits where the instance already is, so it always takes that path. When the host cannot fit an increase, the platform moves the instance to one that can: it stops, its data is copied over, and it boots on the new host, so it is down for the copy (about a couple of minutes per 10 GB) and no writes are lost. A move that runs longer than the request returns `202` with the instance still `updating`, and the platform finishes it on its own: poll `GET /v1/instances/{id}` until it reads `running`. Only when no host has room at all does it return `409 capacity_unavailable`, changing nothing.

```bash curl wrap theme={null}
curl -X POST https://api.agent37.com/v1/instances/ab12cd34ef/resize \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "cpu": 4, "memory": 8 }'
# -> { "id": "ab12cd34ef", "status": "running", "resources": { "cpu": 4, "memory": 8, "disk": 4 } }

# ...and back down when the burst is over. The 4 GB disk stays.
curl -X POST https://api.agent37.com/v1/instances/ab12cd34ef/resize \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "cpu": 2, "memory": 4 }'
# -> { "id": "ab12cd34ef", "status": "running", "resources": { "cpu": 2, "memory": 4, "disk": 4 } }
```

See [Instance lifecycle](https://www.agent37.com/docs/agents-api/instance-lifecycle.md) for disk persistence and boot hooks. Retrieve the [instance object](https://www.agent37.com/docs/agents-api/instances/get.md) for its full representation.


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