Skip to content

AuditService

Provides read access to the append-only audit trail. Every significant platform action (campaign created, message sent, user invited, role changed, etc.) is recorded as an immutable, hash-chained event for tamper detection and compliance.

All RPCs are admin-only and extract org_id from the JWT — it is never sent in request messages.

MethodDescription
ListAuditEventsList audit events with optional filtering
ExportAuditTrailExport the audit trail to S3 in CSV, JSON, or Parquet format

List audit events with optional filtering by event type, actor, and date range. Results are ordered by created_at descending (newest first).

Authorization: Admin only

FieldTypeDescription
page_tokenstringPagination token from a previous response.
page_sizeint32Maximum number of events to return. Min 1, max 100. Default 50.
event_typeAuditEventTypeOptional filter: only return events of this type.
actor_idstringOptional filter: only return events by this actor. UUID format.
start_timeTimestampOptional filter: events after this timestamp (inclusive).
end_timeTimestampOptional filter: events before this timestamp (exclusive).
FieldTypeDescription
eventsAuditEvent[]Audit events matching the request filters.
next_page_tokenstringToken for fetching the next page. Empty when no more events.

TypeScript (Connect-Web)

const response = await auditClient.listAuditEvents({
pageSize: 25,
eventType: AuditEventType.CAMPAIGN_CREATED,
startTime: Timestamp.fromDate(new Date("2026-01-01")),
});
for (const event of response.events) {
console.log(event.id, event.eventType, event.createdAt);
}

Go (gRPC)

resp, err := auditClient.ListAuditEvents(ctx, &pidgrv1.ListAuditEventsRequest{
PageSize: 25,
EventType: pidgrv1.AuditEventType_AUDIT_EVENT_TYPE_CAMPAIGN_CREATED,
StartTime: timestamppb.New(time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)),
})
for _, event := range resp.Events {
fmt.Println(event.Id, event.EventType, event.CreatedAt)
}

Export the audit trail to S3 in CSV, JSON, or Parquet format. This is an async operation — it returns immediately with PENDING status. Poll or check back later for the download URL.

Authorization: Admin only

FieldTypeDescription
formatAuditExportFormatExport format: CSV, JSON, or PARQUET.
start_timeTimestampOptional: export events after this timestamp.
end_timeTimestampOptional: export events before this timestamp.
FieldTypeDescription
export_urlstringPre-signed S3 URL to download the exported audit trail. Only populated when status is COMPLETED.
statusPrivacyRequestStatusCurrent status of the export: PENDING, PROCESSING, COMPLETED, or FAILED.

TypeScript (Connect-Web)

const response = await auditClient.exportAuditTrail({
format: AuditExportFormat.CSV,
startTime: Timestamp.fromDate(new Date("2026-01-01")),
endTime: Timestamp.fromDate(new Date("2026-03-01")),
});
console.log(response.status); // PENDING

Go (gRPC)

resp, err := auditClient.ExportAuditTrail(ctx, &pidgrv1.ExportAuditTrailRequest{
Format: pidgrv1.AuditExportFormat_AUDIT_EXPORT_FORMAT_CSV,
StartTime: timestamppb.New(time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)),
EndTime: timestamppb.New(time.Date(2026, 3, 1, 0, 0, 0, 0, time.UTC)),
})
fmt.Println(resp.Status) // PENDING

An immutable, hash-chained record of a significant platform action. Audit events are append-only — they cannot be updated or deleted. Each event includes a SHA-256 hash linking it to the previous event, forming a tamper-evident chain.

FieldTypeDescription
idstringUnique identifier. UUID format.
org_idstringOrganization in which the event occurred. UUID format.
actor_idstringUser who performed the action. Empty for system-initiated events. UUID format.
event_typeAuditEventTypeType of action that was performed.
entity_typestringType of entity affected (e.g., "campaign", "user", "template"). Max 50 characters.
entity_idstringIdentifier of the entity affected. UUID format.
metadatamap<string, string>Additional context (e.g., old/new values for changes). Max 20 pairs, keys max 50 chars, values max 500 chars.
previous_hashstringSHA-256 hash of the previous event in the chain. Empty for the first event.
hashstringSHA-256 hash of this event (previous_hash + event data) for tamper detection.
created_atTimestampTimestamp when the event was recorded.
ValueDescription
CAMPAIGN_CREATEDA campaign was created.
MESSAGE_SENTA message was sent to a recipient.
MESSAGE_OPENEDA message was opened by a recipient.
ACK_REGISTEREDA recipient acknowledged a campaign.
ESCALATION_EXECUTEDAn escalation was triggered by the workflow.
USER_INVITEDA user was invited to the organization.
USER_DEACTIVATEDA user was deactivated.
DATA_EXPORT_REQUESTEDA data export was requested (GDPR Art. 15).
DATA_DELETION_REQUESTEDA data deletion was requested (GDPR Art. 17).
ROLE_CHANGEDA user’s role was changed.
SSO_CONFIGUREDAn SSO provider was configured.
ValueDescription
CSVComma-separated values.
JSONJSON lines format.
PARQUETApache Parquet columnar format.