# POST /chat-widgets/:widget_id/sessions/delete-older

**Resource:** [CHAT_WIDGETS](./chat-widgets.md)  
**MCP tool:** `delete_old_chat_widget_sessions`  
**Scopes:** `chat-widgets:write`  
**Write operation:** yes

Erase every saved chat on a widget that started more than older_than_days days ago (1 to 3650). Messages and visitor details are removed for good. Leads already created are not touched. Answers how many were erased; more_remain true means run it again.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `widget_id` | path | string | yes | The chat widget id. |
| `older_than_days` | body | number | yes | Erase chats that started more than this many days ago (1 to 3650). |
| `require_approval` | body | boolean | no | Optional. Set true to route this write into the approval queue for human review instead of executing it immediately (returns 202 + an approval_id). Works even when your key/token has permission to execute directly. |

## Request example

```bash
curl -X POST   "https://api.trustpager.com/functions/v1/api/v1/chat-widgets/:widget_id/sessions/delete-older"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"older_than_days":"...","require_approval":"..."}'
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`