curl -X POST \
https://api.agent37.com/v1/instances/ab12cd34ef/sleep \
-H "Authorization: Bearer sk_live_..."
import requests
response = requests.post(
"https://api.agent37.com/v1/instances/ab12cd34ef/sleep",
headers={
"Authorization": "Bearer sk_live_..."
},
)
response.raise_for_status()
print(response.json())
const response = await fetch(
"https://api.agent37.com/v1/instances/ab12cd34ef/sleep",
{
method: "POST",
headers: {
"Authorization": "Bearer sk_live_..."
},
},
);
if (!response.ok) {
throw new Error(await response.text());
}
console.log(await response.json());
{
"id": "ab12cd34ef",
"status": "sleeping"
}
Lifecycle
Sleep an instance
Put an instance to sleep now. It keeps its memory, bills disk only, and wakes on the next request.
POST
/
v1
/
instances
/
{id}
/
sleep
curl -X POST \
https://api.agent37.com/v1/instances/ab12cd34ef/sleep \
-H "Authorization: Bearer sk_live_..."
import requests
response = requests.post(
"https://api.agent37.com/v1/instances/ab12cd34ef/sleep",
headers={
"Authorization": "Bearer sk_live_..."
},
)
response.raise_for_status()
print(response.json())
const response = await fetch(
"https://api.agent37.com/v1/instances/ab12cd34ef/sleep",
{
method: "POST",
headers: {
"Authorization": "Bearer sk_live_..."
},
},
);
if (!response.ok) {
throw new Error(await response.text());
}
console.log(await response.json());
{
"id": "ab12cd34ef",
"status": "sleeping"
}
curl -X POST \
https://api.agent37.com/v1/instances/ab12cd34ef/sleep \
-H "Authorization: Bearer sk_live_..."
import requests
response = requests.post(
"https://api.agent37.com/v1/instances/ab12cd34ef/sleep",
headers={
"Authorization": "Bearer sk_live_..."
},
)
response.raise_for_status()
print(response.json())
const response = await fetch(
"https://api.agent37.com/v1/instances/ab12cd34ef/sleep",
{
method: "POST",
headers: {
"Authorization": "Bearer sk_live_..."
},
},
);
if (!response.ok) {
throw new Error(await response.text());
}
console.log(await response.json());
{
"id": "ab12cd34ef",
"status": "sleeping"
}
Authorization: Bearer sk_live_... on https://api.agent37.com.
Path parameters
Behavior and errors
POST /v1/instances/{id}/sleep puts a running instance to sleep right away, the same sleep auto-sleep applies after the idle timeout. Memory and running processes are saved, CPU and memory are released, the disk stays, and billing drops to the disk rate alone. That includes what you started through exec or SSH: a dev server you left running is still running when the instance wakes. An instance created before November 12, 2026 does so after its next restart. It works whether auto_sleep is on or off, and returns once the instance is asleep: a few seconds for most instances, longer for one with a lot of memory.
Wake it with start, a command sent through exec, or any request to its URLs. With auto_sleep off, the default, a woken instance then stays awake until you put it to sleep or stop it again.
Sleep and stop both release CPU and memory and bill disk alone. A sleeping instance keeps its memory and wakes on the next request; a stopped one loses its memory and stays down until start.
Sleeping an already sleeping instance returns the same ack again; any state other than running returns 400. If another operation on the instance is still running, or the instance is already going to sleep, sleep returns 409 try_again; retry in a few seconds. If the sleep fails, it returns 502 and the instance keeps running.
One failure leaves the instance asleep. When its memory cannot be saved, sleep returns 502 memory_not_saved and the instance is sleeping without its memory: it bills disk alone and wakes on the next request like any sleeper, but boots fresh, with its files kept and its processes gone. Its status_reason reads memory_not_saved until it wakes, and calling sleep again returns 200 with that status_reason in the body. With auto-sleep on, the idle timer puts it to sleep the same way.
The cause you can fix is a named pipe that a program deleted while it still has it open (mkfifo, open, rm), which a sleep cannot save. The message names the pipe. Keep the pipe until the program closes it, or create it under /dev/shm. A VM instance sleeps with one open.
See Instance lifecycle for disk persistence and boot hooks. Retrieve the instance object for its full representation.