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

<RequestExample>
  ```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());
  ```
</RequestExample>

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

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

## Path parameters

<ParamField path="id" type="string" required>
  The instance id, returned when you create an instance.
</ParamField>

## Request body

<ParamField body="cpu" type="integer" post={["optional"]}>
  Target vCPUs. Send a valid CPU and memory shape; omitted values keep their current value.
</ParamField>

<ParamField body="memory" type="integer" post={["optional"]}>
  Target memory in GB. See [instance sizing](/docs/agents-api/instance-sizing) for valid shapes.
</ParamField>

<ParamField body="disk" type="integer" post={["optional"]}>
  Target disk in GB. Disk can grow but cannot shrink. At least one dimension must change.
</ParamField>

## 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](/docs/agents-api/billing)).

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](/docs/agents-api/metrics) 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](/docs/agents-api/instance-lifecycle) for disk persistence and boot hooks. Retrieve the [instance object](/docs/agents-api/instances/get) for its full representation.


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