Audit contract
The ingestion endpoint accepts structured CloudEvents-compatible JSON.
The required standard fields are specversion, id, source, type, time, datacontenttype, and data.
The supported specification version is 1.0.
The supported data content type is application/json.
The source is an absolute URI, such as urn:my-app:projects.
The enterprise extensions use lowercase names:
| Extension | Meaning |
|---|---|
organizationid |
Required tenant identifier within the caller's credential scope |
actorid |
Optional canonical user or trusted application actor identifier |
resourcetype |
Optional application resource category |
resourceid |
Optional application resource identifier |
The API rejects unknown fields. Optional extension values can be absent or null. A user session can submit only its own actor ID. A scoped service can submit trusted external actor references. Untrusted identity headers have no effect.
The durable event identity is (organizationid, source, id).
The first write returns duplicate: false.
An identical retry returns duplicate: true.
A retry with changed content returns HTTP 409.
Retries must preserve the event ID, timestamp, and payload.
The SDK does not retry writes automatically.
The runtime acknowledges a write after the PostgreSQL commit. The connection enables synchronous commit. The database operator controls storage durability, backups, and replication. Direct audit API calls do not share a transaction with an application's business database. The reference application now commits each business change and its pending audit input through its own transactional outbox. Its worker submits that input after the application transaction commits and retries interrupted delivery. Other applications must implement an outbox in their own business database when they need this guarantee.
Queries filter by organization, actor, action, resource type, resource ID, and inclusive time bounds.
The action filter matches the CloudEvents type field.
Pages contain at most 100 events and default to 50.
Events sort by database ingestion sequence, newest first.
The opaque cursor includes the organization and last sequence.
The provider rejects cursors from another organization.
Retention uses the server receipt timestamp, rather than the caller-supplied event timestamp.
An hourly maintenance task deletes events older than audit_retention_days.
The default retention is 90 days.
Idempotency applies while the stored event remains within retention.
Customer exports with existing authentication
Run the backend with the audit-only configuration (deployments/audit-only.yaml). Give the exporting service audit:export for the customer organizations it serves. In your backend, authenticate the user, verify their export permission in that customer, and take their stable ID from the session.
for await (const event of client.audit.exportEvents(session.organizationId, session.userId, {
resourceType: "payroll_record",
resourceId: payrollRecord.id,
})) {
await writeExportRow(event);
}The HTTP endpoint is POST /v1/organizations/{id}/audit-events/export. Send requested_by and an optional filter object. HTTP filters use resource_type and resource_id. To continue, resend the filters with the returned until and page.next_cursor. The SDK carries both across pages. Before returning each page the runtime records audit.export.page with the host admin in actorid and the authenticated service in data.service_id. Limit ordinary audit:read to trusted consumers that need the original event data.
For application events, customer exports include the actor, resource, time and other envelope fields. Use stable, credential-free identifiers in the envelope, including the source URI. Their data defaults to {}. To publish application data, configure the exact source and event type. Each field maps an output name to a JSON Pointer into the original data. Select values your application intends customers to see.
audit_export_fields:
- source: urn:my-app:payroll
event_type: payroll.posted
fields:
status: /result/status
record_count: /record_countThis rule can produce {"status":"posted","record_count":12}. Missing paths, objects and arrays are omitted. You can select a specific nested scalar. Rules apply when the page is read, including to events recorded earlier. OE records the origin of its own events at write time and recursively redacts credential fields in their payloads. The ordinary audit list also applies this customer view to user and portal sessions. A trusted backend service with audit:read can read original payloads.
Provisioning and security events
Directory mutations write their audit event in the same transaction as the access change.
Repeated changes with identical content preserve the resource version and do not add duplicate change events.
Actions include directory.user.created, directory.user.updated, directory.user.deactivated, and directory.user.deleted.
Group actions use directory.group.created, directory.group.updated, and directory.group.deleted.
Configuration changes emit directory.mapping.updated.
The signal worker emits security.stream.verified, security.stream.updated, or security.session.revoked once per accepted event.
Revocation data contains the transmitter event ID and the numbers of sessions and pending exchanges cleaned up.
The durable denial record takes effect before this asynchronous audit entry appears.
The inbox and revocation records have separate retention from the ordinary audit history.
Sign-in events
The runtime audits every sign-in that reaches the point of issuing a login code, through SSO, SAML or a local account.
auth.login.succeeded commits in the same transaction as the login code.
Its actor and resource are the user, and its data holds connection_id, service_id, issuer, amr, acr and authenticated_at.
Broker mode and runtime sessions start from the same code, so both are covered.
auth.login.failed records a sign-in that came back to the runtime's callback and was refused.
It has no actor, because the person is not known for certain, and its resource is the connection.
reason is the identity provider failure, such as signature_invalid, issuer_mismatch or idp_error, or access_denied when the response was valid but the organization refused the person, for example after a directory deactivated them.
A wrong local password is not audited here; local accounts covers throttling.
A failure caused by an outage is logged instead.
Filter with action=auth.login.failed to find attacks or a broken connection.
Stream audit entries to a SIEM
An audit stream sends every new original audit entry of an organization to an operator-approved HTTPS endpoint, such as a SIEM's HTTP collector. Configure a destination authorized to receive the full payload.
Create one with POST /v1/organizations/{org}/audit-streams and a label and endpoint.
The caller needs subscriptions:write and audit:read for the organization, as an administrator or a service key.
The endpoint must match events.allowed_destination_origins, so streams need the events module.
The response holds the Standard Webhooks signing secret once.
GET on the same path lists the streams with their last attempt and failure count, and DELETE .../audit-streams/{stream} stops one.
An organization can have five active streams.
In the TypeScript SDK the calls are client.audit.streams.list, create and revoke.
Creation takes a database snapshot. The stream includes its own audit.stream.created event and writes that were still in flight at that snapshot once they commit. A writer with an earlier transaction ID can appear before the creation event. Previously committed history stays outside the stream.
Each request carries up to 100 entries, oldest first:
{
"type": "audit.batch",
"id": "aub_…",
"stream_id": "aus_…",
"organization_id": "acme",
"events": [{ "specversion": "1.0", "type": "auth.login.succeeded", "…": "…" }]
}Verify it with the same headers and SDK call as event webhooks; webhook-id equals the batch id.
Any 2xx response acknowledges the batch, and the next one follows at once.
A failed batch is retried with the event delivery backoff and holds back everything after it.
A retry sends the same entries under the same id, so a receiver can drop repeats by batch ID or by each entry's source and id.
The stream orders entries by writer transaction ID and then by event sequence within that transaction.
A transaction that receives an earlier ID can commit later and still appear first. An open writer in any organization can delay entries with later transaction IDs.
A stream that keeps failing for longer than audit_retention_days loses the entries that retention deletes, so watch failures and last_delivered_at.
Permission changes
Advanced permission mutations commit their audit event with the policy state, organization revision, and synchronization entry.
Events identify the authenticated user or service, affected resource when applicable, revision, and policy version.
A change event's resourceid names the object it touched, such as grant:bob_share, role:editor, resource:document/doc_a, or subject:<user ID>.
Its data.change holds the change, and data.previous holds the object's earlier version when it replaced or deleted one.
Attribute changes list attribute names and never values.
Group changes record the member count, not the member list.
Actions cover role, assignment, group, grant, resource, relationship, attribute, migration, and policy-version changes.
Advanced membership administration emits permissions.membership.changed and permissions.invitation.created.
No-op retries do not create access-change events.
Policy comparison records translation agreement before activation. Activation and rollback use the same versioned activation path and produce an atomic activation event. Decision diagnostics require separate authority and do not create an unbounded per-decision audit stream. Direct application audit calls remain separate from business transactions. The reference application now uses the transactional outbox described below.
Administration explorer
The administration API adds resource type and resource ID filters alongside actor, action, time, and cursor filters.
Its export endpoint returns bounded pages with a pinned end time.
The SDK supplies an async event iterator over those pages.
The portal downloads one bounded, redacted JSON page with its end time and continuation cursor.
Each export requires audit:export and records its initiating actor.
Administrative events cover portal entry, configuration drafts/tests/activation, DNS proof, key rotation/revocation, invitations, and session revocation. Membership suspension also retains the permission mutation audit trail. Stored secrets, session credentials, and plaintext SCIM keys never enter these event payloads. The explorer uses the same application field rules and OE credential redaction as the customer export. Retention remains based on ingestion time.
Application outbox delivery
The v0.5 example commits each business mutation and pending audit input in one application transaction. The worker preserves its original event ID, time, source, actor, resource, and payload across retries. An interrupted acknowledgment can produce another submission but cannot produce another stored event within the audit retention window.
The example limits submission to 20 attempts and a 23-hour window. Keep runtime audit retention longer than that window. Failed records remain available for investigation in the application database. This pattern requires an outbox in each application's own business database. Runtime state and application state still use independent transactions. See events and reliable integrations for the processing and recovery contract.