# What is recorded

> Every sign-in step, lockout, token, exchange, policy decision, revocation and change the realm writes to its audit trail, when it writes each, and which policy decisions it keeps.

The realm writes a record of everything it does for or about a user or an agent: every sign-in and sign-out, every
token issued or refused, every exchange, the policy decisions that matter, every right a user takes back, and every
change to the realm's objects. Nothing needs turning on; this page is what you will find.

## Before you begin

- **Privilege:** none to read what is recorded about you. `READ` on the realm (`RealmViewer` or `RealmOwner`) to read
  anyone else's records. Changing which policy decisions are kept needs `MODIFY` on the realm (`RealmOwner`).
- **Where:** the API.

## How it works

| Record | Event | When |
|---|---|---|
| A sign-in | `LOGIN_STARTED`, `LOGIN_CONTINUED`, `MODULE_COMPLETED`, `LOGIN`, `LOGIN_FAILED`, `LOGIN_ABANDONED` | Each step of a sign-in, with how each step went, and the outcome |
| A session change | `SESSION_UPGRADED`, `LOGOUT`, `LOGOUT_ALL`, `SESSIONS_REAPED` | A step-up, a sign-out, signing out everywhere, expired sessions cleared |
| A lockout | `AUTH_FAILURE_RECORDED`, `ACCOUNT_LOCKED`, `LOCKOUT_CLEARED` | Each failure counted toward a lockout, the lockout, and its end. Recorded under the name typed, not the user's id |
| A token | `TOKEN_ISSUED` | Every token request, issued or refused: what was asked, what was granted, the key it is bound to, or why it was refused |
| An exchange | `TOKEN_EXCHANGED` | Every [token exchange](/workforce-identity/applications/tokens/token-exchange/), allowed or refused, with the chain of agents |
| A policy decision | `POLICY_DECIDED` | Every deny, and every decision involving an agent. A user's own allows only if you ask for them |
| A token revoked | `TOKEN_REVOKED` | Every [revocation](/workforce-identity/applications/revoke-access/revocation/): an access token, a refresh family or a deferral code |
| An app or agent taken back | `APP_TAKEN_BACK`, `AGENT_TAKEN_BACK` | A user taking back an app they allowed, or an agent's right to act for them |
| An agent's status | `AGENT_QUARANTINED`, `AGENT_RELEASED`, `AGENT_KILLED`, `AGENT_RETIRED` | An agent quarantined, released, killed or retired, with the status before and after, and whether an administrator or a received signal made it. On the trail of whoever made it and of the agent's owner |
| A client's secret | `CLIENT_SECRET_ROTATED`, `CLIENT_SECRET_PREVIOUS_USED` | A rotation, and each use of the replaced secret while it still works |
| A registration | `CLIENT_REGISTERED`, `REGISTRATION_TOKEN_MINTED`, `REGISTRATION_TOKEN_REVOKED` | A client registered, and registration tokens minted or revoked |
| A change | `CREATED`, `UPDATED`, `PATCHED`, `DELETED` | Every change to a user, group, agent, client or setting, with what changed, before and after. Read it in [Change history](/audit-reports/audit-trail/change-history/) |

Each record carries what happened (`eventType`), when (`eventTime`), how it went (`result`), who it is about and who
acted, its own detail in `context`, and the ids that tie it to the rest of its work. A sign-in's record also lists each
step in `entries`, with a stable code for a failure rather than a message. Every field, with full examples, is in
[Record fields and examples](/audit-reports/audit-trail/record-fields/).

### Policy decisions

The realm's `authorizationSettings.auditDecisions` chooses which decisions are kept:

| Value | Kept |
|---|---|
| `agents` (the default) | every deny, and every decision an agent is in, asking or acting for someone, so an agent's trail is whole |
| `all` | a user's own allows too: one record per request |

## Set it up

There's nothing to turn on. To keep every decision, a realm administrator sets `auditDecisions` to `all`
([Call the API](/develop/api/) shows how to get `$CVYUH_SESSION`):

```sh
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/authorizationSettings/authorizationSettings \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -d '{ "auditDecisions": "all" }'
```

The realm answers with the settings as they now are. A value other than `agents` or `all` is refused with `400`, and
a caller without `MODIFY` on the realm with `403`.

## Limits and defaults

| What | Default | Range |
|---|---|---|
| `auditDecisions` | `agents` | `agents` or `all` |
| Records per policy decision | One, when kept | |
| What is never recorded | | Passwords, secrets, session cookies, tokens and keys |

## Audit record

Changing `auditDecisions` is itself recorded: a `PATCHED` entry in the
[change history](/audit-reports/audit-trail/change-history/) of `authorizationSettings/authorizationSettings`, with who
made it and the value before and after.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| A user's allowed requests aren't on their trail | `auditDecisions` is `agents`, which keeps only denies and agents' decisions | Set it to `all` for as long as you need them |
| No lockout records on a locked user's trail | Lockout records follow the name typed, in lower case, not the user's id | Read `?person=maya`, the name in lower case: see [Look into a locked account](/audit-reports/guides/look-into-a-locked-account/) |
| The gateway's denies aren't on the trail | The gateway logs its own decisions where it runs | Read the gateway's log; only decisions it asks of the realm are on the trail |

## Good to know

- **A user's records follow their id, lockout records excepted.** Sign-ins, failed sign-ins and tokens for a user are
  under their id, so a renamed user keeps their trail. Lockout records follow the name signed in with, in lower case
  (read them with `?person=maya`). A refused
  token request is recorded under the client that asked, since no user is known yet.
- **Secrets never reach the trail.** Records of a change leave out every secret field, and a key change records who
  made it, never the key. Session cookies and tokens are never recorded; a session is named by a handle that can't be
  used to sign in.
- **Signing-key changes aren't about a principal,** so they aren't in a trail answer; no API returns them
  yet. See [Signing keys](/platform/keys/signing-keys/#audit-record).
- **Secrets Store records every request and change too,** reads included, values left out. Its records can't be read
  back through the API yet. See [Secrets audit trail](/secrets-store/keys-and-protection/audit-trail/).
- **The gateway's own decisions aren't on the realm's trail yet.** See
  [What's next for audit and reports](/audit-reports/audit-trail/whats-next/#gateway-decisions-on-the-trail).

## Related

- [Record fields and examples](/audit-reports/audit-trail/record-fields/): every field, and full records.
- [Read a user's or agent's trail](/audit-reports/audit-trail/read-a-trail/): how to read these records.
- [Record every policy decision](/audit-reports/guides/record-every-policy-decision/): the task, start to finish.
