Docs/API Reference/Audit Logs

Audit Log API

Query and export admin audit logs with filtering, pagination, and CSV export for compliance reporting.

Endpoints

GET/v1/admin/audit-logsQuery audit logs (paginated, filtered)
GET/v1/admin/audit-logs/exportExport audit logs as CSV

Authentication

Both endpoints require API key authentication. Admin-level rate limiting is enforced.

Query Audit Logs

GET/v1/admin/audit-logs

Returns paginated admin audit logs with optional filters. Response includes aggregate stats and metadata about available filter values.

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber25Results per page (max 100)
actionstringFilter by action type (e.g., POLICY_REVIEW_RESOLVED)
user_idstringFilter by admin user ID
resource_typestringFilter by resource type (e.g., policy, agent, api_key)
date_fromstringStart date (ISO 8601 format)
date_tostringEnd date (ISO 8601 format)
searchstringFull-text search across log details

Response Fields

FieldTypeDescription
logsarrayArray of audit log entries
paginationobjectPage, limit, total, and total_pages
statsobjectAggregate statistics for the filtered results
meta.actionsstring[]Available action types for filtering
meta.resource_typesstring[]Available resource types for filtering

Example

bash
curl "https://api.tork.network/v1/admin/audit-logs?action=POLICY_REVIEW_RESOLVED&limit=5&date_from=2026-02-01" \
  -H "x-tork-api-key: tork_sk_your_api_key"
json
{
  "logs": [
    {
      "id": "log_x1y2z3",
      "action": "POLICY_REVIEW_RESOLVED",
      "user_id": "usr_abc",
      "user_email": "admin@example.com",
      "resource_type": "policy_review",
      "resource_id": "rev_a1b2c3",
      "details": {
        "resolution": "policy_updated",
        "severity": "critical"
      },
      "ip_address": "203.0.113.50",
      "created_at": "2026-02-12T15:30:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 5,
    "total": 12,
    "total_pages": 3
  },
  "stats": {
    "total_actions": 12,
    "unique_users": 3
  },
  "meta": {
    "actions": ["POLICY_REVIEW_RESOLVED", "EMERGENCY_SHUTDOWN_ACTIVATED", "NOTIFICATION_ROUTING_UPDATED"],
    "resource_types": ["policy_review", "emergency_shutdown", "notification_routing"]
  }
}

Export Audit Logs

GET/v1/admin/audit-logs/export

Exports audit logs as a CSV file. Supports the same filters as the query endpoint. Returns up to 10,000 records.

Query Parameters

Same filter parameters as the query endpoint: action, user_id, resource_type, date_from, date_to, search. Pagination is fixed at page 1, limit 10,000.

Response Headers

HeaderValue
Content-Typetext/csv
Content-Dispositionattachment; filename="tork-audit-log-2026-02-12.csv"

Example

bash
curl "https://api.tork.network/v1/admin/audit-logs/export?date_from=2026-02-01" \
  -H "x-tork-api-key: tork_sk_your_api_key" \
  -o audit-log.csv
Compliance Reports
Use the export endpoint to generate audit trails for SOC 2, ISO 27001, and NIST AI RMF compliance reviews.

Error Responses

StatusDescription
401Missing or invalid API key
429Rate limit exceeded
500Internal server error