Read a user's or agent's trail
Every sign-in, token, exchange and decision that involved one user or one agent, newest first, read in one call, by the user themselves or by anyone holding read access to the realm.
Available, with limitsAPI
You read the trail one principal at a time, so two questions have a direct answer: what did this agent do? and what was done in this user’s name? One call returns everything that involved them, newest first, a page at a time. Users can read their own trail; anyone else needs read access to the realm.
This is limited today: an agent’s trail comes back without the changes to its record (read those from its change history), and on a realm served from more than one site, each read shows one site’s records.
Before you begin
Section titled “Before you begin”- Privilege: a user reads their own trail with no privilege. Reading anyone else’s needs
READon the realm, whichRealmViewerandRealmOwnerboth give. To let an auditor read without letting them change anything, see Give an auditor read-only access. - Where: the API.
- What you need first: the principal’s
id, the id the realm gave it when it was made, not the name you address it by. Read it from the object, for examplehttps://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya.
How it works
Section titled “How it works”Name exactly one principal by its id: person for a user, agent for an agent. The answer has two parts:
{ "principal": "<agent's id>", "kind": "agent", "events": { "data": [ … ], "page": 1, "pageSize": 100, "totalCount": 214, "totalPages": 3 }, "changes": { "data": [], "page": 1, "pageSize": 100, "totalCount": 0, "totalPages": 0 }}eventsare the records about the principal, and those in which it acted: see What is recorded, and every field in Record fields and examples.changesis meant for the changes made to an agent’s own record, such as a quarantine. It comes back empty today, for users and agents alike; read an object’s changes in its Change history.
Records are newest first by eventTime. A record appears within moments of
the work it records, so a read made just after a sign-in may not show it yet; read again.
Set it up
Section titled “Set it up”There’s nothing to set up. Read the agent invoice-agent’s trail, 100 records to a page
(Call the API shows how to get $CVYUH_SESSION):
curl "https://foobar.cvyuh.com/api/v0/am/audit/v1/trail?agent=<invoice-agent's id>&page=1&pageSize=100" \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"For a user, send person=<user's id> in place of agent.
Your own trail
Section titled “Your own trail”A signed-in user reads their own trail with no id to know:
curl https://foobar.cvyuh.com/api/v0/am/audit/v1/trail/me \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"It answers as ?person= with their own id does: what they did, and what apps and agents did in their name.
Give an auditor read-only access
Section titled “Give an auditor read-only access”Put the auditors in a group, then grant the group RealmViewer, which reads every record and setting in the realm,
and the realms beneath it, and changes nothing. Here the group is auditors:
curl https://foobar.cvyuh.com/api/v0/am/privilege/v1 \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \ -H "Content-Type: application/json" \ -d '{ "group": "auditors", "privilege": "RealmViewer" }'Granting needs DELEGATE on the realm, which RealmOwner holds. Always send privilege: left out, the grant is
RealmOwner. See Delegated administration.
Read every site’s records
Section titled “Read every site’s records”On a realm served from more than one site, each site keeps the records of the work it did, and a read answers from the
site that serves it. To read what each site recorded, make the same call on the host name that reaches each site (see
Host names), and merge the answers by eventTime. A host name shared by every site
answers from whichever site serves you.
What happens when it fails
Section titled “What happens when it fails”| Answer | Why | What to do |
|---|---|---|
400 | Neither agent nor person named, or both | Name exactly one |
400 | agent isn’t an id | Send the agent’s id, not its name |
400 on trail/me | The session didn’t sign in a user of this realm, such as an agent’s or a client’s | Read with ?person= or ?agent= and the privilege |
401 | No session, or it has ended | Sign in again |
403 | Someone else’s trail, without READ on the realm | Ask for RealmViewer, or read your own trail |
Limits and defaults
Section titled “Limits and defaults”| What | Default | Range |
|---|---|---|
pageSize | 20 | 1 to 100 |
page | 1 | From 1 |
| Order | Newest first by eventTime | Fixed |
| Principals per read | One | |
| Sites per read | The site that serves the call |
events and changes are paged separately, each with its own totalCount and totalPages. A realm set to cursor
paging answers nextCursor and hasMore instead; send cursor back for the next page.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| The trail is empty for a user you know signed in | You named the user by name, not by id | Read the user and send their id |
| A sign-in just made isn’t there | Records appear within moments | Read again |
| A user’s lockout isn’t there | 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 |
changes is empty for an agent | A known gap | Read https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/history |
| A refused token request isn’t on the user’s trail | No user was known yet, so it is under the client that asked | Read ?person=<the client's id> |
| Records you expect from another site are missing | Each site keeps its own | Read every site’s records |
Audit record
Section titled “Audit record”Reading a trail adds nothing to the trails you read.
Related
Section titled “Related”- Get started with Audit & Reports: one user’s and one agent’s trail, step by step.
- Follow what an agent did: the task, start to finish.
- Look into a locked account: a user’s failed sign-ins.