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
}'
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())
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());
{
"id": "ab12cd34ef",
"status": "running",
"resources": {
"cpu": 4,
"memory": 8,
"disk": 6
}
}
Lifecycle
Resize an instance
Change an instance’s CPU, memory, or disk while keeping its id and URLs.
POST
/
v1
/
instances
/
{id}
/
resize
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
}'
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())
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());
{
"id": "ab12cd34ef",
"status": "running",
"resources": {
"cpu": 4,
"memory": 8,
"disk": 6
}
}
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
}'
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())
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());
{
"id": "ab12cd34ef",
"status": "running",
"resources": {
"cpu": 4,
"memory": 8,
"disk": 6
}
}
Authorization: Bearer sk_live_... on https://api.agent37.com.
Path parameters
string
required
The instance id, returned when you create an instance.
Request body
integer
Target vCPUs. Send a valid CPU and memory shape; omitted values keep their current value.
integer
Target memory in GB. See instance sizing for valid shapes.
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).
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 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.
curl
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 } }