vadiga974
11/27/2026, 6:11 PMAsk Inkeep
11/27/2026, 6:11 PMAsk Inkeep
11/27/2026, 6:11 PMGET /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.Ask Inkeep
11/27/2026, 6:11 PMvadiga974
11/27/2026, 6:14 PMCarlos Mion
11/27/2026, 7:27 PM#!/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:
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