---
title: "Delete old inbox items on a schedule · Agent Wranglers"
url: https://agentwranglers.se/playbook/notifications/in-app-notifications/inbox-retention
updated: 2026-10-20
licence: "All rights reserved"
---

# Delete old inbox items on a schedule

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [In-app notifications](https://agentwranglers.se/playbook/notifications/in-app-notifications)
- Rule: Delete inbox items after a fixed time, such as 90 days, and show the limit in the inbox.
- How: Old notifications hold personal data and slow the inbox query. Run a daily job that deletes in small batches, as in [delete old data automatically](https://agentwranglers.se/playbook/data/personal-data/retention-jobs). Keep read and unread items for the same time, so nothing piles up unseen. Say "Notifications are kept for 90 days" at the end of the list, and name the period in the privacy policy.
- Check: Insert a test row dated 91 days ago and run the job. The row is gone. A query finds no notification older than 91 days, which allows for one day between runs.

Example:

```sql
DELETE FROM notifications
WHERE id IN (SELECT id FROM notifications WHERE created_at < now() - interval '90 days' LIMIT 1000);
```

```js
const INBOX_RETENTION_DAYS = 90;
export async function pruneInbox() {
  let deleted;
  do deleted = await db.notifications.deleteOlderThan(INBOX_RETENTION_DAYS, { limit: 1000 });
  while (deleted === 1000);
}
```

```python
INBOX_RETENTION_DAYS = 90

def prune_inbox():
    while db.notifications.delete_older_than(INBOX_RETENTION_DAYS, limit=1000) == 1000:
        pass
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers notifications playbook: https://agentwranglers.se/playbook/notifications/in-app-notifications/inbox-retention`.

- Previous: [Announce new items without stealing focus](https://agentwranglers.se/playbook/notifications/in-app-notifications/accessible-inbox)
- [In-app notifications](https://agentwranglers.se/playbook/notifications/in-app-notifications)
