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

# Update Expected Totals

> Updates the expected total for a transaction category on an event.

This endpoint is used to set or update reserve amounts for categories that support reserves.

**Important:** Amounts are in **dollars** (not cents) for this endpoint.

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




## OpenAPI

````yaml /openapi/generated-external-api.yaml patch /api/external/companies/{companyId}/events/{eventId}/financials/expected-totals
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/{eventId}/financials/expected-totals:
    patch:
      tags:
        - Event Financials
      summary: Update Expected Totals
      description: >
        Updates the expected total for a transaction category on an event.


        This endpoint is used to set or update reserve amounts for categories
        that support reserves.


        **Important:** Amounts are in **dollars** (not cents) for this endpoint.


        **Required permission:** `company.claim:update` or
        `company.incident:update` (depending on event type)
      operationId: updateEventExpectedTotals
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/eventId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateExpectedTotalsRequest'
            examples:
              updateIndemnityReserve:
                summary: Update indemnity reserve
                value:
                  type: claim
                  categoryId: indemnity_invoice
                  expectedTotal: 15000
              updateWithAsOfDate:
                summary: Historical update with asOfDate
                value:
                  type: claim
                  categoryId: alae_invoice
                  expectedTotal: 5000
                  asOfDate: '2025-01-01'
      responses:
        '200':
          description: Expected total updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateExpectedTotalsResponse'
              examples:
                success:
                  summary: Reserve updated
                  value:
                    eventId: 550e8400-e29b-41d4-a716-446655440001
                    categoryId: indemnity_invoice
                    expectedTotal: 15000
                    reserves: 10000
        '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: 'type: Required keys were missing'
                      details:
                        - field: type
                          message: Required keys were missing
                invalidCategory:
                  summary: Invalid category or category doesn't support reserves
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: >-
                        Category 'unknown_category' is not valid or does not
                        support reserves
                negativeAmount:
                  summary: Negative expectedTotal
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: expectedTotal must be greater than or equal to 0
                typeMismatch:
                  summary: Event type doesn't match request type
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: >-
                        Event type 'incident' does not match request type
                        'claim'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Event not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                eventNotFound:
                  summary: Event not found
                  value:
                    error:
                      code: NOT_FOUND
                      message: Event not found
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    eventId:
      name: eventId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Event identifier
  schemas:
    UpdateExpectedTotalsRequest:
      type: object
      description: Request body for updating expected totals on an event
      required:
        - type
        - categoryId
        - expectedTotal
      properties:
        type:
          $ref: '#/components/schemas/EventType'
        categoryId:
          type: string
          description: Transaction category identifier (must support reserves)
        expectedTotal:
          type: number
          minimum: 0
          description: Expected total amount in dollars (not cents)
        asOfDate:
          type: string
          format: date
          description: Historical date for the update (YYYY-MM-DD, optional)
    UpdateExpectedTotalsResponse:
      type: object
      description: Response from updating expected totals
      properties:
        eventId:
          type: string
          format: uuid
          description: Event identifier
        categoryId:
          type: string
          description: Transaction category identifier
        expectedTotal:
          type: number
          nullable: true
          description: Updated expected total in dollars (null if not found)
        reserves:
          type: number
          nullable: true
          description: Reserve amount for the category in dollars (null if not applicable)
    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
  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.

````