# Retention

Personal data needs an end date: GDPR's storage limitation means you keep
it only as long as you need it. A `retention:` block gives one, in the
same `after:` and `since:` shape as a lifecycle's `purge:`
([Lifecycle](lifecycle.md)).

## On a field

The value is cleared when the time is up, so the field must be nullable.
Use it for a value you need only for a while, such as an IP address kept
for 30 days for fraud checks:

```jadpo
entity User {
    ...
    signup_ip: IpAddress? {
        personal: PersonalData.online
        retention: {
            after: config.signup_ip_retention
            since: created_at
        }
    }
}
```

## On an entity

The record is deleted, with whatever cascades from it. Use it for
invoices, as in [Erasure](erasure.md#keeping-a-record-without-the-person-erasureretained),
or for accounts inactive for two years.

## Where the periods come from

The periods are settings in `config.jadpo`
([Settings](settings-config-jadpo.md)), so they
are set per environment and appear in the report. The compiler's built-in
[purge schedule](schedules.md#the-purge-schedule) applies
retention too, in small batches, each logged.

A person entity, or an entity holding marked fields, with no retention
and no purge is listed in the report as "kept until erased".
