# Retention and sites

> The audit trail is kept for the life of the realm, never edited, outlives what it names and the realm's deletion, and is kept by each site that serves the realm.

The realm keeps its audit trail for as long as the realm exists, and no record is ever edited or deleted. A record
written today is there to read years from now, so an investigation never finds its evidence aged out.

This is **limited** today: on a realm served from more than one site, each site keeps its own records and you read
them site by site. Choosing a retention period of your own is planned.

## Before you begin

- **Privilege:** none to keep the trail; reading it is as in
  [Read a user's or agent's trail](/audit-reports/audit-trail/read-a-trail/).
- **Where:** nothing to set, in the API or anywhere else.

## How it works

| When | The trail |
|---|---|
| Every day | Kept whole; nothing expires a record |
| A user, group or agent is deleted | Their records stay |
| The realm is deleted | Its trail stays |

On a realm served from more than one site, each site records what it did and keeps its own records. A trail read at
one site shows what that site recorded. To read every site's records, make the same read on the host name that
reaches each site, and merge the answers by `eventTime`: see
[Read every site's records](/audit-reports/audit-trail/read-a-trail/#read-every-sites-records) and
[Multi-site realms](/platform/sites/multi-site-realms/).

## Set it up

There's nothing to set up. Read a user's trail at the site that serves you
([Call the API](/develop/api/) shows how to get `$CVYUH_SESSION`):

```sh
curl "https://foobar.cvyuh.com/api/v0/am/audit/v1/trail?person=<maya's id>" \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

## Limits and defaults

| What | Default | Range |
|---|---|---|
| How long a record is kept | For the life of the realm | Not configurable today |
| Editing or deleting a record | Never | No call does it, a realm administrator's included |
| Where a record is kept | The site that wrote it | Every site keeps its own |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| Records from a sign-in at another site are missing | Each site keeps its own records | Read the trail on that site's host name |
| A deleted user's or group's history comes back empty | A deleted object's history can't be read at its address | Its sign-ins and tokens stay on the trail by its id; read `?person=<their id>` if you kept it |

## Good to know

- **Records can't be changed.** No call edits or deletes a record, a realm administrator's included.
- **When a realm is deleted for good,** its trail is kept unless you ask for it to be removed. See
  [Retention and clean-up](/platform/data/retention/).
- **The trail grows with the realm.** Setting `auditDecisions` to `all` adds a record per request; see
  [What is recorded](/audit-reports/audit-trail/what-is-recorded/#policy-decisions).
- **Records aren't signed yet.** A tamper-evident trail is planned: see
  [What's next for audit and reports](/audit-reports/audit-trail/whats-next/#a-tamper-evident-trail).

## Coming next

A retention period you set for your realm, and a copy of the trail kept in your own storage: see
[What's next for audit and reports](/audit-reports/audit-trail/whats-next/#set-how-long-the-trail-is-kept).

## Related

- [Retention and clean-up](/platform/data/retention/): what the realm keeps, and for how long.
- [Read a user's or agent's trail](/audit-reports/audit-trail/read-a-trail/): reading what is kept.
