Introducing a new way to review your PRs.

Read the announcement

zipstack / unstract

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

View on GitHub

28 documents · Updated Nov 23, 2026

docs / platform-audit

Platform audit events

Platform audit events give each organization a durable record of important admin-visible platform changes. The domain records the actor, action, target, change context, and request that caused a change. Organization admins can read this record through the backend API, while retention rules and a scheduled purge control how long it remains available.

The page sits below Backend API platform. Audit events help explain changes made through Versioned backend APIs and domain modules, Backend workflow management, Agent key-value extraction, and related platform services.

Audit domain

The audit domain provides one organization-scoped record for changes that matter to platform administration. It gives different change flows a shared event model without making the audit log responsible for changing the source resource.

Recorded action groups

Each event uses a registered action key with a label and category. The action vocabulary is also available to clients, so audit views can build filters from the actions active in the deployment. The main groups cover:

GroupRecorded changes
MembersRole changes, invitations, invitation revocation, and member removal
GroupsGroup creation, edits, deletion, and membership changes
KeysKey creation, rotation, revocation, enablement, disablement, field changes, and expiry changes
Platform stateDefault profiles, platform settings, and organization capabilities
ExecutionsAborted executions
ResourcesResource creation, deletion, sharing changes, and co-owner changes

Emitters record an event after the source change succeeds. The event is committed with the surrounding transaction, so a rolled-back change does not leave an event. Recording is best effort: a recording error is logged and does not fail the user's change.

References: backend/…/README.md• L148-200 backend/…/actions.py• L1-15 backend/…/recorder.py• L1-18

Resource events

Resource events give shared platform objects one common audit shape. The target type identifies the resource kind, while the target name and subtype preserve the display context available when the event is recorded.

The resource boundary covers:

  • Adapter instances
  • Connector instances
  • Workflows
  • API deployments
  • Pipelines
  • Prompt Studio projects
  • Cloud resource kinds such as agentic projects and lookups

The domain records resource creation, deletion, sharing changes, and co-owner changes. It does not record every resource edit, and a refused deletion does not create a deletion event.

References: backend/…/resources.py• L1-7 backend/…/resources.py• L55-118 backend/…/README.md• L224-244

Event data

An event keeps copied identity and change data so that the audit view remains useful after the source member or key is removed. It stays linked to its organization and can retain a convenience link to the acting user, but the copied actor fields form the stable audit view.

Event record

The event record contains the data needed to place a change in time, identify its cause, and explain its effect:

DataPurpose
Occurrence timePlaces the event in the audit timeline
ActorIdentifies a user, API key, or system action; copied identity data survives actor deletion
ActionGives the event its registered action key
TargetIdentifies the changed resource type, ID, and display name
SummaryGives a short row-level explanation
ChangesHolds the available before and after values
Request IDConnects the event to the request that caused it
MetadataKeeps extra internal event detail that the read API does not return

Change data is partial. A create normally has only after, and a deletion normally has only before. If an earlier value cannot be read, that side is omitted instead of being treated as empty. Secrets such as tokens, passwords, and key values must not enter the summary, change data, or metadata.

Events are an audit trail, not tamper evidence. Normal event updates and deletes are blocked, but organization deletion, actor deletion, and retention purge can still remove rows.

References: backend/…/models.py• L38-51 backend/…/models.py• L63-117 backend/…/recorder.py• L57-86 backend/…/recorder.py• L234-251

Audit API

The audit API gives an authenticated organization administrator a read-only view of events for the current organization. The v2 backend mounts it under platform/audit/, and the organization-scoped path provides the tenant boundary.

Read endpoints

The API provides four related views:

EndpointPurpose
GET platform/audit/Returns paged events in newest-first order
GET platform/audit/export/Downloads the same filtered data as CSV
GET platform/audit/actions/Returns active action keys, labels, and categories
GET platform/audit/actors/Returns selectable actors seen during the retention window

Only organization admins using a session can read the audit log. Organization members, service accounts, and platform API keys receive 403. Every read applies the caller's organization and the retention cutoff before it applies filters.

References: backend/…/urls_v2.py• L24-40 backend/…/urls.py• L1-27 backend/…/views.py• L68-103

Filters and export

List and export use the same filter model. Clients can filter by action keys, exact actor e-mail, an inclusive date or time range, or a case-insensitive search across actor, key, target, and summary text. Unknown actions and invalid time ranges are validation errors.

The list response includes the configured retention period and supports up to 1,000 rows per page. CSV export is limited to 10,000 matching events. Export values that could be treated as spreadsheet formulas are protected before download.

The actor view includes removed members and deleted keys because actor identity is copied into each event. It excludes system actors without an e-mail and returns at most 1,000 identities.

References: backend/…/README.md• L34-146 backend/…/views.py• L169-320 backend/…/serializers.py• L52-146

Retention lifecycle

Retention has two stages. Reads hide events older than the organization cutoff. A scheduled purge then removes those rows from storage, which makes a shorter retention choice final.

Retention policy

The default retention is 365 days from PLATFORM_AUDIT_RETENTION_DAYS. An organization can override it from 1 to 3650 days. Invalid environment values fail closed to the maximum period, while an invalid organization override is not used by the purge.

Until the purge runs, an event hidden by a shorter retention can become visible again if the organization later raises its retention period. Retention therefore controls both API visibility and the later deletion boundary.

References: backend/…/base.py• L461-467 backend/…/enums.py• L72-78 backend/…/retention.py• L12-39 backend/…/retention.py• L60-64

Purge job

purge_platform_audit_events is the management-command entry point for scheduled cleanup. It checks each organization that has audit events and uses that organization's retention period before deleting expired rows.

The purge supports a dry run and batch deletion. Each batch is its own transaction, so a run that stops part-way keeps completed deletion work and can continue on the next run. If retention cannot be read or is invalid, the command skips that organization and exits non-zero instead of deleting by a guessed period.

References: backend/…/purge_platform_audit_events.py• L1-8 backend/…/purge_platform_audit_events.py• L21-85 backend/…/retention.py• L42-57

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep action registration, event emitters, and platform/audit/actions/ output aligned. A missing registration drops an event, while a changed label or category changes the client-facing vocabulary.
  • Keep organization and actor resolution aligned between the recorder and every emitting flow. Missing organization context prevents storage.
  • Keep event field changes aligned across the event record, read serializer, CSV columns, and API schema.
  • Keep retention validation aligned between read-time cutoff calculation and purge-time deletion. The purge must not use a guessed organization retention.
  • Keep resource kind names aligned with the shareable-resource registry and resource-sharing endpoints.

Important failure modes

TriggerConsequenceGuard
An emitter uses an unregistered actionThe business change succeeds, but no audit row is storedRegister the action before emitting it and use the action vocabulary endpoint as the client contract
Audit recording fails after a successful changeThe change remains successful and the event is lostMonitor recorder error logs; do not make business success depend on audit storage
A transaction rolls backIts audit event is not committedEmit after the change and keep the event write tied to commit
A caller without organization-admin session access reads the APIThe request receives 403Use an organization-admin session for audit reads
Export matches more than 10,000 eventsThe API returns 413 and no CSVNarrow the action, actor, search, or time filter
Purge cannot read an organization's retentionThat organization's rows are skipped and the command exits non-zeroFix the retention setting or read failure, then run the purge again
A resource changes through an uninstrumented pathThe audit trail has no matching eventTreat the domain as coverage for instrumented platform flows, not every external or admin-side change

Key files

FileWhy to read it
backend/…/README.mdPublished contract for recorded actions, API behavior, retention, and coverage limits
backend/…/actions.pyDefines the shared action vocabulary and target names
backend/…/recorder.pyShows actor data, change data, transaction timing, and best-effort recording
backend/…/resources.pyDefines the resource-event boundary for creation, deletion, and sharing changes
backend/…/views.pyDefines API access rules, filtering, pagination, export, and actor discovery
backend/…/models.pyDefines retained event data and the immutability guard
backend/…/retention.pyDefines read and purge retention decisions
backend/…/purge_platform_audit_events.pyDefines batch cleanup and safety behavior for unreadable retention settings