# Audit trail

> The realm's own record of every sign-in, token, exchange, decision and change, read per user, per agent or per object, kept for the life of the realm, and never edited.

The audit trail is the realm's own record of what it did. It is written as the realm works, with nothing to turn on,
kept for as long as the realm exists, and never edited after it is written. Every record carries the ids that tie it
to the request, the sign-in and the token it belongs to, so the records of one piece of work can be found together.

| Capability | What it gives you |
|---|---|
| [What is recorded](/audit-reports/audit-trail/what-is-recorded/) | Sign-ins, lockouts, tokens, exchanges, policy decisions, revocations and changes |
| [Record fields and examples](/audit-reports/audit-trail/record-fields/) | Every field of a record, full examples, and the ids that tie records together |
| [Read a user's or agent's trail](/audit-reports/audit-trail/read-a-trail/) | Everything about one principal, newest first, paged (with limits) |
| [Your own trail](/audit-reports/audit-trail/read-a-trail/#your-own-trail) | A signed-in user reads what they did and what was done in their name |
| [Change history](/audit-reports/audit-trail/change-history/) | Every change to one user, group, agent or setting, newest first, secrets left out (with limits) |
| [Policy decisions on the trail](/audit-reports/audit-trail/what-is-recorded/#policy-decisions) | Every deny and every decision involving an agent, or every decision if you choose |
| [Retention and sites](/audit-reports/audit-trail/retention/) | Kept for the life of the realm; each site keeps its own records (with limits) |

## Before you begin

- **Privilege:** a user reads their own trail with no privilege. Reading anyone else's trail, or an object's change
  history, needs `READ` on the realm: the `RealmViewer` privilege gives it with no right to change anything, and
  `RealmOwner` includes it. See [Give an auditor read-only access](/audit-reports/audit-trail/read-a-trail/#give-an-auditor-read-only-access).
- **Where:** the API.

## How it works

You read the trail from one of two ends:

| To answer | Read | Under `https://foobar.cvyuh.com/api/v0/am` |
|---|---|---|
| What did this user or agent do, and what was done in their name? | the principal's trail | `/audit/v1/trail?person=…` or `?agent=…` |
| Who changed this user, group, agent or setting, and how? | the object's history | `/objects/v1/<type>/<id>/history` |

For example, a signed-in user reads their own trail ([Call the API](/develop/api/) shows how to get
`$CVYUH_SESSION`):

```sh
curl https://foobar.cvyuh.com/api/v0/am/audit/v1/trail/me \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

## Limits and defaults

| What | Default | Range or note |
|---|---|---|
| How long records are kept | For the life of the realm | Not configurable today |
| Records in a trail page | 20 | 1 to 100 |
| Entries in a change-history page | 50 | 1 to 500 |
| Policy decisions kept (`auditDecisions`) | `agents` | `agents` or `all` |
| When a record appears | Within moments of the work it records | Not a fixed bound |

## Good to know

- **Records can't be changed.** No call edits or deletes a record, a realm administrator's included. A record stays
  as it was written for the life of the realm.
- **Secrets never reach the trail.** Records of a change leave out every secret field, a key change records who made
  it and never the key, and session cookies and tokens are never recorded: a session is named by a handle that can't
  be used to sign in.
- **Recording never slows a request.** A record appears on the trail within moments of the work it records. In rare
  failures, a record can be missing even though the request completed.
- **Reading the trail adds nothing to it.** Your reads don't show up on the trails you read.

## Coming next

The gateway's own decisions on the trail, a search across every record of the realm, realm-wide reports, streaming to
your SIEM, a retention period you choose and a tamper-evident trail: see
[What's next for audit and reports](/audit-reports/audit-trail/whats-next/).

## Related

- [Get started with Audit & Reports](/audit-reports/get-started/): one user's and one agent's trail, step by step.
- [Follow what an agent did](/workforce-identity/guides/agents/follow-what-an-agent-did/): the task, start to finish.
- [Delegated administration](/platform/realms/delegated-administration/): who holds `READ` on the realm.
