How to Set Data Retention Rules for Customer Records in SaaS
A practical guide to data retention rules for customer records: how to set durations, build deletion jobs, and prove deletion happened.
Set data retention rules by listing every customer record type, assigning each one a legal or operational lifetime, then enforcing those lifetimes with scheduled deletion jobs that run in code rather than in memory. The rule set needs three inputs: what the law requires, what the product needs in order to function, and what the customer contract promises.
Start with an inventory, not a policy
You cannot set a lifetime for data you have not named. Pull the database schema, list every table that stores anything about a customer, and mark which columns hold personal data.
A data retention rule is a written instruction that sets how long one category of records is kept, which event starts the clock, and what happens when the clock runs out. Personal data means any field that can identify a person, alone or combined with other fields: name, email, address, IP address, device identifier, and often free-text notes.
Most teams find the same thing on their first pass: roughly 60% of the tables in a mature SaaS database hold at least one personal field, and a good share of those tables exist because of a feature nobody uses any more. The unused ones are the cheapest to delete and the easiest to forget.
Group the inventory into retention classes before writing a single duration. Ask three questions of each class:
- Which event starts the clock: account closure, last login, invoice date, or ticket resolution?
- Which obligation sets the floor: tax law, contract terms, a dispute window, or a regulator's guidance?
- Which systems hold a copy: primary database, search index, object storage, analytics warehouse, or a vendor's API?
What are data retention rules in a SaaS product?
Data retention rules are per-record-type instructions that define how long a record is stored, which event starts the retention clock, and how deletion happens. They cover active data, archives, backups, and the evidence you keep proving deletion occurred.
Each rule has four parts: a record class, a duration in days, a clock field that already exists in your schema, and an action such as hard delete, anonymise, or archive to cold storage. Cold storage means a cheaper location that the live application does not query. If a rule has no clock field, it is not a rule, it is a wish.
Retention classes and typical durations
| Record class | Typical retention | Clock starts | Action at expiry | Main risk if kept |
|---|---|---|---|---|
| Account profile | Life of account plus 30 to 90 days | Account closure | Hard delete | Stale contact data |
| Invoices and payment records | Roughly 7 years | Invoice date | Archive, then delete | Tax exposure if deleted early |
| Support tickets | One to three years | Ticket closure | Anonymise, keep thread | Free-text notes holding personal data |
| Product event logs | 30 to 90 days | Event timestamp | Delete | Behaviour profiles rebuilt from logs |
| Authentication logs | 90 days to 1 year | Login attempt | Delete | Incident investigation window too short |
| Backups | 35 to 90 days rolling | Snapshot creation | Expire snapshot | Deleted record reappears on restore |
| Deleted account tombstone | 1 to 3 years | Deletion date | Delete | Re-signup abuse, unresolved disputes |
The durations above are starting points, not legal advice. Your floor comes from the jurisdictions you sell into and the contracts you signed.
How long should you keep customer records?
Keep each record only as long as a named purpose or legal duty requires: roughly 30 to 90 days for raw logs, one to three years for support history, up to seven years for invoices.
Two failure modes sit on either side of that range. Keep too long and you carry storage cost, discovery risk, and a larger breach blast radius. Delete too early and you cannot answer a chargeback, a tax query, or a security incident that surfaces months later.
Retention is usually a maximum, not a target. A customer who closed their account last week does not need session logs kept for a year just because the policy permits it.
Where retention rules leak
Every copy of a record needs a rule, and the copies are rarely in the database you were thinking about. Search indexes, analytics warehouses, support tooling, email logs, and vendor APIs each hold a version of the same customer, often with different lifecycles.
Soft delete is the usual culprit. Soft delete means flagging a row as deleted while leaving the data in place, which is fine for a 30-day undo window and dangerous as a permanent state. Pair it with a hard delete job that runs on schedule, and give the row a tombstone: a minimal record holding an ID and a deletion date so the system can refuse to recreate the account.
Cascade delete means the database automatically removes child records when the parent is removed. It is convenient and it is not enough on its own: files in object storage, rows in a search cluster, and records already sent to a payment provider all sit outside that cascade.
How should the deletion path work?
Deletion should run as a scheduled job that walks a dependency graph from child records to parent records, removes files and search indexes, writes an audit entry, and leaves a minimal tombstone so the system never resurrects the record.
A dependency graph is a map of which records point at which, so the job knows the order that keeps the database consistent. Build it in this order:
- Resolve the record set by clock field, not by a list someone typed.
- Count first, delete second. Write the count to a dry-run log so you spot a job that would remove ten times the expected volume.
- Delete or anonymise child records, then parents.
- Remove files from object storage and documents from the search index.
- Send deletion requests to processors: payment provider, email platform, analytics vendor.
- Write an audit log entry with the rule ID, record count, and timestamp. An audit log is an append-only record of what happened, kept separately from the data it describes.
- Let backups expire on their own clock. You cannot delete inside a snapshot, only let it roll off.
Anonymise means replacing identifying fields with values that cannot be traced back to a person, while keeping the aggregate for reporting. It is often the right action for support tickets and event logs, where the business value sits in the shape of the data rather than the identity.
What should happen when a customer asks for their data to be deleted?
Verify identity, log the request, delete or anonymise the records within the contractual window, and notify any third parties that received the data. Keep a request record and a completion date, not the deleted content itself.
Most products promise a response within 30 days and completion within 30 to 45 days. If you offer a 30-day undo window on account deletion, the erasure request runs after that window closes, and the customer should be told so.
Not everything can be deleted. Invoices held for tax, records under a legal hold, and data tied to an open fraud investigation are typically exempt. Legal hold means a formal instruction to stop deletion because of a dispute or an investigation, and the response should name the exemption and the retention period that applies to it.
Put the rules in configuration
A retention table in your database is easier to review than durations scattered through job code. Give it one row per rule: record class, duration in days, clock field, action, owner, and last reviewed date. The job reads the table at runtime, so changing a duration becomes a config change with a review rather than a deploy.
Treat that table as a product artefact. It belongs in the technical spec for a custom SaaS build, next to the data model, and it should be updated whenever a new table or integration appears. A feature that stores customer data without a retention row is an unfinished feature.
Test the clock
You cannot wait three years to find out whether a rule works. Make the clock injectable, which means the job accepts a reference date as a parameter so tests can pretend it is 2029. Run every job in dry-run mode against a copy of production data first, and compare the row count against the number of records you expect from the clock field.
A useful sanity check: pick 1% of the due records at random, inspect them by hand, and confirm the action taken matches what the rule specified. This catches the mismatch where the rule says anonymise and the code deletes.
Who owns retention after launch?
One named person should own the rule table, review it at least twice a year, and sign off on exceptions. Engineering owns the jobs, legal owns the durations, and the owner reconciles the two when either changes.
Retention rots quietly. A pricing change adds a field, an integration starts copying profiles to a vendor, a support macro starts collecting medical details in a free-text box. None of that triggers a code failure. Twice a year, diff the schema against the retention table and add a row for anything new.
Frequently asked questions
How long should we keep customer data in a SaaS product?
There is no single number. Typical starting points are 30 to 90 days for raw event logs, one to three years for support history, and up to seven years for invoices that tax rules require you to keep. Set each duration from a named obligation or product purpose, and record which one justified it.
Do we have to delete personal data from backups too?
You usually cannot delete a single record inside an immutable backup snapshot, and most privacy regimes accept that. The practical approach is a short backup rotation, typically 35 to 90 days, so deleted records roll off within a window you can document. If a restore happens, the deletion jobs must run again before the restored data goes back into service.
What is the difference between soft delete and anonymisation?
Soft delete flags a row as deleted but keeps the underlying data, which is useful only as a short undo window. Anonymisation replaces identifying fields with untraceable values and keeps the rest for reporting. Support tickets and event logs are often better anonymised than deleted, because the business value is in the pattern rather than the person.
How often should data retention rules be reviewed?
At least twice a year, and every time a new table, integration, or data-collecting feature ships. Retention rules break silently: nothing fails when a new field starts storing personal data with no expiry. A schema diff against the retention table is the fastest way to find the gaps.