Skip to content
Audit & ReportsMarkdown

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.

  • Privilege: a user reads their own trail with no privilege. Reading anyone else’s needs READ on the realm, which RealmViewer and RealmOwner both 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 example https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya.

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 }
}
  • events are the records about the principal, and those in which it acted: see What is recorded, and every field in Record fields and examples.
  • changes is 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.

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):

Terminal window
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.

A signed-in user reads their own trail with no id to know:

Terminal window
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.

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:

Terminal window
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.

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.

AnswerWhyWhat to do
400Neither agent nor person named, or bothName exactly one
400agent isn’t an idSend the agent’s id, not its name
400 on trail/meThe session didn’t sign in a user of this realm, such as an agent’s or a client’sRead with ?person= or ?agent= and the privilege
401No session, or it has endedSign in again
403Someone else’s trail, without READ on the realmAsk for RealmViewer, or read your own trail
WhatDefaultRange
pageSize201 to 100
page1From 1
OrderNewest first by eventTimeFixed
Principals per readOne
Sites per readThe 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.

SymptomCauseFix
The trail is empty for a user you know signed inYou named the user by name, not by idRead the user and send their id
A sign-in just made isn’t thereRecords appear within momentsRead again
A user’s lockout isn’t thereLockout records follow the name typed, in lower case, not the user’s idRead ?person=maya, the name in lower case: see Look into a locked account
changes is empty for an agentA known gapRead https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/history
A refused token request isn’t on the user’s trailNo user was known yet, so it is under the client that askedRead ?person=<the client's id>
Records you expect from another site are missingEach site keeps its ownRead every site’s records

Reading a trail adds nothing to the trails you read.