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

# Auto-delete

> Delete an instance on its own once it has stayed asleep or stopped for a set time.

A sleeping or stopped instance still pays for its disk. Set `auto_delete_seconds` and the platform deletes the instance once it has stayed asleep or stopped for that long, so a sandbox nobody came back to stops costing anything.

```bash theme={null}
curl -X POST https://api.agent37.com/v1/instances \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "auto_sleep": true,
    "idle_timeout_seconds": 900,
    "auto_delete_seconds": 604800
  }'
```

This instance sleeps after 15 idle minutes and is deleted after 7 days asleep.

* The clock runs only while the instance is `sleeping` or `stopped`. A running instance is never deleted, so pair it with [auto-sleep](https://www.agent37.com/docs/agents-api/instance-auto-sleep.md): an instance that never sleeps is deleted only after you stop it.
* Waking or starting the instance resets the clock. The next sleep or stop starts it again from zero.
* The value is an integer from `3600` (one hour) to `31536000` (one year). The instance is deleted within an hour of the time running out.
* `null`, the default, keeps the instance until you delete it.

Change it any time with [`PATCH /v1/instances/{id}`](https://www.agent37.com/docs/agents-api/instances/edit). Set on an instance that is already asleep or stopped, the clock starts at that call. A [fork](https://www.agent37.com/docs/agents-api/instances/fork.md) takes its source's value unless you send one.

An auto-deleted instance goes the way [`DELETE /v1/instances/{id}`](https://www.agent37.com/docs/agents-api/instances/delete) takes one: its URLs stop working, its billing stops, and your [webhooks](https://www.agent37.com/docs/agents-api/webhooks.md) receive the `deleted` status.


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