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

# List Events

> Returns a paginated list of events (claims and incidents) for the company.

Events represent insurance claims and incidents. Each event includes:
- Basic event information (type, status, reference ID)
- Associated policy and insured references
- Custom entity data specific to your company's configuration

The `data` field contains custom entity data with **field keys** (not field IDs) mapped to values.
Returns `null` when no custom data exists for the event.

**Required permission:** `company.claim:read` or `company.incident:read` (depending on event type filter)




## OpenAPI

````yaml /openapi/generated-external-api.yaml get /api/external/companies/{companyId}/events
openapi: 3.0.3
info:
  title: AI Insurance External API
  description: External API for AI Insurance platform
  version: 1.0.0
  contact:
    email: support@aiinsurance.io
servers:
  - url: https://app.aiinsurance.io
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/external/companies/{companyId}/events:
    get:
      tags:
        - Events
      summary: List Events
      description: >
        Returns a paginated list of events (claims and incidents) for the
        company.


        Events represent insurance claims and incidents. Each event includes:

        - Basic event information (type, status, reference ID)

        - Associated policy and insured references

        - Custom entity data specific to your company's configuration


        The `data` field contains custom entity data with **field keys** (not
        field IDs) mapped to values.

        Returns `null` when no custom data exists for the event.


        **Required permission:** `company.claim:read` or `company.incident:read`
        (depending on event type filter)
      operationId: listEvents
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/eventType'
        - $ref: '#/components/parameters/eventStatus'
        - $ref: '#/components/parameters/policyId'
        - $ref: '#/components/parameters/filterText'
        - $ref: '#/components/parameters/eventSortBy'
        - $ref: '#/components/parameters/sortDirection'
        - $ref: '#/components/parameters/page'
      responses:
        '200':
          description: Paginated list of events
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Event'
                  totalCount:
                    type: integer
                    description: Total number of matching events across all pages
              examples:
                success:
                  summary: Events with custom data
                  value:
                    items:
                      - id: 550e8400-e29b-41d4-a716-446655440001
                        companyId: 550e8400-e29b-41d4-a716-446655440000
                        type: claim
                        status: open
                        referenceId: CLM-2025-001
                        coverageTypeId: general_liability
                        policyId: 550e8400-e29b-41d4-a716-446655440100
                        insuredIds:
                          - 550e8400-e29b-41d4-a716-446655440200
                          - 550e8400-e29b-41d4-a716-446655440201
                        createdAt: '2025-01-15T10:30:00.000Z'
                        createdBy: google-oauth2|123456789
                        updatedAt: '2025-01-16T14:20:00.000Z'
                        data:
                          eventDescription: Vehicle accident at intersection
                          claimAmount: '50000'
                          dateOfLoss: '2025-01-10'
                      - id: 550e8400-e29b-41d4-a716-446655440002
                        companyId: 550e8400-e29b-41d4-a716-446655440000
                        type: incident
                        status: closed
                        referenceId: INC-2025-002
                        coverageTypeId: property_damage
                        policyId: 550e8400-e29b-41d4-a716-446655440101
                        insuredIds:
                          - 550e8400-e29b-41d4-a716-446655440202
                        createdAt: '2025-01-10T08:00:00.000Z'
                        createdBy: google-oauth2|987654321
                        updatedAt: '2025-01-12T16:00:00.000Z'
                        data: null
                    totalCount: 42
        '400':
          description: Bad Request - Invalid query parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidType:
                  summary: Invalid event type
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: 'type must be one of: claim, incident'
                invalidStatus:
                  summary: Invalid status
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: 'status must be one of: open, closed'
                invalidPolicyId:
                  summary: Invalid policy ID
                  value:
                    error:
                      code: NotUUID
                      message: 'policyId: Value is not a valid UUID'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    eventType:
      name: type
      in: query
      schema:
        oneOf:
          - $ref: '#/components/schemas/EventType'
          - type: array
            items:
              $ref: '#/components/schemas/EventType'
      description: Filter by event type (claim, incident, or both)
    eventStatus:
      name: status
      in: query
      schema:
        oneOf:
          - $ref: '#/components/schemas/EventStatus'
          - type: array
            items:
              $ref: '#/components/schemas/EventStatus'
      description: Filter by event status (open, closed, or both)
    policyId:
      name: policyId
      in: query
      schema:
        type: string
        format: uuid
      description: Filter by policy ID
    filterText:
      name: filterText
      in: query
      schema:
        type: string
      description: Search across quote number, description, and other text fields
    eventSortBy:
      name: sortBy
      in: query
      schema:
        type: string
        enum:
          - createdAt
          - updatedAt
          - referenceId
        default: createdAt
      description: Field to sort by (default createdAt)
    sortDirection:
      name: sortDirection
      in: query
      schema:
        type: string
        enum:
          - asc
          - desc
        default: desc
      description: Sort direction (default desc)
    page:
      name: page
      in: query
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number (1-based, default 1, page size 50)
  schemas:
    Event:
      type: object
      description: An event (claim or incident) in the system
      properties:
        id:
          type: string
          format: uuid
          description: Event identifier
        companyId:
          type: string
          format: uuid
          description: Company identifier
        type:
          $ref: '#/components/schemas/EventType'
        status:
          $ref: '#/components/schemas/EventStatus'
        referenceId:
          type: string
          description: Human-readable reference ID for the event
          example: CLM-2025-001
        coverageTypeId:
          type: string
          description: Coverage type identifier for this event
          example: general_liability
        lawsuitId:
          type: string
          format: uuid
          nullable: true
          description: Associated lawsuit ID (null if no lawsuit exists for this event)
        policyId:
          type: string
          format: uuid
          nullable: true
          description: Associated policy ID (null if not linked to a policy)
        insuredIds:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of insureds associated with this event
        createdAt:
          type: string
          format: date-time
          description: When the event was created (ISO 8601)
        createdBy:
          type: string
          nullable: true
          description: User ID who created the event (null if not tracked)
        updatedAt:
          type: string
          format: date-time
          nullable: true
          description: When the event was last updated (ISO 8601), or null if never updated
        data:
          type: object
          additionalProperties:
            type: string
          nullable: true
          description: >-
            Custom entity data with field keys mapped to values. Returns null
            when no custom data exists.
          example:
            eventDescription: Vehicle accident at intersection
            claimAmount: '50000'
            dateOfLoss: '2025-01-10'
    ErrorResponse:
      type: object
      description: Standard error response for all external API endpoints
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code
              example: VALIDATION_ERROR
            message:
              type: string
              description: Human-readable error message
              example: 'submissionId: Required field is missing'
            details:
              type: array
              description: Additional details for validation errors (field-level errors)
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: The field that caused the error
                    example: submissionId
                  message:
                    type: string
                    description: Description of the field error
                    example: Required field is missing
    EventType:
      type: string
      description: Type of event (claim or incident)
      enum:
        - claim
        - incident
    EventStatus:
      type: string
      description: Status of the event
      enum:
        - open
        - closed
  responses:
    Unauthorized:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingApiKey:
              summary: Missing API key
              value:
                error:
                  code: UNAUTHORIZED
                  message: Authorization header is required
            bearerTokenNotAllowed:
              summary: Bearer token used instead of API key
              value:
                error:
                  code: UNAUTHORIZED
                  message: External API endpoints require API key authentication
    Forbidden:
      description: Forbidden - Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            insufficientPermissions:
              summary: Insufficient permissions
              value:
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to perform this action
    InternalServerError:
      description: Internal Server Error - Unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internalError:
              summary: Unexpected server error
              value:
                error:
                  code: INTERNAL_ERROR
                  message: An unexpected error occurred. Please try again later.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Include your API key in the Authorization
        header.

````