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

> Deletes the most recent transaction on a policy, rolling the policy back to
its prior version. Only the most recent transaction (highest `policyVersion`)
can be deleted — attempting to delete an older transaction returns a 400 error.

After deletion, the policy state reverts to what it was before the deleted
transaction was applied. If the only transaction (NEW_BUSINESS) is deleted,
the policy has no remaining transactions.

**Required permission:** `policy:delete`




## OpenAPI

````yaml /openapi/generated-external-api.yaml delete /api/v1/external/companies/{companyId}/policies/{policyId}/transactions/{transactionId}
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/v1/external/companies/{companyId}/policies/{policyId}/transactions/{transactionId}:
    delete:
      tags:
        - Field Model Policy Transactions
      summary: Delete Policy Transaction
      description: >
        Deletes the most recent transaction on a policy, rolling the policy back
        to

        its prior version. Only the most recent transaction (highest
        `policyVersion`)

        can be deleted — attempting to delete an older transaction returns a 400
        error.


        After deletion, the policy state reverts to what it was before the
        deleted

        transaction was applied. If the only transaction (NEW_BUSINESS) is
        deleted,

        the policy has no remaining transactions.


        **Required permission:** `policy:delete`
      operationId: deletePolicyTransaction
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/policyIdPath'
        - $ref: '#/components/parameters/transactionId'
      responses:
        '200':
          description: Transaction deleted successfully
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - deleted
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the deleted transaction
                  deleted:
                    type: boolean
                    description: Confirmation that the transaction was deleted
              examples:
                success:
                  summary: Transaction deleted
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440020
                    deleted: true
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notMostRecent:
                  summary: Attempted to delete a non-most-recent transaction
                  value:
                    error:
                      code: INVALID_REQUEST
                      message: >-
                        Only the most recent transaction can be deleted.
                        Transaction 550e8400-e29b-41d4-a716-446655440010 is not
                        the latest (version 2)
                noTransactions:
                  summary: Policy has no transactions
                  value:
                    error:
                      code: INVALID_REQUEST
                      message: Policy has no transactions
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Policy not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                policyNotFound:
                  summary: Policy not found
                  value:
                    error:
                      code: NOT_FOUND
                      message: Policy 550e8400-e29b-41d4-a716-446655440001 not found
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    policyIdPath:
      name: policyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Policy identifier
    transactionId:
      name: transactionId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Transaction identifier
  schemas:
    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.

````