SiftDocs
Developer

Export audit events

Export the organization audit log and keep a security monitoring system in sync.

Use GET /v0/audit-events to export your organization's retained audit events. The API returns the newest events first.

At a glance

EndpointGET /v0/audit-events
Key profileAudit log (read only)
Scopeaudit:read
Page sizeUp to 50 events
End of exportnextCursor is null
MCP tool callsAvailable for 30 days

Make your first request

Ask a Super Admin to create an Audit log (read only) key in Settings → Connections → Developer access → API keys.

Run this block in Bash or Zsh. Paste the key at the prompt. If you have a staging key, set the URL to https://api.staging.getsift.ai.

export SIFT_API_BASE='https://api.getsift.ai'
printf 'Sift Audit log key: '
IFS= read -rs SIFT_AUDIT_API_KEY
printf '\n'
export SIFT_AUDIT_API_KEY

In the same terminal, request the first page with all event types.

curl --fail-with-body --get "$SIFT_API_BASE/v0/audit-events" \
  --header "X-API-Key: $SIFT_AUDIT_API_KEY"

Read the response

HTTP 200 returns data and nextCursor. If data is empty and a cursor is present, continue to the next page. If the cursor is null, you have reached the end.

{
  "success": true,
  "data": [
    {
      "id": "audit_evt_example",
      "type": "EXPORT_DOWNLOADED",
      "actorId": "user_example",
      "actorName": "Taylor",
      "targetId": null,
      "targetName": "people.csv",
      "metadata": { "format": "csv" },
      "createdAt": "2026-11-24T08:56:30.000Z",
      "viaAgent": null
    }
  ],
  "nextCursor": null
}

id identifies the event. actorId and actorName identify the actor when known. targetId and targetName identify the object when known. viaAgent identifies the agent surface when present. The shape of metadata depends on the event type. Keep unfamiliar event types and metadata fields so your export can accept new events.

Filter events

Add one --data-urlencode argument to the cURL command per filter. For example, add --data-urlencode 'types=USER_SIGNED_IN' to read sign-in events.

Query parameterUse
from, toInclusive bounds on createdAt. Use ISO 8601 timestamps with a time zone.
typesComma-separated event types. Omit it to return every type.
actorIdRestrict results to the ID of one actor.
cursorPass the previous response's nextCursor unchanged. URL-encode it as a query parameter.

Export to a file

Save this as export-audit.py. It writes one JSON event per line. It fixes the end time when it starts and follows cursors through empty pages.

import json
import os
from datetime import datetime, timezone
from urllib.parse import urlencode
from urllib.request import Request, urlopen

base_url = os.environ.get("SIFT_API_BASE", "https://api.getsift.ai").rstrip("/")
headers = {"X-API-Key": os.environ["SIFT_AUDIT_API_KEY"]}
bounds = {
    "to": os.environ.get("SIFT_AUDIT_TO")
    or datetime.now(timezone.utc).isoformat(timespec="milliseconds")
}
if os.environ.get("SIFT_AUDIT_FROM"):
    bounds["from"] = os.environ["SIFT_AUDIT_FROM"]

cursor = None
while True:
    query = dict(bounds)
    if cursor is not None:
        query["cursor"] = cursor
    request = Request(
        f"{base_url}/v0/audit-events?{urlencode(query)}",
        headers=headers,
    )
    with urlopen(request, timeout=60) as response:
        page = json.load(response)

    for event in page["data"]:
        print(json.dumps(event))

    next_cursor = page["nextCursor"]
    if next_cursor is None:
        break
    if next_cursor == cursor:
        raise RuntimeError("The audit cursor did not advance")
    cursor = next_cursor
python3 export-audit.py > audit.ndjson.part \
  && mv audit.ndjson.part audit.ndjson \
  && wc -l audit.ndjson

When the command succeeds, it saves audit.ndjson in your current directory and prints the event count. If a page fails, the partial output stays in audit.ndjson.part.

To make an export repeatable, set its UTC time window before the first run. Replace the example dates with your own.

export SIFT_AUDIT_FROM='2026-11-01T00:00:00Z'
export SIFT_AUDIT_TO='2026-11-02T00:00:00Z'

If a page fails, run the export command again with the same time bounds. The script starts at the first page. To export from the start of retained history, leave SIFT_AUDIT_FROM unset.

Poll for changes

  1. For a historical export, set to to a fixed UTC time. Omit from to start with all retained history.
  2. Store each event by id. Keep the filters fixed and send each nextCursor as cursor on the next request.
  3. Stop when nextCursor is null. Keep paging when data is empty and a cursor is present.
  4. For the next poll, overlap the previous time window. Use a new to value and restart without a cursor. Deduplicate by id. Advance the saved time only after all pages succeed.

Some events arrive after their createdAt time. Replay the affected window after an outage or a historical import. The export contains events that Sift recorded and still retains.

Handle errors

HTTP statusWhat to check
400Check the timestamps and pass the cursor from the last successful page unchanged.
401Check whether the key is present, valid, and still active.
403Check that the key has audit:read. The Reporting key has a different scope.
500If you page in your own client, retry the same page with the same cursor and time bounds. Increase the wait between attempts.

On this page