Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fact0.io/llms.txt

Use this file to discover all available pages before exploring further.

Audit client

import ledgerflow

client = ledgerflow.Client(api_key="alk_live_...")
audit = client.audit  # or client.audit directly via convenience methods

Constructor options

ParameterDefaultDescription
api_keyrequiredWrite or read-scoped alk_live_* key
base_urlhttps://api.ledgerflow.ioAPI origin
batch_max_size100Max events per flush
batch_max_wait_ms500Max wait before flush
raise_on_errorFalseRaise on transport failure
dead_letter_pathNoneJSONL path for failed batches
syncFalseSynchronous ingest (X-LedgerFlow-Sync: true)
poll_receiptsTruePoll async receipts after ingest
Environment variables: LEDGERFLOW_API_KEY, LEDGERFLOW_BASE_URL.

Write methods

log(**fields) -> None

Validate and enqueue one event. Returns immediately.

log_batch(events: list[dict]) -> BatchResult | AsyncReceipt

Send up to 1000 events. Uses batch endpoint.

flush() -> None

Block until the in-memory buffer is drained.

close() -> None

Stop background flusher and drain. Registered with atexit.

Read methods

get_event(event_id: str) -> dict

GET /v1/events/{id}

list_events(**filters) -> dict

GET /v1/events — filters: actor_id, actor_type, action, resource_id, outcome, from, to, page, page_size.

get_receipt(receipt_id: str) -> dict

GET /v1/receipts/{id}

wait_for_receipt(receipt_id: str, timeout_s=30) -> dict

Poll until status is committed or failed.

Verify methods

verify(from_=None, to=None, scan_all=False) -> dict

GET /v1/verify

verify_event(event_id: str) -> dict

GET /v1/events/{id}/verify

Export methods

export_pdf(from_=None, to=None) -> bytes

GET /v1/export/pdf

export_evidence_pack(from_=None, to=None) -> bytes

GET /v1/export/evidence-pack

Stream

stream_events() -> Iterator[dict]

SSE iterator over GET /v1/events/stream.

Error handling

ExceptionWhen
ledgerflow.ValidationErrorInvalid event fields at log()
ledgerflow.TransportErrorHTTP failure (only if raise_on_error=True)
ledgerflow.AuditLogErrorBase class
By default transport errors are logged and optionally written to dead-letter JSONL.