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

# Reassign a Paid Invoice's Payment

> Moves the payment of a paid invoice: the current payment is undone exactly like cancelling a paid invoice, then the invoice is marked as paid again with the new strategy. Invoices paid through Stripe must be refunded in Stripe first. Use action PLAN to preview what happens to the current payment transaction, then action REASSIGN to reassign.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/invoices/{id}/reassign-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}/reassign-paid-invoice:
    post:
      tags:
        - Invoices
      summary: Reassign a Paid Invoice's Payment
      description: >-
        Moves the payment of a paid invoice: the current payment is undone
        exactly like cancelling a paid invoice, then the invoice is marked as
        paid again with the new strategy. Invoices paid through Stripe must be
        refunded in Stripe first. Use action PLAN to preview what happens to the
        current payment transaction, then action REASSIGN to reassign.
      operationId: reassignPaidInvoice
      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:
                            - REASSIGN
                        data:
                          type: object
                          properties:
                            strategyData:
                              anyOf:
                                - type: object
                                  properties:
                                    strategy:
                                      type: string
                                      enum:
                                        - CREATE_TRANSACTION
                                    data:
                                      type: object
                                      properties:
                                        account:
                                          type: string
                                          nullable: true
                                          description: >-
                                            The id of the account where the payment
                                            will be credited
                                        counterParty:
                                          type: string
                                          nullable: true
                                          description: >-
                                            The id of the counterparty who paid the
                                            invoice
                                        transactionRefNo:
                                          type: string
                                          description: The reference number of the transaction
                                        transactionNote:
                                          type: string
                                          nullable: true
                                          description: The note of the transaction
                                        category:
                                          type: string
                                          description: >-
                                            The id of the category where the payment
                                            will be credited
                                      required:
                                        - transactionRefNo
                                        - transactionNote
                                        - category
                                      additionalProperties: false
                                  required:
                                    - strategy
                                    - data
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    strategy:
                                      type: string
                                      enum:
                                        - ATTACH_INTO_TRANSACTION
                                    data:
                                      type: object
                                      properties:
                                        transactionId:
                                          type: string
                                          description: Transaction id to attach the invoice to
                                      required:
                                        - transactionId
                                      additionalProperties: false
                                  required:
                                    - strategy
                                    - data
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    strategy:
                                      type: string
                                      enum:
                                        - JUST_MARK_AS_PAID
                                    data:
                                      type: object
                                      properties: {}
                                      additionalProperties: false
                                  required:
                                    - strategy
                                    - data
                                  additionalProperties: false
                          required:
                            - strategyData
                          additionalProperties: false
                      required:
                        - action
                        - data
                      additionalProperties: false
              required:
                - actionData
              additionalProperties: false
      responses:
        '200':
          description: Reassign a Paid Invoice's Payment 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 undoing the
                              payment
                          blockers:
                            type: array
                            items:
                              type: string
                            description: >-
                              Reasons the payment can't be undone right now. If
                              this has any items, the action can't be performed,
                              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 invoice paid with the new strategy, 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.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.