> ## 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.

# List Audit Logs

> Returns paginated audit logs for the current account with optional
filtering by action, resource type, actor, and date range. Results
are ordered by most recent first. Requires `audit:view` permission.




## OpenAPI

````yaml GET /api/audit-logs
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:
    get:
      tags:
        - Audit Logs
      summary: List audit logs
      description: |
        Returns paginated audit logs for the current account with optional
        filtering by action, resource type, actor, and date range. Results
        are ordered by most recent first. Requires `audit:view` permission.
      operationId: listAuditLogs
      parameters:
        - name: action
          in: query
          required: false
          description: Filter by action name (e.g., "lead.created", "api_key.rotated")
          schema:
            type: string
        - name: resourceType
          in: query
          required: false
          description: Filter by resource type (e.g., "lead", "conversation", "api_key")
          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 (user ID or API key ID)
          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: skip
          in: query
          required: false
          description: Number of records to skip for pagination
          schema:
            type: integer
            default: 0
            minimum: 0
        - name: limit
          in: query
          required: false
          description: Maximum number of records to return
          schema:
            type: integer
            default: 50
            minimum: 1
            maximum: 200
      responses:
        '200':
          description: Paginated audit log results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditLogListResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    AuditLogListResponse:
      type: object
      description: Paginated audit log response.
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/AuditLog'
        total:
          type: integer
          description: Total number of matching audit log entries
        skip:
          type: integer
          description: Number of records skipped
        limit:
          type: integer
          description: Maximum records returned per page
      required:
        - data
        - total
        - skip
        - limit
    AuditLog:
      type: object
      description: A single audit log entry recording a security-relevant event.
      properties:
        _id:
          type: string
          description: Unique audit log identifier
        accountId:
          type: string
          description: Account that owns this audit log entry
        actor:
          $ref: '#/components/schemas/Actor'
        action:
          type: string
          description: >-
            Action performed (e.g., lead.created, api_key.rotated,
            conversation.started)
        resource:
          $ref: '#/components/schemas/Resource'
        metadata:
          type: object
          additionalProperties: true
          description: Additional context about the action (varies by action type)
        timestamp:
          type: string
          format: date-time
          description: When the action occurred
      required:
        - _id
        - accountId
        - actor
        - action
        - resource
        - timestamp
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    Actor:
      type: object
      description: The entity that performed the audited action.
      properties:
        type:
          type: string
          enum:
            - user
            - api_key
          description: Type of actor
        id:
          type: string
          description: Actor identifier (user ID or API key ID)
        ip:
          type: string
          description: IP address of the actor at the time of the action
        displayName:
          type: string
          description: Human-readable name of the actor (if available)
      required:
        - type
        - id
        - ip
    Resource:
      type: object
      description: The resource that was affected by the audited action.
      properties:
        type:
          type: string
          description: Resource type (e.g., "lead", "conversation", "api_key", "campaign")
        id:
          type: string
          description: Resource identifier
      required:
        - type
        - id
  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
  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_*).

````