Set retention policies and place legal holds
Create retention policies safely, preview them, turn them on, and freeze a person or record with a legal hold.
Developers and superusers who apply retention and legal holds through the routes.
A live policy deletes or blanks data for good. Claviger ships no policy. New ones start disabled and as a dry run, so you can see the effect first.
What you will do, in one sentence
Create the policy, preview it, enable it as a dry run, then make it live with a fresh passkey.
Screens are captured from a seeded test system. Every name, address and number on the screens is invented. Prepared 15 November 2026.
1. What a policy is
A policy names a collection, a date, a period and an action. A daily job at 02:27 server time applies the enabled policies.
| Field | Meaning |
|---|---|
collection | The collection the policy applies to. |
basis | The date the period counts from: created, updated, a date field name, or ageOut. |
after, unit | The period, in days, months or years. 0 is allowed only for a named date field. |
action | delete, anonymize or archive. |
filter | Optional filter on the collection's own fields. Encrypted fields cannot be filtered. |
How long to keep each kind of record is a decision for your lawyer. Claviger ships no policy, enabled or not.
deleteremoves the row. A guard that refuses it, such as a legal hold, counts asfailed.anonymizeblanks the personal fields of the collection's data map entry. A collection with no entry, or no personal fields, cannot have an anonymize policy enabled.archivesetsarchived = true. The collection needs a bool field with that name.ageOutcounts from the day a person'sisMinorturns false. The collection needs abirthDatefield.
2. Create, preview, enable, go live
A policy is always created disabled and as a dry run, whatever the request says. Records API writes are refused. Use the routes.
-
Create the policy:
curl -X POST https://auth.example.org/api/gdpr/retention/policies \-H "Authorization: $TOKEN" -H "Content-Type: application/json" \-d '{"collection": "pastoral_notes", "basis": "expiresAt", "after": 0, "unit": "days", "action": "archive"}' -
Preview it. Nothing changes:
curl -X POST https://auth.example.org/api/gdpr/retention/run \-H "Authorization: $TOKEN" -H "Content-Type: application/json" \-d '{"preview": true, "policy": "POLICY_ID"}' -
Enable it with
PATCH /api/gdpr/retention/policies/{id}and{"enabled": true}. The job counts it, still as a dry run. -
Make it real with
{"dryRun": false}.
A policy that ends up enabled and live needs a fresh passkey step-up. So does a change to a live policy. A delete or an anonymize is final. The job does not audit each row, because the entry would keep the deleted data.
A policy cannot be edited or deleted while a run that includes it is unfinished.
3. What a policy never touches
- Rows under an active legal hold.
- Pastoral notes with an open export hold.
- Permanent registers and their annotation collections. A policy on one is refused on save and on run.
- Accounts. Erasure handles them.
_auditLog, which has its ownaudit.retentionDays, and the policy, hold, data map and key tables.
4. Read a run
Each policy reports five counts:
| Count | Meaning |
|---|---|
matched | Past the period and matching the filter. |
held | Skipped because of a legal or pastoral hold. |
unchanged | Already in the state the action leaves. |
failed | A guard refused. The reason goes to the server log. |
affected | Deleted, anonymized or archived. For a dry run, would be. |
A run survives a restart. It stores a cursor after every batch and continues from it. One run happens at a time.
Each run writes one gdpr_retention_run audit entry with ids and counts. It is also the webhook event gdpr.retention.
5. Legal holds
A hold freezes data while a legal matter is open. It has a scope:
subject: a person. It covers every row the data map ties to them.record: one record, withcollectionandrecordId.
A hold also needs a reason. A reference, such as a case number, is optional.
curl -X POST https://auth.example.org/api/gdpr/holds \
-H "Authorization: $TOKEN" -H "Content-Type: application/json" \
-d '{"scope": "subject", "subject": "USER_ID", "reason": "Open matter", "reference": "CASE-001"}'
Placing and lifting need a fresh passkey. The routes are:
GET /api/gdpr/holds[?active=1]
GET /api/gdpr/holds/{id}
POST /api/gdpr/holds
POST /api/gdpr/holds/{id}/lift
While a hold is active, the job skips the rows. Nothing can delete a held record: the records API, a cascade, a hook and the job all get 409. A lifted hold stays as evidence. There is no delete.
The audit entries gdpr_hold and gdpr_hold_lift never carry the reason or the reference.
The export shows the scope, reason, reference and dates of a person's holds. It leaves out who placed and lifted them. The owner decided this on 2026-11-14. Whether you may tell the person about a given hold is a legal question. Raise it with your lawyer before the export runs.
6. Quick reference card
Make a policy live
POST /api/gdpr/retention/policies.POST /api/gdpr/retention/runwithpreview: true.PATCHwithenabled: true.PATCHwithdryRun: false, with a fresh passkey.
Hold a person
POST /api/gdpr/holdswith a fresh passkey.- Lift it with
POST /api/gdpr/holds/{id}/lift.
The admin UI has retention and hold screens. See the erasure guide.