Audit logs
ulex's immutable, hash-chained audit log: 48 actions across 8 categories, pseudonymous actors, queryable facets, chain verification, NDJSON and CSV export, and retention.
Required scope: read:audit_logs. This is the surface an agent should read before and after any mutation, and the evidence it should quote in its report.
The audit log is append-only and hash-chained. Entries cannot be updated or deleted through any API, by any scope, including ulex:admin. Chain verification is a supported, documented operation, not a claim.
#Object
{
"id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
"object": "audit_event",
"environment": "prod",
"action": "authentication.succeeded",
"category": "authentication",
"actor_id": null,
"actor_hash": "sha256:3b1f0c9a7d2e4f6a8b0c2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a",
"actor_type": "user",
"actor_display": "Dana Okafor",
"target": { "type": "application", "id": "app_01M3PSV7J8TBSPHG95CYSEX32B", "display_name": "Acme Support" },
"organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
"connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
"request_id": "req_01M3PSW9R0175NAW62NYR403R8",
"correlation_id": "onboard-acme-2026-09-29",
"session_id": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
"ip_hash": "sha256:9c2e4a6b8d0f2a4c6e8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a0c2e4b6d8f0a2c",
"user_agent": "ulex-mcp/2025.9.1",
"metadata": { "amr": ["pwd", "otp", "mfa"], "acr": "urn:ulex:acr:mfa" },
"outcome": "success",
"error_code": null,
"timestamp": 1790693112,
"previous_hash": "sha256:…",
"entry_hash": "sha256:…",
"hash_version": 2
}| Field | Notes |
|---|---|
action | closed enum, 48 values, append-only |
category | authentication, authorization, configuration, data_access, data_modification, provisioning, security, system — mapped to SOC 2 control families |
actor_id | the ulex id of the actor, null for system |
actor_hash | sha256:<hex> of the acting user's email. PHI minimisation: the email itself is never written to the audit log |
actor_type | user, api_key, system, service, agent |
actor_display | a display name, not an email. Used for humans reading an export |
target | { type, id, display_name } — what was acted on |
ip_hash | sha256:<hex> of the client IP, salted per tenant. Never the raw address |
timestamp | milliseconds since epoch, integer, primary sort key |
outcome | success, failure, denied |
error_code | a ulex error code when outcome is not success |
metadata | free-form diff. Never contains secrets or raw PHI; values are scrubbed on write |
previous_hash / entry_hash | the chain link, flat on the event. previous_hash is null on a chain's first entry |
hash_version | which formula produced entry_hash. Version 1 could not be recomputed from storage and verifies as unverifiable |
actor_type: "agent" is set automatically when the credential is a bearer token presented by an MCP client. Your agent's actions are distinguishable from a human's and from a service's, which is what makes "auditing an agent's own actions" a query rather than an archaeology project.
#Actions
Forty-eight values, grouped by category.
#authentication
| Action | Fired by |
|---|---|
authentication.succeeded | a completed login |
authentication.failed | a rejected login |
authentication.challenge | an MFA or step-up challenge was raised |
authentication.mfa_challenge | an MFA prompt was presented |
authentication.mfa_failed | a wrong or missing MFA code |
authentication.saml_failed | a SAML assertion was rejected |
authentication.api_key_failed | a bad key was presented |
authentication.session_created | a session was created |
authentication.session_expired | a session passed idle_expires_at or expires_at |
authentication.session_revoked | logout, suspension, deprovision, or rotation |
sso.session_created | a session created through cross-app SSO |
#authorization
| Action | Fired by |
|---|---|
impersonation.started | impersonation_only login |
impersonation.ended | that session ended |
mcp.tool_denied | an MCP call rejected for scope or policy |
#configuration
| Action | Fired by |
|---|---|
application.created / .updated / .deleted / .secret_rotated | |
connection.created / .updated / .activated / .deactivated / .deleted | |
organization.created / .updated / .deleted | |
webhook.created / .updated / .deleted / .enabled / .disabled | |
api_key.created / .revoked | |
domain.created / .verified / .deleted |
#provisioning
| Action | Fired by |
|---|---|
user.created / .updated / .deleted | |
user.suspended / .unsuspended | |
user.email_verified / .password_reset | |
directory.sync_started / .sync_completed / .sync_failed |
#security and system
| Action | Fired by |
|---|---|
mcp.tool_invoked | an MCP tool call, per the sampling policy |
webhook.delivery_failed | |
webhook.delivered | |
deployment.started / .succeeded / .failed / .cancelled |
#Query
curl -sS -G "$BASE/audit-events" \
-H "Authorization: Bearer $ULEX_API_KEY" \
--data-urlencode 'action=authentication.succeeded' \
--data-urlencode 'organization_id=org_01M3PSV8HGTKQFCAYF9GDWGN3C' \
--data-urlencode 'since=2026-09-29T00:00:00.000Z' \
--data-urlencode 'until=2026-09-30T00:00:00.000Z' \
--data-urlencode 'limit=50' \
--data-urlencode 'order=desc'{
"object": "list",
"data": [
{
"id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
"object": "audit_event",
"action": "authentication.succeeded",
"category": "authentication",
"actor_id": null,
"actor_hash": "sha256:3b1f0c9a7d2e4f6a8b0c2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a",
"actor_type": "user",
"actor_display": "Dana Okafor",
"target": { "type": "application", "id": "app_01M3PSV7J8TBSPHG95CYSEX32B", "display_name": "Acme Support" },
"organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
"request_id": "req_01M3PSW9R0175NAW62NYR403R8",
"outcome": "success",
"timestamp": 1790693112
}
],
"first_id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
"last_id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
"has_more": false,
"next_cursor": null,
"chain_head": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b"
}#Filters
| Filter | Type | Notes |
|---|---|---|
action | exact | |
action_prefix | prefix | authentication. gets you all eleven authentication actions in one call. This is the one to reach for |
category | enum | |
actor_id | exact | |
actor_type | enum | agent to see only what agents did |
actor_hash | exact | you cannot enumerate these; they come from your own HMAC input |
target_id | exact | |
organization_id | exact | |
connection_id | exact | |
session_id | exact | |
request_id | exact | the one you sent as X-Ulex-Request-Id |
correlation_id | exact | the one you sent as X-Ulex-Correlation-Id |
outcome | enum | success, failure, denied |
error_code | exact | join against the error catalogue |
since / until | ISO-8601 | since is inclusive, until is exclusive |
limit | 1–200 | default 20 |
order | asc / desc | default asc |
starting_after | id | cursor |
All filters are AND-combined. There is no free-text search and no OR. For OR, run two queries and merge on id, or use action_prefix and filter client-side.
#Read one
curl -sS "$BASE/audit-events/aud_01M3PSVN7R3H0ECRPQVTDF1PY9" -H "Authorization: Bearer $ULEX_API_KEY"{
"audit_event": {
"id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
"action": "authentication.succeeded",
"outcome": "success",
"timestamp": 1790693112,
"previous_hash": "sha256:9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4f6a8",
"entry_hash": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
"hash_version": 2
}
}The link is flat on the event — previous_hash, entry_hash, hash_version, not a nested chain object. hash_version says which formula produced entry_hash; version 1 could not be recomputed from storage and so verifies as unverifiable.
#Chain verification
There is no sequence field, and that is deliberate. A sequence number cannot order two entries written in the same millisecond, and ordering by one produces a chain that looks broken when it is intact. Order the rows by following the links, which is what makes this work regardless of what order the rows arrive in:
export function verifyChain(events: AuditEvent[]): { valid: boolean; brokenAt: string | null } {
const byHash = new Map(events.map((e) => [e.entry_hash, e]));
// The tip is the entry nothing links to. Exactly one, in an intact chain.
const linkedTo = new Set(events.map((e) => e.previous_hash).filter(Boolean));
const tips = events.filter((e) => !linkedTo.has(e.entry_hash));
// Walk back from each tip. A window that starts mid-chain simply stops at its
// oldest entry, which is not a failure — report that separately, as the
// endpoint's `windowStartsMidChain` does.
const reachable = new Set<string>();
for (const tip of tips) {
let cursor: AuditEvent | undefined = tip;
while (cursor && !reachable.has(cursor.entry_hash)) {
reachable.add(cursor.entry_hash);
cursor = cursor.previous_hash ? byHash.get(cursor.previous_hash) : undefined;
}
}
const orphan = events.find((e) => !reachable.has(e.entry_hash));
return { valid: !orphan, brokenAt: orphan?.id ?? null };
}Once the order comes from the links, "does this entry link to the one before it" is true by construction — checking it verifies nothing. The check that still carries information is monotonicity: the chain's order must agree with the clock, so no entry may be dated before the one it links from. The snippet above omits it; the endpoint does not.
entry_hash is a canonical-JSON hash of the entry's contents and its previous_hash, keyed by hash_version. A single altered or removed entry breaks every link after it, which is the tamper evidence SOC 2 CC7.2 and HIPAA 164.312(b) ask for.
#Verifying the chain
curl -sS -X POST "$BASE/audit-events/verify_chain" \
-H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
-d '{"from":"2026-01-01T00:00:00.000Z","to":"2026-06-30T23:59:59.000Z"}'The body takes from and to, and nothing else. Both are optional and default to the last 24 hours; the object is strict, so an unknown key is a 400 rather than a silently narrower window. Omit the body entirely for the default.
The fields are named from and to, not since and until. An earlier version of this page documented since/until, and the endpoint ignored them — a caller asking to verify twelve months silently received the default twenty-four hours and a valid: true that meant nothing about the other eleven months. The strict body is what stops that from reaching you quietly; check your own scripts against the field names above.
{
"valid": true,
"checked": 8471,
"failure": null,
"windowStartsMidChain": false,
"head": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
"summary": "Chain intact: 8471 event(s) verified from 2026-01-01T00:00:00.000Z to 2026-06-30T23:59:59.000Z. Every entry hashes to the value it had when written, and each links to its predecessor.",
"window": { "from": "2026-01-01T00:00:00.000Z", "to": "2026-06-30T23:59:59.000Z" }
}A break — the endpoint answers 409, and guidance says what it is worth:
{
"valid": false,
"checked": 4102,
"failure": {
"kind": "hash_mismatch",
"at": "aud_01M3PSW3WGDDFJFJHZ4QJNNFZD",
"detail": "The entry's contents do not hash to the hash recorded on it. The row was altered after it was written.",
"found_previous": "sha256:…",
"expected_previous": "sha256:…"
},
"windowStartsMidChain": false,
"head": "sha256:…",
"guidance": { "severity": "security", "what": "…", "do": "…", "not": "…" },
"summary": "Chain verification FAILED (hash_mismatch) at event aud_01M3PSW3WGDDFJFJHZ4QJNNFZD, after verifying 4102 event(s) …",
"window": { "from": "…", "to": "…" }
}failure.kind | guidance.severity | Meaning |
|---|---|---|
hash_mismatch | security | the entry's contents no longer hash to its recorded entry_hash. Somebody altered it |
missing_predecessor | operational | an entry is on no branch of the chain — it links at a hash nothing produced, or nothing links to it. An ulex write was lost |
broken_link | operational | an entry sits somewhere other than where the links put it, or the chain runs backwards against the clock. Both are ulex-side: two appenders racing, or a clock behind |
unverifiable | operational | the entry's hash was written by a formula that cannot be recomputed from storage |
hash_mismatch is the only kind that is evidence the log was altered. The other three are ulex writing the log wrong, which is a support case rather than an incident — and guidance.severity is provided precisely so nobody has to guess.
Two things about the shape that are easy to get wrong:
windowStartsMidChainis part of the result, not a failure. A window that began part-way through the chain leaves its first entry's link unchecked, sovalid: truemeans nothing inside this window is wrong, not this window is a whole chain. Widen it before telling an auditor the log verified.- The order comes from the links, not from the store's sort key. Entries sharing a timestamp — normal under concurrency — verify correctly. An earlier implementation trusted the storage layer's ordering and reported intact chains as
missing_predecessor.
The router resolves this literal path above /audit-events/{id}, so the audit event id verify_chain is unreachable by design. Anyone can also verify the chain independently from an NDJSON export, which is the point — see Runbook 12.
#Export
curl -sS -G "$BASE/audit-events/export" \
-H "Authorization: Bearer $ULEX_API_KEY" \
--data-urlencode 'format=ndjson' \
--data-urlencode 'since=2026-09-01T00:00:00.000Z' \
--data-urlencode 'until=2026-10-01T00:00:00.000Z' \
--data-urlencode 'category=authentication' \
-o audit-2026-09.ndjson{"id":"aud_01M3PSVN7R3H0ECRPQVTDF1PY9","action":"authentication.succeeded","category":"authentication","actor_id":null,"actor_hash":"sha256:3b1f0c9a…","actor_type":"user","target":{"type":"application","id":"app_01M3PSV7J8TBSPHG95CYSEX32B","display_name":"Acme Support"},"organization_id":"org_01M3PSV8HGTKQFCAYF9GDWGN3C","request_id":"req_01M3PSW9R0175NAW62NYR403R8","outcome":"success","timestamp":1790693112,"previous_hash":"sha256:9f3c1a7b…","entry_hash":"sha256:7d9f1b3a…","hash_version":2}
{"id":"aud_01M3PSW3WGDDFJFJHZ4QJNNFZD","action":"user.created","category":"provisioning","actor_id":null,"actor_hash":"sha256:3b1f0c9a…","actor_type":"agent","target":{"type":"user","id":"usr_01M3PSWBPGS08FWV4NV7P9VNFN","display_name":"Pat Iyer"},"organization_id":"org_01M3PSV8HGTKQFCAYF9GDWGN3C","request_id":"req_01M3PSW9R0175NAW62NYR403R8","outcome":"success","timestamp":1790693121,"previous_hash":"sha256:7d9f1b3a…","entry_hash":"sha256:b2e4d6f8a…","hash_version":2}format | Content type | Notes |
|---|---|---|
ndjson | application/x-ndjson | one event per line; the right format for a chain verifier |
csv | text/csv | flattened, previous_attributes and metadata JSON-encoded into one cell |
json | application/json | a single ListResponse-shaped object; capped at 10,000 events |
?download=true sets Content-Disposition: attachment. Exports above 100,000 events are rejected with 413; narrow the window.
The same export is available in the hosted console as a signed CSV download for SOC 2 evidence, and to compliance auditors under NDA.
#Retention
| Data | Default | Minimum | Notes |
|---|---|---|---|
| Audit events | 2,555 days (7 years) | 365 | required by the SOC 2 and HIPAA retention posture |
| Webhook deliveries | 30 days | 1 | |
| Sessions | 30 days after expiry | 1 | |
| Inactive applications | 730 days | 1 | then soft-deleted |
| Soft-deleted resources | 30 days | — | then hard-deleted, audit events retained |
Overrides live on tenant.retention. audit_log_days cannot be lowered below 365 and cannot be set to null.
#Privacy
What is not in the audit log, by construction:
- plaintext email addresses — only
sha256:<hex>of the normalised email, salted per tenant - IP addresses — only
sha256:<hex>, salted per tenant - passwords, secrets, tokens, API keys — scrubbed on write, before the row is written
- SAML assertions, JWTs, cookies — never
- PHI in
metadata— scrubbed against a pattern list; do not put it there
Full detail: HIPAA PHI handling.
#MCP equivalents
ulex_search_audit_logs, ulex_get_audit_event. Recipe: Auditing your own actions.
Deeper: Observability, SOC 2, Incident response.