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

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.