# List audit logs div strong 🔨 In Development — This section is still being developed and may change. Retrieve audit logs for resource changes across your organization. Track who made what changes, when, and view detailed change history. List all audit log entries for an organization with flexible filtering options. Useful for compliance, debugging, and understanding system changes. #### Path Parameters **`organization_id`** string required The unique identifier of the organization. #### Query Parameters **`resourceType`** string optional Filter by resource type. Values: `assistant`, `thread`, `vector_store`, `rule`, `mcp_configuration`, `user`, `organization`. **`resourceId`** string optional Filter by specific resource ID. **`action`** string optional Filter by action type. Values: `created`, `updated`, `deleted`, `accessed`, `shared`, `archived`. **`userId`** string optional Filter by user who performed the action. **`startDate`** string optional Filter logs from this date (ISO 8601 format). **`endDate`** string optional Filter logs until this date (ISO 8601 format). **`limit`** integer optional · Defaults to `50` Number of logs to return per page. Maximum: 100. **`offset`** integer optional · Defaults to `0` Number of logs to skip for pagination. All Logs ```bash curl "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?limit=20" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests response = requests.get( "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs", headers={"Authorization": f"Bearer {api_key}"}, params={"limit": 20} ) logs = response.json() print(f"Found {logs['pagination']['total']} audit logs") for log in logs['auditLogs']: print(f"{log['timestamp']}: {log['action']} {log['resourceType']} by {log['userName']}") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?limit=20', { headers: { 'Authorization': `Bearer ${apiKey}` } }); const logs = await response.json(); console.log(`Found ${logs.pagination.total} audit logs`); logs.auditLogs.forEach(log => { console.log(`${log.timestamp}: ${log.action} ${log.resourceType} by ${log.userName}`); }); ``` By Resource Type ```bash curl "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?resourceType=assistant" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests response = requests.get( "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs", headers={"Authorization": f"Bearer {api_key}"}, params={"resourceType": "assistant"} ) logs = response.json() print(f"Found {len(logs['auditLogs'])} assistant changes") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?resourceType=assistant', { headers: { 'Authorization': `Bearer ${apiKey}` } }); const logs = await response.json(); console.log(`Found ${logs.auditLogs.length} assistant changes`); ``` By Specific Resource ```bash curl "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?resourceType=assistant&resourceId=asst_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests response = requests.get( "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs", headers={"Authorization": f"Bearer {api_key}"}, params={ "resourceType": "assistant", "resourceId": "asst_abc123" } ) logs = response.json() for log in logs['auditLogs']: print(f"{log['timestamp']}: {log['action']}") for change in log.get('changes', []): print(f" - {change['field']}: {change['oldValue']} → {change['newValue']}") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?resourceType=assistant&resourceId=asst_abc123', { headers: { 'Authorization': `Bearer ${apiKey}` } }); const logs = await response.json(); logs.auditLogs.forEach(log => { console.log(`${log.timestamp}: ${log.action}`); log.changes?.forEach(change => { console.log(` - ${change.field}: ${change.oldValue} → ${change.newValue}`); }); }); ``` By Date Range ```bash curl "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?startDate=2025-01-01T00:00:00Z&endDate=2025-01-31T23:59:59Z" \ -H "Authorization: Bearer $FREDDY_API_KEY" ``` ```python import requests response = requests.get( "https://api.freddy.aitronos.com/v1/org_abc123/audit-logs", headers={"Authorization": f"Bearer {api_key}"}, params={ "startDate": "2025-01-01T00:00:00Z", "endDate": "2025-01-31T23:59:59Z" } ) logs = response.json() print(f"Found {logs['pagination']['total']} logs in January 2025") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/org_abc123/audit-logs?startDate=2025-01-01T00:00:00Z&endDate=2025-01-31T23:59:59Z', { headers: { 'Authorization': `Bearer ${apiKey}` } }); const logs = await response.json(); console.log(`Found ${logs.pagination.total} logs in January 2025`); ``` ## Response ```json { "auditLogs": [ { "id": "log_abc123", "timestamp": "2025-01-20T10:30:00Z", "resourceType": "assistant", "resourceId": "asst_abc123", "resourceName": "Customer Support Bot", "action": "updated", "userId": "uid_user123", "userName": "John Doe", "userEmail": "john@example.com", "changes": [ { "field": "temperature", "oldValue": 0.7, "newValue": 0.9 }, { "field": "tools.webSearch", "oldValue": false, "newValue": true }, { "field": "instructions", "oldValue": "You are a helpful assistant.", "newValue": "You are a helpful customer support assistant." } ], "metadata": { "ipAddress": "192.168.1.1", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)", "source": "web_ui" } }, { "id": "log_def456", "timestamp": "2025-01-20T09:15:00Z", "resourceType": "thread", "resourceId": "thread_xyz789", "resourceName": "Customer Inquiry #1234", "action": "created", "userId": "uid_user456", "userName": "Jane Smith", "userEmail": "jane@example.com", "changes": [], "metadata": { "ipAddress": "192.168.1.2", "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", "source": "api" } } ], "pagination": { "total": 150, "limit": 50, "offset": 0, "hasMore": true } } ``` ### Errors ```json 404 Not Found { "error": { "message": "Organization not found", "type": "not_found_error", "code": "organization_not_found" } } ``` ```json 401 Unauthorized { "error": { "message": "Authentication required", "type": "authentication_error", "code": "missing_authentication" } } ``` ```json 403 Forbidden { "error": { "message": "Insufficient permissions to view audit logs", "type": "permission_error", "code": "insufficient_permissions" } } ``` ## Resource-Specific Shortcuts For convenience, you can also use resource-specific endpoints: - **Assistants:** `GET /v1/assistants/{assistant_id}/history` - **Threads:** `GET /v1/threads/{thread_id}/history` - **Vector Stores:** `GET /v1/vector-stores/{store_id}/history` - **Rules:** `GET /v1/rules/{rule_id}/history` - **MCP Configurations:** `GET /v1/mcp-configurations/{config_id}/history` These endpoints automatically filter by resource type and ID. ## Use Cases ### **Compliance & Auditing** Track all changes for regulatory compliance and security audits. ### **Debugging** Understand what changed when troubleshooting issues. ### **User Activity Monitoring** Monitor user actions and identify suspicious behavior. ### **Change Rollback** Review changes before implementing rollback functionality. ## Related Resources - [Audit Log Object](/docs/api-reference/objects/audit-log-object) - [Assistant History](/docs/api-reference/assistants/history) - [Thread History](/docs/api-reference/threads/history)