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

# Set Submission Loss History

> Replaces the entire loss history on a submission. The request body
contains an array of loss history entries — any previously stored
entries are overwritten. Unknown fields are rejected with a 400 error.

For FMV1-enabled companies, setting loss history automatically
recomputes computed loss history aggregation fields on all quotes
attached to the submission.

**Required permission:** `submission:update`




## OpenAPI

````yaml /openapi/generated-external-api.yaml put /api/external/companies/{companyId}/submissions/{submissionId}/loss-history
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}/submissions/{submissionId}/loss-history:
    put:
      tags:
        - Submissions
      summary: Set Submission Loss History
      description: |
        Replaces the entire loss history on a submission. The request body
        contains an array of loss history entries — any previously stored
        entries are overwritten. Unknown fields are rejected with a 400 error.

        For FMV1-enabled companies, setting loss history automatically
        recomputes computed loss history aggregation fields on all quotes
        attached to the submission.

        **Required permission:** `submission:update`
      operationId: setSubmissionLossHistory
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/submissionIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - history
              properties:
                history:
                  type: array
                  description: >-
                    Loss history entries. Send an empty array to clear all loss
                    history.
                  items:
                    $ref: '#/components/schemas/LossHistoryEntry'
            examples:
              singleEntry:
                summary: Single loss history entry
                value:
                  history:
                    - year: 2022
                      data:
                        company: Acme Insurance Co
                        policyNumber: POL-2022-001
                        policyPremium: 10000
                        totalIncurred: 10000
                        indemnityPaid: 5000
                        expensesPaid: 2000
                        totalReserves: 3000
                        claimDescription: Slip and fall at insured premises
                        reportDate: '2022-06-20T00:00:00.000Z'
              clearHistory:
                summary: Clear all loss history
                value:
                  history: []
      responses:
        '200':
          description: Loss history saved successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                properties:
                  success:
                    type: boolean
                    example: true
              examples:
                success:
                  summary: Successful save
                  value:
                    success: true
        '400':
          description: Bad Request — Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidHistory:
                  summary: Missing required field
                  value:
                    error:
                      code: ValidationError
                      message: history[0].data.totalIncurred is required
                unknownField:
                  summary: Unknown field in request
                  value:
                    error:
                      code: UnknownFields
                      message: 'history[0].data: Unknown field(s): bogusField'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Submission not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notFound:
                  summary: Submission does not exist
                  value:
                    error:
                      code: NotFound
                      message: Submission not found
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    submissionIdPath:
      name: submissionId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Submission identifier
  schemas:
    LossHistoryEntry:
      type: object
      description: >-
        A single loss history entry representing a claim or loss event for a
        given policy year.
      required:
        - year
        - data
      properties:
        year:
          type: integer
          description: The policy year this loss entry belongs to.
          example: 2022
        data:
          type: object
          description: Claim/loss details for this entry.
          required:
            - totalIncurred
          properties:
            company:
              type: string
              description: Insurance company name.
              example: Acme Insurance Co
            policyNumber:
              type: string
              description: Policy number associated with this loss.
              example: POL-2022-001
            policyPremium:
              type: number
              description: Premium for the policy period.
              example: 10000
            policyEffectiveDate:
              type: string
              format: date-time
              description: Policy effective date (ISO 8601).
              example: '2022-01-01T00:00:00.000Z'
            policyExpirationDate:
              type: string
              format: date-time
              description: Policy expiration date (ISO 8601).
              example: '2023-01-01T00:00:00.000Z'
            indemnityPaid:
              type: number
              description: Indemnity amount paid.
              example: 5000
            expensesPaid:
              type: number
              description: Expenses (ALAE) paid.
              example: 2000
            totalReserves:
              type: number
              description: Total reserves.
              example: 3000
            totalIncurred:
              type: number
              description: Total incurred amount (required).
              example: 10000
            coverageType:
              type: string
              description: Type of coverage.
              example: General Liability
            claimDescription:
              type: string
              description: Description of the claim.
              example: Slip and fall at insured premises
            claimNumber:
              type: string
              description: Claim number.
              example: CLM-2022-001
            eventDate:
              type: string
              format: date-time
              description: Date the loss event occurred (ISO 8601).
              example: '2022-06-15T00:00:00.000Z'
            reportDate:
              type: string
              format: date-time
              description: Date the claim was reported (ISO 8601).
              example: '2022-06-20T00:00:00.000Z'
            indemnityReserve:
              type: number
              description: Indemnity reserve amount.
              example: 1000
            alaeReserve:
              type: number
              description: ALAE (Allocated Loss Adjustment Expense) reserve amount.
              example: 2000
    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
  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.

````