# Record every policy decision

> Keep every policy decision on the audit trail, a user's own allowed requests included, and go back to the default when you're done.

By default the trail keeps every deny and every decision an agent is in, so an agent's trail is whole. During an
investigation or an audit period you may want each user's allowed requests too, to show exactly what a user reached.

**Before you start:** you hold `MODIFY` on the realm, as a realm administrator with `RealmOwner` does, and are signed
in with your session in `$CVYUH_SESSION` ([Call the API](/develop/api/) shows how).

## Keep every decision

<Steps>

1. Set the realm's `auditDecisions` to `all`:

   ```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" }'
   ```

2. Read a user's trail as requests come in:

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

</Steps>

<Aside type="caution" title="It grows fast">
  `all` writes one record per request a policy decides. Keep it on for as long as you need it.
</Aside>

## Check it worked

The user's trail now holds `POLICY_DECIDED` records with `"result": "SUCCESSFUL"` for their own allowed requests, not
only denies.

## Undo it

Set `auditDecisions` back to `agents`:

```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": "agents" }'
```

The records already written stay on the trail.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| `403` on the `PATCH` | You don't hold `MODIFY` on the realm | Ask a holder of `RealmOwner` |
| `400` on the `PATCH` | A value other than `agents` or `all` | Send one of the two |
| No allowed `POLICY_DECIDED` records yet | No request a policy decides has come in since | Wait for one, then read again |

Each change of the setting is itself recorded, with who made it and the value before and after, in the
[change history](/audit-reports/audit-trail/change-history/) of `authorizationSettings/authorizationSettings`.

## Related

- [What is recorded](/audit-reports/audit-trail/what-is-recorded/#policy-decisions): which decisions each setting
  keeps.
- [Policies](/workforce-identity/authorization/policies/): the decisions themselves.
