# Export audit log Export audit log entries as a CSV file for compliance, reporting, or offline analysis. Exports audit log entries matching the specified filters as a downloadable CSV file. Supports the same filtering options as the query endpoint. Maximum 10,000 rows per export. #### Path Parameters **`organization_id`** string required The unique identifier of the organization. #### Query Parameters **`entity_type`** string optional Filter by entity type. Values: `user`, `department`, `role`, `role_assignment`, `department_membership`, `permission`, `knowledge_slice`, `vector_store`, `knowledge_grant`, `knowledge_composite`. **`action_type`** string optional Filter by action type. Values: `created`, `updated`, `deleted`, `invited`, `deactivated`, `reactivated`, `removed`, `assigned`, `unassigned`, `reparented`, `membership_added`, `membership_removed`, and more. **`actor_id`** string optional Filter by the user who performed the action. **`target_id`** string optional Filter by the target entity of the action. **`department_id`** string optional Filter by department context. **`from_date`** string optional Filter entries from this date (ISO 8601 format, e.g. `2025-01-01`). **`to_date`** string optional Filter entries until this date (ISO 8601 format, e.g. `2025-12-31`). **`search_term`** string optional Full-text search across entity name, actor name, and actor email. ## Returns Returns a CSV file as a streaming download. The CSV contains these columns: | Column | Description | | --- | --- | | Timestamp | When the action occurred (ISO 8601) | | Entity Type | Type of entity affected | | Entity Name | Name of the entity | | Action | Action performed | | Actor Name | Name of the user who performed the action | | Actor Email | Email of the user | | Target Name | Name of the target (if applicable) | | Previous Value | Value before the change (if applicable) | | New Value | Value after the change (if applicable) | The response has `Content-Type: text/csv` and `Content-Disposition` header with filename `audit-log-{org_id}-{date}.csv`. Request ```bash cURL curl -s -X GET "https://api.aitronos.com/v1/organizations/org_abc123/audit-log/export?from_date=2025-01-01&to_date=2025-12-31" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -o audit-log.csv ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") csv_content = client.audit_log.export( organization_id="org_abc123", from_date="2025-01-01", to_date="2025-12-31", ) with open("audit-log.csv", "w") as f: f.write(csv_content) ``` ```python Python import requests response = requests.get( "https://api.aitronos.com/v1/organizations/org_abc123/audit-log/export", headers={"Authorization": "Bearer YOUR_ACCESS_TOKEN"}, params={ "from_date": "2025-01-01", "to_date": "2025-12-31", }, ) with open("audit-log.csv", "w") as f: f.write(response.text) ``` ```javascript JavaScript const response = await fetch( "https://api.aitronos.com/v1/organizations/org_abc123/audit-log/export?from_date=2025-01-01&to_date=2025-12-31", { headers: { "Authorization": "Bearer YOUR_ACCESS_TOKEN", }, } ); const csv = await response.text(); console.log(csv); ``` Response ```text 200 OK (CSV) Timestamp,Entity Type,Entity Name,Action,Actor Name,Actor Email,Target Name,Previous Value,New Value 2026-01-15T10:30:00,role_assignment,Admin,assigned,Jane Smith,jane@example.com,John Doe,, 2026-01-14T09:15:00,department,Engineering,created,Jane Smith,jane@example.com,,, ``` ```json 403 Forbidden { "success": false, "error": { "code": "INSUFFICIENT_PERMISSIONS", "message": "You don't have permission to access this resource.", "system_message": "Insufficient permissions for this operation", "type": "client_error", "status": 403, "details": { "required_capability": "export_audit_log" }, "trace_id": "abc-123-def", "timestamp": "2026-01-15T10:30:00Z" } } ``` ```json 422 Validation Error { "success": false, "error": { "code": "AUDIT_EXPORT_LIMIT_EXCEEDED", "message": "The export exceeds the maximum allowed row limit.", "system_message": "the export exceeds the maximum allowed row limit.", "type": "client_error", "status": 422, "details": { "max_rows": 10000 }, "trace_id": "abc-123-def", "timestamp": "2026-01-15T10:30:00Z" } } ``` ## Related Resources - [Query Audit Log](/docs/api-reference/audit-log/query)