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

# Submit Xero Payment API

> Book a payment in Xero for a Breezing transaction, either against an outstanding invoice or as a standalone spend or receive money entry.



## OpenAPI

````yaml POST /xero/payments
openapi: 3.1.0
info:
  title: Breezing Public API
  version: 1.0.0
  description: >-
    Crypto accounting API for programmatic access and AI agents. Authenticate
    with an API key using the Authorization header: `Bearer brz_...`
servers:
  - url: https://api.breezing.io/v1
security:
  - BearerAuth: []
paths:
  /xero/payments:
    post:
      tags:
        - Xero
      summary: Submit payment on Xero
      description: >-
        Replicates the dashboard's "Submit payment on Xero" action for a single
        transaction. Two modes:


        1. **With `invoiceId`**: applies a reconciled payment in Xero against
        that outstanding invoice, paid from the bank account mapped to the
        transaction's token. The payment amount is `invoiceAmount`, capped at
        the invoice's `amountDue`.

        2. **Without `invoiceId`**: creates a standalone spend/receive money
        bank transaction for `invoiceAmount`, using the transaction's `account`
        as the line item account (400 if the transaction has no account set).


        In both modes, a transaction fee (`feeFiat` >= 0.01) is additionally
        booked as a separate spend bank transaction against
        `companies.feeAccount`, and a net gain/loss (`net` >= 0.01) is booked
        against the company's net gain/loss account. These extra legs require
        the mapped token account to be of type BANK in Xero and the
        corresponding company account mappings to be set.


        **Prerequisites**: Xero linked; the transaction's token must resolve to
        a Xero account (the transaction's `assetAccount`, or the asset's account
        mapping for that token). When using `invoiceId`, call POST
        /xero/invoices/refresh first: the id is validated against the cached
        invoice list and a stale `amountDue` changes the cap.


        **Side effects**: entries are created in Xero (reference
        `[BREEZING:<id>]<transactionId>`), payment rows are recorded in
        Breezing, the cached invoice list is refreshed, and the transaction's
        `status` is set to "paid".


        **NOT idempotent**: submitting the same transaction again creates
        additional entries in Xero. Call GET /xero/payments with this trxId
        first to see what was already booked (the transaction's `status` being
        "paid" is a weaker signal: it flips on any submission and does not list
        the individual entries).
      parameters:
        - schema:
            type: string
            description: >-
              Organization ID. Use GET /v1/companies to discover available
              org/company pairs.
            example: '1'
          required: true
          description: >-
            Organization ID. Use GET /v1/companies to discover available
            org/company pairs.
          name: orgId
          in: query
        - schema:
            type: string
            description: >-
              Company ID. Use GET /v1/companies to discover available companies
              and their access levels.
            example: '1'
          required: true
          description: >-
            Company ID. Use GET /v1/companies to discover available companies
            and their access levels.
          name: companyId
          in: query
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/XeroSubmitPaymentBody'
      responses:
        '200':
          description: Payment submitted to Xero
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Transaction ID that was submitted.
                      status:
                        type: string
                        enum:
                          - paid
                        description: Breezing transaction status after submission.
                    required:
                      - id
                      - status
                required:
                  - success
                  - data
        '400':
          description: >-
            Xero not linked, unknown invoiceId, or Xero rejected the entries
            (e.g. missing account mapping)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '403':
          description: >-
            API key has no access to this company, has read-only access where
            write was required, or the company subscription is inactive
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '404':
          description: Transaction not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '409':
          description: Transaction is locked or currently processing
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
      security:
        - BearerAuth: []
components:
  schemas:
    XeroSubmitPaymentBody:
      type: object
      properties:
        id:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          description: >-
            Breezing transaction ID to submit. This is the database id from GET
            /transactions, not the blockchain hash.
        invoiceId:
          type: string
          minLength: 1
          description: >-
            Xero invoice ID (InvoiceID) to apply the payment to. Must be one of
            the ids returned by POST /xero/invoices/refresh. Omit to book a
            standalone spend/receive money bank transaction instead.
        invoiceAmount:
          type: string
          pattern: ^\d+(\.\d+)?$
          description: >-
            Fiat amount to book, as a positive decimal string. With invoiceId,
            the payment applied in Xero is capped at the invoice amountDue.
            Without invoiceId, this is the amount of the standalone bank
            transaction. Legs under 0.01 are skipped.
      required:
        - id
        - invoiceAmount

````