Hello! We would like to preserve audit logs in ob...
# general
m
Hello! We would like to preserve audit logs in object storage. Ideally, we would like to fetch the logs once a day. Do you have documentation or code samples for the same?
o
1. this should be asked in #C02RTML2WNN 2. This can be done via the audit-logs API 3. @Ask Inkeep can provide an example
👍 1
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
You can access audit logs through the Permit.io API and integrate them with your preferred logging platform (1) . The audit logs are automatically generated as Permit.io powers your application . For accessing audit logs programmatically, you can use the Audit Log API. The logs can be filtered based on user, date, decision, and tenant . Note that there is a maximum of 10,000 results per API query - if you need additional results, you'll need to readjust the query's time window or apply additional filters . The audit logs are also written to
stdout/stderr
in your deployed PDP microservice, making it easy to integrate them directly with your preferred logging platform . For best practices on implementing audit log collection, the documentation recommends using asynchronous audit logging to avoid adding latency, and preferring solutions that generate audit logs implicitly without explicit logging code in your application (2) . If you need more specific implementation details or code samples for your use case, I recommend reaching out to the Permit.io team via Email or their Slack community for tailored guidance on setting up daily batch exports to object storage.
To learn more, see the sources I considered: [[1] Audit Types & Filtering](https://docs.permit.io/how-to/use-audit-logs/types-and-filtering) [[2] Best Practices for Authorization Audit Logs](https://www.permit.io/blog/audit-logs)
o
@Ask Inkeep provide a code example for using the API
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
Here's a code example for fetching audit logs using the Permit.io API (1) :
Copy code
curl "<https://api.permit.io/v2/pdps/{proj_id}/{env_id}/audit_logs>" \
-H "Authorization: Bearer {api-key}"
The API endpoint accepts several query parameters for filtering : •
pdp_id
- Filter by PDP config id •
users
- List of user keys or emails to filter by •
decision
- Filter by decision result (boolean) •
resources
- Filter by resources •
tenant
- Filter by tenant •
action
- Filter by action •
timestamp_from
- Filter by timestamp from (integer) •
timestamp_to
- Filter by timestamp to (integer) •
page
- Page number of results to fetch, starting at 1 •
per_page
- Number of results per page (max 100) For example, to fetch logs from a specific time range:
Copy code
curl "<https://api.permit.io/v2/pdps/{proj_id}/{env_id}/audit_logs?timestamp_from=1640995200&timestamp_to=1641081600&per_page=100>" \
-H "Authorization: Bearer {api-key}"
Note that the maximum number of results for this API is 10,000 (2) . To obtain additional results, you'll need to readjust the query's time window or apply additional filters .
To learn more, see the sources I considered: [[1] GET /v2/pdps/{proj_id}/{env_id}/audit_logs](https://api.permit.io/v2/redoc#tag/Audit-Logs/operation/list_audit_logs) [[2] Audit Types & Filtering](https://docs.permit.io/how-to/use-audit-logs/types-and-filtering)
Thanks for the feedback, glad I was helpful.
m
I'm using Python but the request is similar to what you've described above. However, I'm getting an error. I have redacted the project ID and environment ID.
Copy code
2026-07-17 16:10:33,676 - DEBUG - Starting new HTTPS connection (1): <http://www.permit.io:443|www.permit.io:443>
2026-07-17 16:10:34,381 - DEBUG - <https://www.permit.io:443> "GET /v2/pdps/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/audit_logs?from=2026-07-10T10%3A40%3A33.451011%2B00%3A00&to=2026-07-17T10%3A40%3A33.451179%2B00%3A00&page=1&per_page=100&query=none HTTP/1.1" 200 None
2026-07-17 16:10:34,424 - WARNING - API error: Expecting value: line 1 column 1 (char 0). Retrying in 1s...
o
@Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
The error you're seeing suggests the API is returning an empty or non-JSON response. Looking at your request, I notice you're using
<http://www.permit.io|www.permit.io>
as the base URL, but the correct API endpoint should be
<http://api.permit.io|api.permit.io>
(1) . The correct Python request should look like this:
Copy code
import requests

api_key = "your_api_key"
proj_id = "your_project_id"
env_id = "your_environment_id"

url = f"<https://api.permit.io/v2/pdps/{proj_id}/{env_id}/audit_logs>"

headers = {
    "Authorization": f"Bearer {api_key}"
}

params = {
    "timestamp_from": 1720605633,  # Unix timestamp
    "timestamp_to": 1721210433,    # Unix timestamp
    "page": 1,
    "per_page": 100
}

response = requests.get(url, headers=headers, params=params)
Key issues with your current request: 1. ​*Wrong base URL*​: Change from
<http://www.permit.io|www.permit.io>
to
<http://api.permit.io|api.permit.io>
2. ​*Parameter names*​: The API expects
timestamp_from
and
timestamp_to
(not
from
and
to
) , and these should be Unix timestamps (integers) , not ISO format strings 3. ​*Remove
query
parameter*​: The API doesn't have a
query
parameter - use the specific filter parameters instead The API supports these query parameters for filtering : •
pdp_id
- Filter by PDP config id •
users
- List of user keys or emails •
decision
- Filter by decision result (boolean) •
resources
- Filter by resources •
tenant
- Filter by tenant •
action
- Filter by action •
timestamp_from
- Filter by timestamp from (integer) •
timestamp_to
- Filter by timestamp to (integer) •
page
- Page number starting at 1 •
per_page
- Number of results per page (max 100) Remember that the maximum number of results for this API is 10,000 (2) . If you need additional results, readjust the query's time window or apply additional filters (1) . To help investigate further, could you share: 1. Which Workspace / Project / Env you are using 2. The exact SDK code or CURL command you're performing 3. Which PDP version you are running 4. Relevant logs from your PDP
To learn more, see the sources I considered: [[1] GET /v2/pdps/{proj_id}/{env_id}/audit_logs](https://api.permit.io/v2/redoc#tag/Audit-Logs/operation/list_audit_logs) [[2] Audit Types & Filtering](https://docs.permit.io/how-to/use-audit-logs/types-and-filtering)