Skip to content

Export the audit log

GET
/admin/audit/export

Streams the audit log as CSV or as NDJSON (one JSON object per line), oldest first, optionally limited to a time range. Use format=json for NDJSON; anything else gives CSV.

Only since and until narrow the export; there’s no filter by event type or user. columns picks the fields and their order. In CSV the first row holds the column names, and the metadata cell holds the JSON as text.

ip is filled in only if you also hold system.audit.pii.read; otherwise the column stays, empty in CSV and null in NDJSON. Nothing else is held back: user agents and metadata, with any usernames, email addresses or IP addresses they hold, are exported as stored. Cells aren’t escaped for spreadsheet formulas, and user_agent comes from the client, so take care opening the CSV in a spreadsheet.

The server reads the log 1,000 events at a time and sends them as it goes, so a large export doesn’t need much memory. It isn’t a snapshot: events recorded during the export can appear in it. The response has no Content-Length and no file name. If something fails partway through, the 200 has already been sent: the download stops early and may end with a line of error text, so check the end of the file before relying on it.

You need system.audit.read or system.admin.

format
string
default: csv
Allowed values: csv json

json gives NDJSON. Anything else, or leaving it out, gives CSV.

columns
string

Which columns to include, comma-separated, in the order you want: id, event_type, occurred_at, actor_user_ref, subject_user_ref, ip, user_agent, metadata and legal_hold (true for events kept regardless of retention). Unknown names are skipped; if it’s empty or no name is known, you get all nine in that order.

since
string format: date-time

Only events at or after this time.

until
string format: date-time

Only events at or before this time.

The export, streamed: text/csv for CSV, application/x-ndjson for NDJSON, as format chose.

string format: binary

Authentication required, missing, or invalid

object
error
required

Human-readable error summary

string
Example
the request could not be completed
Example
{
"error": "authentication required: sign in and retry with a valid session or API token"
}

Authenticated but missing required capabilities

object
error
required

Human-readable error summary

string
Example
the request could not be completed