Export Audit Log Events through the WorkOS Dashboard and API.
Export Audit Log events as CSV files for compliance reporting and analysis. Create exports through the Dashboard or API, scoped to a single organization within a specified date range.
Navigate to the Organization page, view Audit Log Events, and select “Export CSV” from the “Actions” dropdown. Set your filters and select “Generate CSV file”.

import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const auditLogExport = await workos.auditLogs.createExport({ organizationId: 'org_01EHWNCE74X7JSDV0X3SZ3KJNY', rangeStart: new Date('2022-08-31T15:51:23.604Z'), rangeEnd: new Date('2022-08-31T15:51:23.604Z'), }); // Use auditLogExport.id for fetching export at a later time
After creating the export, fetch it to access the url of the generated CSV file.
The URL will expire after 10 minutes. If the export is needed again at a later time, refetching the export will regenerate the URL.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const auditLogExport = await workos.auditLogs.getExport( 'audit_log_export_01GBT9P815WPET6H8K0XHBACGS', ); // auditLogExport.state `pending` or `ready` // auditLogExport.url available once `state` is `ready`
If the state of the export is still pending, poll the export until it is ready for download.