Most organisations have logs. Few have evidence. Application logs are written for debugging: they rotate, they sample, they drop fields to save space, and they are readable by anyone with production access. A consent dispute needs the opposite: a complete, ordered, attributable record that survives a staff change and a storage migration.
The audit ledger is that record. It is not a feature of the consent service; it is a separate system with its own storage, its own access rules and its own verification.
What the ledger is for
Three questions justify the cost of building it properly.
- The dispute. A person says they withdrew and processing continued. The ledger shows the withdrawal, the effective time, the cascade to each processor and each acknowledgement.
- The audit. A reviewer samples ten consent journeys and asks for the notice, the choice, the validation call and the evidence that withdrawal reached downstream systems.
- The incident. A change was made without approval. The ledger shows who did it, from where, under which role, and what else happened in the same window.
If the ledger cannot answer those three questions, it is a log with a serious-sounding name.
The nine mandatory dimensions
Every consent action writes one entry with all nine fields. A missing field makes the entry unusable in at least one of the three scenarios above.
| Dimension | What it records | Why it is needed |
|---|---|---|
| Log ID | A unique, immutable entry identifier | Ordering, lookup and cross-reference from other systems |
| User ID | The Data Principal the action concerns | Reconstruct one person's history without ambiguity |
| Purpose ID | The purpose the action applies to | Prove scope, and show that one purpose did not leak into another |
| Action Type | Grant, update, renew, validate, withdraw, notify | Explain what happened without reading free text |
| Timestamp | The precise time, in a single time zone | Establish sequence, deadlines and the effective moment |
| Consent Status | The resulting status | Show the state after the action, including terminal states |
| Initiator | Principal, fiduciary, system or administrator | Attribute the action and separate a person from a process |
| Source IP | The address the action came from | Support incident investigation, with care for shared networks |
| Audit Hash | The cryptographic hash described below | Detect tampering and link each entry to its predecessor |
Two notes on field design. Keep User ID pseudonymous where the ledger does not need identity; the join to a name should be a separate, controlled lookup. And keep Action Type a controlled vocabulary, not a sentence written by whichever service called the ledger. Free text belongs in a linked detail record, not in the field you will query.
Hash chaining
The hash makes tampering detectable. Each entry's hash covers the previous entry's hash and a canonical form of the current entry.
entry_hash = SHA-256( previous_hash + canonical_entry )
canonical_entry = log_id | user_id | purpose_id | action_type |
timestamp | consent_status | initiator | source_ip
Three implementation rules keep the chain verifiable.
- Canonicalise before hashing. Agree a field order, an encoding, a timestamp format and a rule for nulls. The same entry must always produce the same digest, whoever computes it.
- Store the previous hash with the entry. The chain is only useful if a verifier can walk it without trusting a mutable pointer.
- Publish a verification routine. It recomputes the chain over a range and reports the first entry that fails, not just a pass or fail for the whole ledger.
A hash chain proves internal consistency: nobody changed an entry and left the later hashes intact. It does not prove that the original entry was true. Truth comes from the transaction that wrote it and the controls around that transaction. Say so plainly when you present the evidence; overclaiming is how an audit finding starts.
Append-only storage
Immutable means the application cannot update or delete an entry, and the storage agrees.
- No update or delete path in the service, for any role, including Admin.
- Write-once or append-only storage, or a table protected at the database level with a separate, narrowly held credential.
- Separate retention from the data it describes. A purge of personal data must not remove the ledger entry that proves the processing was authorised.
- Replicate to a second location with write-once semantics, so a compromised primary does not take the history with it.
- Back up the backups. A restore that silently truncates the chain is worse than a visible outage.
- Monitor write continuity. A gap in entry IDs or timestamps is a signal, even if every stored entry verifies.
API contract
Read the audit ledger
/v1/audit-logs?user_id=usr_8f3a&action_type=withdrawResponse 200Returns hash-chained entries filtered by principal, purpose, action or period, for a role with permission and MFA.
Response
{
"log_id": "log_000981",
"user_id": "usr_8f3a",
"purpose_id": "P-MKT",
"action_type": "withdraw",
"timestamp": "2026-11-19T10:15:00Z",
"consent_status": "WITHDRAWN",
"initiator": "user",
"source_ip": "203.0.113.8",
"audit_hash": "sha256:c4d2...",
"previous_hash": "sha256:8f10..."
}What the implementation must hold
- The nine dimensions are Log ID, User ID, Purpose ID, Action Type, Timestamp, Status, Initiator, Source IP and the SHA-256 hash chain.
- audit_hash = SHA-256(previous hash + canonical entry), so editing any past entry breaks every later link.
- Append-only storage. Read access needs RBAC and MFA, and the read is itself logged.
- Offer a verification endpoint that recomputes the chain over a date range and reports the first break.
Access and evidence
The ledger contains the most sensitive behavioural record in the system. Reading it is a privileged act.
| Who | What they can do | What is logged |
|---|---|---|
| Auditor | Query, verify chains, export evidence packages | The query, the range, the requester and the export hash |
| DPO | Read entries for an escalation, request or incident | The reason and the case reference |
| Operator | Read entries for their own operational incident, with a time box | The scope and the expiry of the access |
| Admin | Manage access to the ledger, not its contents | Every grant and revocation |
Exports should be self-contained: the entries, their hashes, the verification result and a manifest that lets a third party recompute the chain. Sign the package. An export that only opens in the vendor's portal is not an evidence package.
Questions the ledger must answer
Test the design with five queries. If any takes more than a few minutes for someone who did not build the system, the model is wrong.
- Show every consent action for this principal, in order, with the notice version shown at each grant.
- Show every validation call for this purpose in the last quarter that returned WITHDRAWN.
- Show the withdrawal, every recipient of the cascade, and each acknowledgement with its evidence reference.
- Show every role change and every ledger read by a named administrator.
- Show the exact entries that a given evidence export contained, and verify the chain over that range.
Failure patterns to design out
- The shared log pipeline. Consent events share a log with application noise, so retention and access follow the noisiest system.
- The editable timestamp. The service writes client time or a mutable field, and the sequence becomes arguable.
- The chain that is never verified. Hashing without a verifier is a ritual. Schedule verification and record its result.
- The nine-field entry with empty fields. Optional in the schema becomes missing in practice.
- The export without a manifest. A CSV is not evidence unless it can be tied to the ledger and verified.
- The purge that eats history. Retention automation deletes ledger entries along with the data they describe.
Next step
The engineering contract behind all of this, including the state machine and a validation sandbox: technical reference and APIs. If you need help with any of this, write to us and we will help.