Audit Logs SDK
The audit namespace lives under client.audit. It defaults occurred_at to now, generates the required idempotency key for you, and ships an offline verifier that needs no network call. A key needs audit:write to send events and audit:read to read, verify, and export.
Install
pip install invoanceMethods
Send an event
Append one activity event to an org's signed ledger. occurred_at defaults to now and the Idempotency-Key is generated for you.
ev = await client.audit.events.ingest(
org="acme-prod",
action="user.signed_in",
actor={"type": "user", "id": "user_123"},
)
print(ev["event_id"])Get an event
Retrieve a single audit event by id.
event = await client.audit.events.get("aevt_01J…")
print(event["action"], event["seq"])List events
Keyset-paginated listing with action, actor, target, and date filters.
page = await client.audit.events.list(
org_id="aorg_01J…", actions="user.signed_in", limit=50
)
for e in page["events"]:
print(e["id"], e["action"])Verify an event offline
Reconstruct the canonical signed bytes and check the Ed25519 signature locally, with no trust in the server's answer.
from invoance import verify_audit_event
event = await client.audit.events.get("aevt_01J…")
result = verify_audit_event(event) # offline, no network call
print(result.valid) # TrueExport events
Queue an async CSV or NDJSON export, then poll for the download URL.
job = await client.audit.exports.create(
org_id="aorg_01J…", format="csv"
)
status = await client.audit.exports.get(job["id"]) # poll until "ready"
print(status["status"], status.get("download_url"))Next steps
See the Audit Logs quick start for the full request and response shapes, the hosted-viewer hand-off, SIEM streaming, and the endpoint reference.