> ## 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 Gain/Loss Journal API

> Book a manual journal in Xero with only the net gain/loss lines of a Breezing transaction, using the company's gain and loss account mappings.



## OpenAPI

````yaml POST /xero/ngl
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/ngl:
    post:
      tags:
        - Xero
      summary: Submit a net gain/loss journal to Xero
      description: >-
        Book a manual journal in Xero for ONE transaction containing ONLY net
        gain/loss lines: the journal is built from the transaction with its main
        fiat amount zeroed and its net set to `nglAmount`, booked between the
        company's net gain/loss account mapping and the token's asset account.
        Both mappings must be configured or the call fails with 400. The journal
        is created as DRAFT, or POSTED when the company setting "Sync journals
        as posted" (`xeroSyncJournalsAsPosted`) is enabled. On success the
        transaction's `lastSync` and `xeroSyncId` are updated.


        **OVERWRITE WARNING**: the journal is pushed with the transaction's
        existing `xeroSyncId`. If the transaction was already journal-synced via
        POST /xero/sync, this REPLACES that journal's lines with the NGL-only
        lines (same behavior as the dashboard). Use it on transactions whose
        full journal you do not need, or re-run POST /xero/sync afterwards to
        restore the full journal (which conversely drops the NGL-only lines).


        **Overpayment recipe** (what the dashboard does when a received amount
        exceeds the invoice's amountDue): book the difference with this
        endpoint, then book the invoice payment for the remaining amount with
        POST /xero/payments (invoiceId + invoiceAmount).


        Synchronous and not gated against concurrent runs. Re-running with an
        unchanged nglAmount updates the same journal in place rather than
        creating a new one (the journal id is stable while `xeroSyncId` is set;
        a run that follows a cleared `xeroSyncId` creates a fresh journal).
      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/XeroSubmitNglBody'
      responses:
        '200':
          description: Net gain/loss journal 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 whose net gain/loss was submitted.
                      synced:
                        type: boolean
                        enum:
                          - true
                        description: >-
                          The journal was accepted by Xero. Read the transaction
                          to see the updated lastSync/xeroSyncId.
                    required:
                      - id
                      - synced
                required:
                  - success
                  - data
        '400':
          description: >-
            Xero not linked, missing net gain/loss or asset account mapping, or
            Xero rejected the journal
          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:
    XeroSubmitNglBody:
      type: object
      properties:
        id:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          description: >-
            Breezing transaction ID whose net gain/loss to book. This is the
            database id from GET /transactions, not the blockchain hash.
        nglAmount:
          type: string
          pattern: ^\d+(\.\d+)?$
          description: >-
            Net gain/loss amount to book, as a positive decimal string. Journal
            lines under 0.01 are skipped, so an amount below 0.01 books nothing.
      required:
        - id
        - nglAmount

````