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

# Sleep an instance

> Put an instance to sleep now. It keeps its memory, bills disk only, and wakes on the next request.

```bash curl wrap theme={null}
curl -X POST \
  https://api.agent37.com/v1/instances/ab12cd34ef/sleep \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
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())
```

```javascript Node wrap theme={null}
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());
```

```json 200 wrap theme={null}
{
  "id": "ab12cd34ef",
  "status": "sleeping"
}
```

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.

## Behavior and errors

`POST /v1/instances/{id}/sleep` puts a `running` instance to sleep right away, the same sleep [auto-sleep](https://www.agent37.com/docs/agents-api/instance-auto-sleep.md) 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](https://www.agent37.com/docs/agents-api/exec.md) 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`](https://www.agent37.com/docs/agents-api/instances/start), a command sent through [exec](https://www.agent37.com/docs/agents-api/exec.md), 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](https://www.agent37.com/docs/agents-api/instances/stop.md) 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`](https://www.agent37.com/docs/agents-api/instances/object) 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](https://www.agent37.com/docs/agents-api/vm-instances.md) sleeps with one open.

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.