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

# Create Event

> Creates a new event (claim or incident).

**Required fields:**
- `type` - Event type (`claim` or `incident`)
- `coverageTypeId` - Coverage type identifier
- `insuredIds` - At least one insured must be associated

**Optional fields:**
- `status` - Defaults to `open` if not provided
- `policyId` - Associate with a policy
- `data` - Custom entity data as key-value pairs

**Required permission:** `company.claim:create` or `company.incident:create` (depending on type)




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /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:
    post:
      tags:
        - Events
      summary: Create Event
      description: >
        Creates a new event (claim or incident).


        **Required fields:**

        - `type` - Event type (`claim` or `incident`)

        - `coverageTypeId` - Coverage type identifier

        - `insuredIds` - At least one insured must be associated


        **Optional fields:**

        - `status` - Defaults to `open` if not provided

        - `policyId` - Associate with a policy

        - `data` - Custom entity data as key-value pairs


        **Required permission:** `company.claim:create` or
        `company.incident:create` (depending on type)
      operationId: createEvent
      parameters:
        - $ref: '#/components/parameters/companyId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEventRequest'
            examples:
              minimalClaim:
                summary: Minimal claim (required fields only)
                value:
                  type: claim
                  coverageTypeId: general_liability
                  insuredIds:
                    - 550e8400-e29b-41d4-a716-446655440200
              claimWithData:
                summary: Claim with custom data
                value:
                  type: claim
                  coverageTypeId: general_liability
                  insuredIds:
                    - 550e8400-e29b-41d4-a716-446655440200
                  policyId: 550e8400-e29b-41d4-a716-446655440100
                  data:
                    eventDescription: Vehicle accident at intersection
                    dateOfLoss: '2025-01-10'
                    claimAmount: '50000'
              incident:
                summary: Incident (no policy required)
                value:
                  type: incident
                  coverageTypeId: property_damage
                  insuredIds:
                    - 550e8400-e29b-41d4-a716-446655440201
                  status: open
      responses:
        '201':
          description: Event created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the created event
              examples:
                success:
                  summary: Event created
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440003
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingRequiredField:
                  summary: Missing required field
                  value:
                    error:
                      code: KeyMissing
                      message: 'insuredIds: Required keys were missing'
                      details:
                        - field: insuredIds
                          message: Required keys were missing
                insuredNotFound:
                  summary: Insured not found
                  value:
                    error:
                      code: NOT_FOUND
                      message: 'Insured not found: 550e8400-e29b-41d4-a716-446655440999'
                unknownFieldKey:
                  summary: Unknown field key in data
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: 'Unknown field key: invalidFieldName'
        '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
  schemas:
    CreateEventRequest:
      type: object
      required:
        - type
        - coverageTypeId
        - insuredIds
      properties:
        type:
          $ref: '#/components/schemas/EventType'
        coverageTypeId:
          type: string
          description: Coverage type identifier for this event
        insuredIds:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of insureds to associate with this event
        status:
          $ref: '#/components/schemas/EventStatus'
        lawsuitId:
          type: string
          format: uuid
          description: >-
            Optional lawsuit ID to associate with this event (must reference an
            existing lawsuit)
        policyId:
          type: string
          format: uuid
          description: Optional policy ID to associate with this event
        data:
          type: object
          additionalProperties:
            oneOf:
              - type: string
              - type: number
          description: >-
            Custom entity data fields as key-value pairs. Keys should be field
            keys (e.g., 'reportDate', 'eventDescription').
    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.

````