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

# Ungroup Trades API

> Ungroup Breezing trades through the API, turning every leg of a linked trade back into a plain transaction, the reverse of the group trades action.



## OpenAPI

````yaml POST /transactions/ungroup-trades
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:
  /transactions/ungroup-trades:
    post:
      tags:
        - Transactions
      summary: Ungroup trades
      description: >-
        Dissolve one or more trades back into plain transactions, the API
        equivalent of "Ungroup" in the dashboard and the reverse of POST
        /transactions/group-trades. Pass the transaction id of ANY leg: the
        whole trade it belongs to is resolved via its exchangeId and every leg
        reverts to a plain row (type="transaction", exchangeId=null). The legs
        themselves are not deleted or altered otherwise; a trade that was
        consolidated from more than two legs stays as its two synthesized rows,
        they simply stop being linked as a trade.


        Returns 404 if any transaction is not found, 400 NOT_A_TRADE if any id
        is not part of a trade (null exchangeId; this includes ids whose trade
        was already ungrouped, so a retry after success reports NOT_A_TRADE
        rather than succeeding twice), and 409 if ANY leg of a resolved trade is
        locked or currently processing, including legs you did not pass (a
        partial ungroup would corrupt the pair, so the whole trade must be
        mutable). Duplicate IDs are deduplicated server-side.


        Balances, cost basis and net gain/loss are NOT recomputed automatically;
        run POST /ngl/calculate when ready.
      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/UngroupTradesBody'
      responses:
        '200':
          description: Trades dissolved
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      ungroupedTrades:
                        type: integer
                        description: Number of distinct trades that were dissolved.
                      updated:
                        type: integer
                        description: >-
                          Number of transaction rows updated (every leg of each
                          dissolved trade reverts to a plain transaction:
                          type="transaction", exchangeId=null).
                      dedupedFrom:
                        type: integer
                        description: >-
                          Original input length when duplicate IDs were deduped
                          server-side. Omitted when the input had no duplicates.
                    required:
                      - ungroupedTrades
                      - updated
                required:
                  - success
                  - data
        '400':
          description: Bad request, including NOT_A_TRADE when an id is not part of a trade
          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: One or more transactions were 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: >-
            One or more legs of a resolved trade are 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:
    UngroupTradesBody:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
          minItems: 1
          maxItems: 500
          description: >-
            Transaction IDs of trade legs to ungroup (max 500). Every id must
            belong to a trade (non-null exchangeId); passing either leg
            dissolves the whole trade, so one leg per trade is enough. Duplicate
            IDs, and ids resolving to the same trade, are handled server-side.
      required:
        - ids

````

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