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

# List Audit Logs

> List audit log entries with advanced filtering and pagination.

Only superadmins can access audit logs.
PII is masked unless the user belongs to the 'pii_access' group.



## OpenAPI

````yaml get /api/v1/audit-logs/
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/audit-logs/:
    get:
      tags:
        - audit-logs
      summary: List Audit Logs
      description: |-
        List audit log entries with advanced filtering and pagination.

        Only superadmins can access audit logs.
        PII is masked unless the user belongs to the 'pii_access' group.
      operationId: list_audit_logs_api_v1_audit_logs__get
      parameters:
        - name: account_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by account ID
            title: Account Id
          description: Filter by account ID
        - name: table_name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by table name
            title: Table Name
          description: Filter by table name
        - name: record_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by record ID
            title: Record Id
          description: Filter by record ID
        - name: user_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by user ID
            title: User Id
          description: Filter by user ID
        - name: operation
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by operation (CREATE, UPDATE, DELETE)
            title: Operation
          description: Filter by operation (CREATE, UPDATE, DELETE)
        - name: from_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            description: Filter from this timestamp (ISO 8601)
            title: From Date
          description: Filter from this timestamp (ISO 8601)
        - name: to_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            description: Filter to this timestamp (ISO 8601)
            title: To Date
          description: Filter to this timestamp (ISO 8601)
        - name: skip
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            description: Number of entries to skip
            default: 0
            title: Skip
          description: Number of entries to skip
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 500
            minimum: 1
            description: Maximum number of entries to return
            default: 50
            title: Limit
          description: Maximum number of entries to return
        - name: sort_by
          in: query
          required: false
          schema:
            type: string
            description: Field to sort by
            default: occurred_at
            title: Sort By
          description: Field to sort by
        - name: sort_order
          in: query
          required: false
          schema:
            type: string
            pattern: ^(asc|desc)$
            description: Sort order (asc or desc)
            default: desc
            title: Sort Order
          description: Sort order (asc or desc)
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditLogListResponse'
        '403':
          description: Superadmin access required
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AuditLogListResponse:
      properties:
        items:
          items:
            $ref: '#/components/schemas/AuditLogResponse'
          type: array
          title: Items
          description: List of audit log entries
        total:
          type: integer
          title: Total
          description: Total number of entries matching filters
        skip:
          type: integer
          title: Skip
          description: Number of entries skipped
        limit:
          type: integer
          title: Limit
          description: Number of entries returned
        audit_logging_enabled:
          type: boolean
          title: Audit Logging Enabled
          description: Whether audit logging is currently enabled
          default: true
      type: object
      required:
        - items
        - total
        - skip
        - limit
      title: AuditLogListResponse
      description: Response for listing audit logs.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AuditLogResponse:
      properties:
        id:
          type: integer
          title: Id
          description: Unique identifier (sequence number)
        account_id:
          type: string
          title: Account Id
          description: Account context (UUID)
        operation:
          type: string
          title: Operation
          description: 'Operation type: CREATE, UPDATE, DELETE'
        table_name:
          type: string
          title: Table Name
          description: Table/collection name
        record_id:
          type: string
          title: Record Id
          description: ID of the affected record
        column_name:
          type: string
          title: Column Name
          description: Name of the changed column
        old_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Old Value
          description: Previous value
        new_value:
          anyOf:
            - type: string
            - type: 'null'
          title: New Value
          description: New value
        user_id:
          type: string
          title: User Id
          description: ID of user who made the change
        user_email:
          type: string
          title: User Email
          description: Email of user who made the change
        user_name:
          type: string
          title: User Name
          description: Name of user who made the change
        es_username:
          anyOf:
            - type: string
            - type: 'null'
          title: Es Username
          description: Electronic signature username
        es_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Es Reason
          description: Electronic signature reason
        es_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Es Timestamp
          description: Electronic signature timestamp
        ip_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Ip Address
          description: Client IP address
        user_agent:
          anyOf:
            - type: string
            - type: 'null'
          title: User Agent
          description: User agent string
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: Correlation ID
        occurred_at:
          type: string
          format: date-time
          title: Occurred At
          description: Timestamp of the change (UTC)
        checksum:
          anyOf:
            - type: string
            - type: 'null'
          title: Checksum
          description: SHA-256 hash of this entry
        previous_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Hash
          description: Checksum of the previous entry
        extra_metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Extra Metadata
          description: Additional metadata
      type: object
      required:
        - id
        - account_id
        - operation
        - table_name
        - record_id
        - column_name
        - user_id
        - user_email
        - user_name
        - occurred_at
      title: AuditLogResponse
      description: Response for a single audit log entry.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````