TrackLayer's audit log is write-only. Events are appened, never modified. Verify endpoint re-computes the chain on demand — if a single hash doesn't match, the entire chain is flagged as compromised.
function computeHash(prevHash: string | null, material: AuditMaterial): string {
const serialized = JSON.stringify({
prev_hash: prevHash,
event_type: material.event_type,
resource_id: material.resource_id,
actor: material.actor,
timestamp: material.timestamp,
payload: material.payload,
});
return crypto.subtle.digest('SHA-256', serialized);
}
// Genesis event (first in chain)
const genesis = await computeHash(null, {
event_type: 'account_created',
resource_id: 'm_abc123',
actor: 'system',
timestamp: '2026-01-01T00:00:00Z',
payload: { plan: 'pro', region: 'eu-west-1' }
});
// hash = h8f3a2c1d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8merchant_id | advisory_lock_enabled | advisory_key_hash | locked_at | locked_by
-----------+----------------------+--------------------+-----------------+------------
m_abc123 | true | h7d2e8f... | 2026-04-15 | admin_user_42
m_def456 | false | null | null | null
// Attempting to append without unlock key
POST /v1/audit/events
{
"merchant_id": "m_abc123",
"event_type": "destination_pause",
"resource_id": "tiktok_abc123",
...
}
→ 403 Forbidden: advisory lock enabled. Provide advisory_key header.Advisory lock is optional for Pro+ and required for Enterprise contracts with compliance SLAs. Lock key is generated once at enablement and hashed for storage. Unlocking requires the original key.
curl -H "Authorization: Bearer $TRACKLAYER_API_KEY" \
https://tracklayer-api.sublime.workers.dev/v1/audit/verify?merchant_id=m_abc123
# Response
{
"merchant_id": "m_abc123",
"chain_status": "valid",
"total_events": 14832,
"break_count": 0,
"first_event": "ae_9a2f1",
"last_event": "ae_9b4e3",
"last_verified_at": "2026-04-23T14:02:11Z"
}The verify endpoint can be called from CI/CD pipelines, SOC2 auditors, or dashboard UI. It's read-only — no state modification. Use it to prove log integrity during compliance audits.
bucket_path | export_schedule | last_exported_at | event_count
-------------------------------+-----------------+---------------------+-------------
tracklayer-audit-abc123/backup | weekly (sun 02:00)| 2026-04-20 02:01:23| 14,732
// Export file structure
backup/2026/04/20/audit-events-m_abc123-2026-04-20.json
{
"merchant_id": "m_abc123",
"exported_at": "2026-04-20T02:01:23Z",
"events": [
{ "event_id": "ae_9a2f1", "prev_hash": null, "hash": "h8f3...", ... },
{ "event_id": "ae_9b3e2", "prev_hash": "h8f3...", "hash": "ha1c...", ... },
...
]
}Exports are gzip-compressed and stored under a merchant-specific prefix. Retention policy is 90 days. Configure exports in Settings → Compliance → Audit Export.
prev_hash || material prevents retroactive edits.
GET /v1/audit/verify returns chain status.
One-click verification with visual chain view.
Optional export to private bucket for offline proof.
We use essential cookies to keep the site secure and functional. Analytics and third-party tags run only with your consent. See our Cookie Policy.
We use essential cookies to keep the site secure and functional. Analytics and third-party tags run only with your consent. See our Cookie Policy.