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

> Creates a new financial transaction for an event.

**Transaction Types:**
- **Non-itemized types** (e.g., `indemnity_invoice`): Require `amount` field, `lineItems` is forbidden
- **Itemized types** (e.g., `alae_invoice`): Require `lineItems` array, `amount` is forbidden

Use the [GET /transaction-categories](/api-reference/transaction-categories/list-transaction-categories) endpoint to see available transaction types and whether they are itemized.

**Note:** This endpoint does NOT automatically update reserves. Use [PATCH /events/{eventId}/financials/expected-totals](/api-reference/event-financials/update-expected-totals) to update reserves.

**Required permission:** `company.payment:create`




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /api/external/companies/{companyId}/events/{eventId}/financials/transactions
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/transactions:
    post:
      tags:
        - Event Financials
      summary: Create Event Transaction
      description: >
        Creates a new financial transaction for an event.


        **Transaction Types:**

        - **Non-itemized types** (e.g., `indemnity_invoice`): Require `amount`
        field, `lineItems` is forbidden

        - **Itemized types** (e.g., `alae_invoice`): Require `lineItems` array,
        `amount` is forbidden


        Use the [GET
        /transaction-categories](/api-reference/transaction-categories/list-transaction-categories)
        endpoint to see available transaction types and whether they are
        itemized.


        **Note:** This endpoint does NOT automatically update reserves. Use
        [PATCH
        /events/{eventId}/financials/expected-totals](/api-reference/event-financials/update-expected-totals)
        to update reserves.


        **Required permission:** `company.payment:create`
      operationId: createEventTransaction
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/eventId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEventTransactionRequest'
            examples:
              nonItemizedTransaction:
                summary: Non-itemized transaction (e.g., indemnity payment)
                value:
                  transactionType: indemnity_invoice
                  transactionDate: '2025-01-15'
                  amount: 500000
                  payeeId: 550e8400-e29b-41d4-a716-446655440050
                  description: Initial claim payment
                  status: owed
              paidTransaction:
                summary: Transaction marked as paid
                value:
                  transactionType: indemnity_invoice
                  transactionDate: '2025-01-15'
                  amount: 500000
                  payeeId: 550e8400-e29b-41d4-a716-446655440050
                  description: Initial claim payment
                  status: paid
                  paidDate: '2025-01-20'
              itemizedTransaction:
                summary: Itemized transaction (e.g., ALAE with line items)
                value:
                  transactionType: alae_invoice
                  transactionDate: '2025-01-18'
                  payeeId: 550e8400-e29b-41d4-a716-446655440051
                  description: Legal services
                  lineItems:
                    - categoryId: legal_fees
                      amount: 50000
                      description: Initial consultation
                    - categoryId: legal_fees
                      amount: 25000
                      description: Document review
      responses:
        '200':
          description: Transaction created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the created transaction
              examples:
                success:
                  summary: Transaction created
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440010
        '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: 'transactionType: Required keys were missing'
                      details:
                        - field: transactionType
                          message: Required keys were missing
                invalidTransactionType:
                  summary: Invalid transaction type
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: 'Invalid transaction type: unknown_type'
                itemizedRequiresLineItems:
                  summary: Itemized type requires lineItems
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: >-
                        Transaction type 'alae_invoice' requires lineItems, not
                        amount
                nonItemizedRequiresAmount:
                  summary: Non-itemized type requires amount
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: >-
                        Transaction type 'indemnity_invoice' requires amount,
                        not lineItems
                missingPaidDate:
                  summary: Missing paidDate for paid status
                  value:
                    error:
                      code: VALIDATION_ERROR
                      message: paidDate is required when status is 'paid'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Event or payee 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
                payeeNotFound:
                  summary: Payee not found
                  value:
                    error:
                      code: NOT_FOUND
                      message: Payee 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:
    CreateEventTransactionRequest:
      type: object
      description: Request body for creating an event transaction
      required:
        - transactionType
        - transactionDate
        - payeeId
      properties:
        transactionType:
          type: string
          description: >-
            Transaction category identifier (e.g., "indemnity_invoice",
            "alae_invoice")
        transactionDate:
          type: string
          format: date
          description: Transaction date (YYYY-MM-DD)
        amount:
          type: integer
          description: >-
            Transaction amount in cents (required for non-itemized transaction
            types, forbidden for itemized types)
        payeeId:
          type: string
          format: uuid
          description: >-
            ID of an existing payee. Use GET /payees to find valid IDs, or POST
            /payees to create one first.
        description:
          type: string
          description: Transaction description
        status:
          type: string
          enum:
            - owed
            - paid
            - approved
          default: owed
          description: Transaction status (default is "owed")
        paidDate:
          type: string
          format: date
          description: >-
            Date the transaction was paid (YYYY-MM-DD, required if status is
            "paid")
        dateModified:
          type: string
          format: date
          description: >-
            Optional override for the transaction's most recent modification
            date (YYYY-MM-DD). Defaults to current time if not provided.
        entryDate:
          type: string
          format: date
          description: >-
            Optional override for the transaction's entry date (YYYY-MM-DD).
            Defaults to current time if not provided.
        lineItems:
          type: array
          items:
            type: object
            required:
              - amount
            properties:
              categoryId:
                type: string
                description: >-
                  Ledger account/category ID (must be valid for the transaction
                  type)
              amount:
                type: integer
                description: Line item amount in cents
              description:
                type: string
                description: Line item description
          description: >-
            Line items for itemized transaction types (required for itemized
            types, forbidden for non-itemized)
    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.

````