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

# Delete Event

> Soft deletes an event by setting deletedAt and deletedBy timestamps.
The event will no longer be returned in list or get operations.

**Financial Transaction Protection:**
By default, events with paid or processing financial transactions cannot be deleted.
This protects financial data integrity. If you need to delete such an event,
set `force: true` in the request body.

**⚠️ WARNING:** Using `force: true` will orphan the associated financial records.
Only use this option if you understand the implications.

**Required fields in request body:**
- `type` - Event type (required for permission resolution)

**Optional fields:**
- `force` - Set to `true` to delete events with paid/processing transactions (use with caution)

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




## OpenAPI

````yaml /openapi/generated-external-api.yaml delete /api/external/companies/{companyId}/events/{eventId}
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}:
    delete:
      tags:
        - Events
      summary: Delete Event
      description: >
        Soft deletes an event by setting deletedAt and deletedBy timestamps.

        The event will no longer be returned in list or get operations.


        **Financial Transaction Protection:**

        By default, events with paid or processing financial transactions cannot
        be deleted.

        This protects financial data integrity. If you need to delete such an
        event,

        set `force: true` in the request body.


        **⚠️ WARNING:** Using `force: true` will orphan the associated financial
        records.

        Only use this option if you understand the implications.


        **Required fields in request body:**

        - `type` - Event type (required for permission resolution)


        **Optional fields:**

        - `force` - Set to `true` to delete events with paid/processing
        transactions (use with caution)


        **Required permission:** `company.claim:delete` or
        `company.incident:delete` (depending on type)
      operationId: deleteEvent
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/eventId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteEventRequest'
            examples:
              deleteClaim:
                summary: Delete a claim
                value:
                  type: claim
              deleteIncident:
                summary: Delete an incident
                value:
                  type: incident
              forceDeleteWithFinancials:
                summary: >-
                  Force delete event with financial transactions (use with
                  caution)
                value:
                  requestorEmail: user@example.com
                  type: claim
                  force: true
      responses:
        '200':
          description: Event deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the deleted event
                  deleted:
                    type: boolean
                    description: Confirmation that the event was deleted
              examples:
                success:
                  summary: Event deleted
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440001
                    deleted: true
        '400':
          description: Bad Request - Validation error or event has financial transactions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingType:
                  summary: Missing required type field
                  value:
                    error:
                      code: KeyMissing
                      message: 'type: Required keys were missing'
                      details:
                        - field: type
                          message: Required keys were missing
                hasFinancialTransactions:
                  summary: Event has paid/processing financial transactions
                  value:
                    error:
                      code: ActionError
                      message: >-
                        Unable to delete event because it has 2 paid or
                        processing financial transaction(s). To delete anyway,
                        set "force": true in the request body. WARNING: Force
                        deleting will orphan these financial records.
        '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:
    DeleteEventRequest:
      type: object
      required:
        - type
      properties:
        type:
          $ref: '#/components/schemas/EventType'
        force:
          type: boolean
          description: >
            If true, allows deletion even when the event has paid or processing
            financial transactions.

            **WARNING:** Force deleting will orphan these financial records. Use
            with caution.
    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.

````