Pattern: Deletion, retention schedule and legal hold

Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.

Search terms: data deletion, retention schedule, backup retention, legal hold, soft delete, cleanup job, right to erasure, storage limitation, linked records

Last reviewed:

For agents

1. Problem

“Delete” can mean hidden, removed from the database, removed from backups, or removed from third-party processors. If the notice to users and the real behaviour differ, trust and compliance suffer. Cleanup jobs that silently skip work are worse than no jobs.

2. Options

Method Upside Downside
Hard delete immediately Simple; data gone Backups still hold it; no undo for mistakes; conflicts with open reports
Soft delete only Easy undo Data stays forever unless a purge job exists
Staged timeline (recommended) Honest, predictable, supports undo and holds Needs scheduled jobs and monitoring

Timeline (example values)

  1. At the moment of deletion: invisible to users and APIs.
  2. Within at most 7 days: removed from the live database and storage.
  3. Backups: remain for at most 30 more days (the backup rotation), then gone. So the latest everywhere is about day 37.
  4. The terms of service state this correctly. On-screen short notes must not understate backup and third-party (for example AI provider) retention.

Legal hold

Linked records

Cleanup jobs

Account deletion has extra store rules: see data export and account deletion.

4. Scenarios and edge cases

5. Common mistakes

6. How to audit

Sources