> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bookeeping.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a Paid Invoice

> Only invoices in paid status can be cancelled. Invoices paid through Stripe must be refunded in Stripe first. Use action PLAN to preview what happens to the payment transaction without cancelling, then action CANCEL to cancel.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/invoices/{id}/cancel-paid-invoice
openapi: 3.0.3
info:
  title: Bookeeping.ai API
  version: 1.0.0
  description: API for accessing and managing bookkeeping.ai data.
servers:
  - url: https://api.bookeeping.ai/public-api
    description: USA Virginia Region
  - url: https://ca-api.bookeeping.ai/public-api
    description: Canada Toronto Region
  - url: https://eu-api.bookeeping.ai/public-api
    description: EU Belgium Region
security:
  - BearerAuth: []
paths:
  /v1/invoices/{id}/cancel-paid-invoice:
    post:
      tags:
        - Invoices
      summary: Cancel a Paid Invoice
      description: >-
        Only invoices in paid status can be cancelled. Invoices paid through
        Stripe must be refunded in Stripe first. Use action PLAN to preview what
        happens to the payment transaction without cancelling, then action
        CANCEL to cancel.
      operationId: cancelPaidInvoice
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            The id of the invoice. Expected to be a valid object id like
            666666666666666666666666
          schema:
            type: string
            pattern: ^[0-9A-Fa-f]{24}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                actionData:
                  anyOf:
                    - type: object
                      properties:
                        action:
                          type: string
                          enum:
                            - PLAN
                        data:
                          type: object
                          properties: {}
                          additionalProperties: false
                      required:
                        - action
                        - data
                      additionalProperties: false
                    - type: object
                      properties:
                        action:
                          type: string
                          enum:
                            - CANCEL
                        data:
                          type: object
                          properties:
                            cancellationReason:
                              type: string
                              minLength: 1
                              description: The reason for cancellation
                          required:
                            - cancellationReason
                          additionalProperties: false
                      required:
                        - action
                        - data
                      additionalProperties: false
              required:
                - actionData
              additionalProperties: false
      responses:
        '200':
          description: Cancel a Paid Invoice executed successfully
          headers:
            x-rate-limiter-daily-limit:
              description: Maximum number of requests allowed per day
              schema:
                type: integer
                example: 1500
            x-rate-limiter-minutely-limit:
              description: Maximum number of requests allowed per minute
              schema:
                type: integer
                example: 25
            x-rate-limiter-daily-usage:
              description: Number of requests made today
              schema:
                type: integer
                example: 106
            x-rate-limiter-minutely-usage:
              description: Number of requests made in the current minute
              schema:
                type: integer
                example: 1
            x-rate-limiter-operation-type:
              description: Operation type. Either read or write.
              schema:
                type: string
                enum:
                  - read
                  - write
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Success message
                  metaData:
                    type: object
                    properties:
                      warnings:
                        type: array
                        items:
                          type: string
                        description: Any validation warnings
                  data:
                    type: object
                    properties:
                      plan:
                        type: object
                        properties:
                          transaction:
                            type: object
                            properties:
                              _id:
                                type: string
                                description: The id of the payment transaction
                              action:
                                type: string
                                enum:
                                  - SOFT_DELETE
                                  - UNLINK
                                description: >-
                                  SOFT_DELETE if the transaction was created by
                                  the invoice, UNLINK if it was attached to the
                                  invoice
                            required:
                              - _id
                              - action
                            additionalProperties: false
                            nullable: true
                            description: >-
                              The payment transaction affected by the
                              cancellation
                          blockers:
                            type: array
                            items:
                              type: string
                            description: >-
                              Reasons the invoice can't be cancelled right now.
                              If this has any items, the invoice can't be
                              cancelled right now, this tells the exact reason
                              why.
                        required:
                          - transaction
                          - blockers
                        additionalProperties: false
                      invoice:
                        type: object
                        properties:
                          _id:
                            type: string
                            description: The id of the invoice
                          projectId:
                            type: string
                            description: The id of the project
                          status:
                            type: string
                            enum:
                              - DRAFT
                              - SENT
                              - PAID
                              - OVERDUE
                              - CANCELLED
                              - ESTIMATE_SENT
                              - ESTIMATE_ACCEPTED
                              - ESTIMATE_REJECTED
                            description: The status of the invoice
                          invoiceId:
                            type: string
                            description: The number of the invoice eg. 0001, 0002, etc.
                          purchaseOrderId:
                            type: string
                            nullable: true
                            description: The id of the purchase order
                          counterParty:
                            type: object
                            properties:
                              _id:
                                type: string
                                description: The id of the counterparty
                              accountName:
                                type: string
                                nullable: true
                                description: The account name of the counterparty
                              accountNumber:
                                type: string
                                nullable: true
                                description: The account number of the counterparty
                              email:
                                type: string
                                format: email
                                nullable: true
                                description: The email of the counterparty
                              phone:
                                type: string
                                nullable: true
                                description: The phone of the counterparty
                              type:
                                type: string
                                enum:
                                  - customer
                                  - vendor
                                  - both
                                nullable: true
                                description: The type of the counterparty
                              otherEmails:
                                type: array
                                items:
                                  type: string
                                  format: email
                                nullable: true
                                description: The other emails of the counterparty
                              address:
                                type: object
                                properties:
                                  city:
                                    type: string
                                    nullable: true
                                  country:
                                    type: string
                                    nullable: true
                                  state:
                                    type: string
                                    nullable: true
                                  cca2:
                                    type: string
                                    nullable: true
                                  line1:
                                    type: string
                                    nullable: true
                                  line2:
                                    type: string
                                    nullable: true
                                  postalCode:
                                    type: string
                                    nullable: true
                                additionalProperties: false
                                nullable: true
                                description: The address of the counterparty
                            required:
                              - _id
                            additionalProperties: false
                            nullable: true
                            description: The counterparty of the invoice
                          discount:
                            type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - PERCENTAGE
                                  - FIXED
                              value:
                                type: number
                            required:
                              - type
                              - value
                            additionalProperties: false
                            description: >-
                              Global discount, after applying the line item
                              discounts
                          amount:
                            type: number
                            description: The amount of the invoice
                          convertedAmount:
                            type: number
                            nullable: true
                            description: The converted amount of the invoice
                          convertedCurrency:
                            type: string
                            nullable: true
                            description: The converted currency of the invoice
                          sendDate:
                            type: string
                            format: date-time
                            nullable: true
                            description: The date of the sending
                          sendBy:
                            type: string
                            nullable: true
                            description: The user who sent the invoice
                          invoiceDate:
                            type: string
                            format: date-time
                            description: The date of the invoice
                          dueDate:
                            type: string
                            format: date-time
                            description: The date of the due date
                          currency:
                            type: string
                            description: The currency of the invoice
                          lineItems:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: string
                                name:
                                  type: string
                                description:
                                  type: string
                                quantity:
                                  type: number
                                unitPrice:
                                  type: number
                                tax:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - PERCENTAGE
                                        - FIXED
                                    value:
                                      type: number
                                  required:
                                    - type
                                    - value
                                  additionalProperties: false
                                discount:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - PERCENTAGE
                                        - FIXED
                                    value:
                                      type: number
                                  required:
                                    - type
                                    - value
                                  additionalProperties: false
                              required:
                                - id
                                - name
                                - quantity
                                - unitPrice
                                - tax
                                - discount
                              additionalProperties: false
                            description: The line items of the invoice
                          note:
                            type: string
                            description: The notes of the invoice
                          calculated:
                            type: object
                            properties:
                              grandTotal:
                                type: number
                                description: The grand total of the invoice
                              tax:
                                type: number
                                description: The tax of the invoice
                              discount:
                                type: number
                                description: The discount of the invoice
                              subTotal:
                                type: number
                                description: The sub total of the invoice
                            required:
                              - grandTotal
                              - tax
                              - discount
                              - subTotal
                            additionalProperties: false
                          cancellationReason:
                            type: string
                            nullable: true
                            description: The reason of the cancellation
                          cancellationDate:
                            type: string
                            format: date-time
                            nullable: true
                            description: The date of the cancellation
                          cancellationBy:
                            type: string
                            nullable: true
                            description: The user who cancelled the invoice
                          paidMarkedBy:
                            type: string
                            nullable: true
                            description: The user who marked the invoice as paid
                          paidMarkedDate:
                            type: string
                            format: date-time
                            nullable: true
                            description: The date of the payment
                          attachedTransactionId:
                            type: string
                            nullable: true
                            description: The id of the transaction attached to the invoice
                          attachments:
                            type: array
                            items:
                              type: string
                            description: The attachments of the invoice
                          payViaStripeAccountConnectionId:
                            type: string
                            pattern: ^[0-9A-Fa-f]{24}$
                            description: >-
                              The id of the pay via stripe account connection.
                              Expected to be a valid object id like
                              666666666666666666666666
                            nullable: true
                          createdAt:
                            type: string
                            format: date-time
                            description: The date of the creation
                          updatedAt:
                            type: string
                            format: date-time
                            description: The date of the last update
                        required:
                          - _id
                          - projectId
                          - status
                          - invoiceId
                          - discount
                          - amount
                          - invoiceDate
                          - dueDate
                          - currency
                          - lineItems
                          - note
                          - calculated
                          - attachments
                          - createdAt
                          - updatedAt
                        additionalProperties: false
                        nullable: true
                        description: The cancelled invoice, null for action PLAN
                    required:
                      - plan
                      - invoice
                    additionalProperties: false
        '400':
          description: Bad Request - Invalid input parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    enum:
                      - BadRequestError
                  message:
                    type: string
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    enum:
                      - UnauthorizedError
                  message:
                    type: string
        '409':
          description: Conflict - Resource already exists
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    enum:
                      - ConflictError
                  message:
                    type: string
        '429':
          description: >-
            Too Many Requests - Rate limit exceeded. Either daily or minutely
            limit exceeded. If you have any questions, please contact
            support@bookeeping.ai.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    enum:
                      - TooManyRequestsError
                  message:
                    type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
      security:
        - BearerAuth: []
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API key for authentication. Get your key from the Dashboard > Settings >
        API Access.

````