> ## Documentation Index
> Fetch the complete documentation index at: https://docs.naturalead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Export Audit Logs

> Exports audit logs as a downloadable file in the specified format.
Supports the same filters as the list endpoint. The response is streamed
with a Content-Disposition header for file download.
Requires `audit:export` permission.




## OpenAPI

````yaml GET /api/audit-logs/export
openapi: 3.1.0
info:
  title: Naturalead Audit Logs API
  version: 1.0.0
  description: |
    API for querying and exporting audit logs in the Naturalead platform.
    Audit logs record all security-relevant events for SOC2 compliance,
    including authentication, authorization, data access, and configuration
    changes. All endpoints require API key authentication
    and are scoped to the caller's account.
servers:
  - url: '{baseUrl}'
    description: API server
    variables:
      baseUrl:
        default: http://localhost:3001
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: Audit Logs
    description: Audit log querying and export
paths:
  /api/audit-logs/export:
    get:
      tags:
        - Audit Logs
      summary: Export audit logs
      description: |
        Exports audit logs as a downloadable file in the specified format.
        Supports the same filters as the list endpoint. The response is streamed
        with a Content-Disposition header for file download.
        Requires `audit:export` permission.
      operationId: exportAuditLogs
      parameters:
        - name: action
          in: query
          required: false
          description: Filter by action name
          schema:
            type: string
        - name: resourceType
          in: query
          required: false
          description: Filter by resource type
          schema:
            type: string
        - name: actorType
          in: query
          required: false
          description: Filter by actor type
          schema:
            type: string
            enum:
              - user
              - api_key
        - name: actorId
          in: query
          required: false
          description: Filter by actor identifier
          schema:
            type: string
        - name: from
          in: query
          required: false
          description: Start date for the time range filter (ISO 8601)
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          description: End date for the time range filter (ISO 8601)
          schema:
            type: string
            format: date
        - name: search
          in: query
          required: false
          description: >-
            Free-text search across action, resource type, and actor display
            name
          schema:
            type: string
            minLength: 2
            maxLength: 200
        - name: format
          in: query
          required: false
          description: Export file format
          schema:
            type: string
            enum:
              - csv
              - tsv
              - jsonl
            default: csv
      responses:
        '200':
          description: Streamed file download
          headers:
            Content-Disposition:
              schema:
                type: string
              description: >-
                Attachment filename (e.g., attachment;
                filename=audit-logs-2026-03-29.csv)
          content:
            text/csv:
              schema:
                type: string
                format: binary
            text/tab-separated-values:
              schema:
                type: string
                format: binary
            application/x-ndjson:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  responses:
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: search must be between 2 and 200 characters
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Failed to process request
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        API key for programmatic access. Keys use the format `nl_live_<64 hex>`
        or `nl_test_<64 hex>` and are scoped to an account's RBAC permissions.
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        Bearer token using an API key (format: nl_live_* or nl_test_*).

````