how to export audit logs and activity logs in the ...
# permit-saas
v
how to export audit logs and activity logs in the portal? I dont see any options
a
Hi @vadiga974, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
The documentation doesn't describe an export button for audit logs in the Permit.io dashboard. What it does describe are ways to view, filter, and collect log entries outside the UI. ​*Audit logs (decision logs)*​ • The ​*Audit Log*​ screen in the Permit.io dashboard lets you filter entries by user, date, decision, and tenant, and open an entry to see its decision log. (1) • To collect entries in code (for example, for a reporting period), the documentation points to the List audit logs endpoint of the Permit API. (1) • To get decision logs into your own tooling, you can forward PDP decision logs to Elasticsearch or stdout with the Fluent Bit logs forwarder and then into your SIEM. See Forward decision logs. (2) • Permit deletes old audit logs periodically, so collect what you need within your retention window. (1) ​*Activity logs*​ • The Activity Log API (
GET /v2/activity
) accepts the
timestamp_from
and
timestamp_until
query parameters, both in seconds since the epoch. Consecutive time windows can return the same event twice, so deduplicate on the
id
field of each event. (3) ​*Permit MCP Gateway*​ If you're using the gateway, each agent, person, and MCP server page has an ​*Audit Logs*​ tab, and the ​*Dashboard*​ has a ​*Live activity*​ feed. The documentation describes these for viewing, not exporting. For a per-period collection, it directs you to the Permit.io dashboard's ​*Audit Log*​ screen or the API above. (1) If you can tell me which logs you're looking at (decision logs, the activity log, or the MCP Gateway views), I can narrow this down. If you're still not seeing the ​*Audit Log*​ screen, you can reach the team at help@permit.io.
To learn more, see the sources I considered: [[1] Investigate agent activity with audit logs](https://docs.permit.io/permit-mcp-gateway/audit-logs) [[2] Audit and compliance evidence for AI coding agents](https://docs.permit.io/software-factory-security/compliance) [[3] FAQ](https://docs.permit.io/faq)
v
is there no way to export logs for review?
c
Hi @vadiga974, there’s no export button in the dashboard today, on either the Audit Log or the Activity Log. You can export both through the API, though. Here’s how. You’ll need curl and jq. 1. Get an API key • Audit logs: use an environment API key. On the Projects screen, click the three dots on your environment and choose Copy API Key (https://docs.permit.io/overview/get-api-key). The same card shows the project and environment keys you’ll use below. • Activity log: use an organization API key. An org admin creates it under Settings → API Keys (https://app.permit.io/settings/api-keys). 2. Export audit logs for a period Each request returns at most 100 entries, so the script below pages through until it has them all and writes one JSON object per line. Timestamps are Unix seconds. For example, 1793491200 is Nov 1, 2026 00:00 UTC.
Copy code
#!/usr/bin/env bash
# Usage: PERMIT_API_KEY=<key> ./export_audit_logs.sh <project> <env> <from> <to> > audit_logs.jsonl
set -euo pipefail
url="https://api.permit.io/v2/pdps/$1/$2/audit_logs"
page=1
while :; do
  resp=$(curl -sSf -G "$url" \
    -H "Authorization: Bearer $PERMIT_API_KEY" \
    --data-urlencode "timestamp_from=$3" --data-urlencode "timestamp_to=$4" \
    --data-urlencode "query=none" --data-urlencode "per_page=100" \
    --data-urlencode "page=$page")
  if [ "$page" -eq 1 ] && [ "$(jq '.total_count' <<<"$resp")" -gt 10000 ]; then
    echo "More than 10,000 entries in this window: only the first 10,000 are exported. Use a shorter window." >&2
  fi
  jq -c '.data[]' <<<"$resp"
  if [ "$(jq '.data | length' <<<"$resp")" -lt 100 ] || [ "$page" -ge 100 ]; then break; fi
  page=$((page + 1))
done
Then remove duplicates and turn the result into a CSV:
Copy code
sort -u audit_logs*.jsonl > all.jsonl
jq -r '[.timestamp, .user_key, .action, .resource_type, .tenant, .decision] | @csv' all.jsonl > audit_logs.csv
Good to know: • Pass both timestamp_from and timestamp_to. The time filter only applies when both are set. • query=none includes every query type. Without it you get check calls only. • You can narrow the export with users, decision, resources, tenant or action. • Each time window can return at most 10,000 entries. For a busy period, run the script once per day or week, starting each window where the previous one ended, and let sort -u drop the overlap. • End the window in the past rather than at “now”. New decisions arriving during the export shift the pages. • GET .../audit_logs/{log_id} returns the full decision for a single entry. 3. Export the activity log Use the same script with these changes: • URL: api.permit.io/v2/activity • timestamp_until instead of timestamp_to • Drop query=none • Use the organization key The same rules apply: pass both bounds, keep each window under 10,000 events, and remove duplicates. You can filter by actor_id, actor_type, project_id and env_id. Retention Permit keeps audit logs for a limited time, so export a review period while it’s still inside that window. If you want a continuous copy in your own logging system, a PDP deployed with our Helm chart can forward every decision to Elasticsearch or stdout: docs.permit.io/how-to/use-audit-logs/logs-forwarder