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

# Group Transactions Into Trades API

> Group Breezing transactions into trades through the API, pairing opposite buy and sell legs into linked trade pairs as the dashboard action does.



## OpenAPI

````yaml POST /transactions/group-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/group-trades:
    post:
      tags:
        - Transactions
      summary: Group transactions into trades
      description: >-
        Group a set of transactions into one or more trades, the API equivalent
        of "Group Into Multiple Trades" in the dashboard. The engine buckets the
        selected transactions by timestamp and external reference, then forms a
        trade from each qualifying group (opposite in/out legs, different
        tokens, at most two wallets, not spam, not already a trade or internal).
        A two-leg group is tagged with a shared exchangeId and type="trade";
        larger qualifying groups are consolidated into a synthetic trade pair.
        Non-qualifying transactions are left unchanged.


        Returns 404 if any transaction is not found, 409 if any is locked or
        currently processing. Duplicate IDs are deduplicated server-side.
        Because the engine decides which groups qualify, the response reports
        how many transactions were processed, not how many trades resulted.
        Inspect GET /transactions afterward (type="trade", non-null exchangeId)
        to see what was formed.
      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/GroupTradesBody'
      responses:
        '200':
          description: Transactions submitted to the grouping engine
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      processed:
                        type: integer
                        description: >-
                          Number of distinct, unlocked transactions submitted to
                          the grouping engine. Not all become trades: only
                          qualifying opposite-direction groups do. Inspect the
                          result via GET /transactions (a formed trade has
                          type="trade" and a non-null exchangeId).
                      dedupedFrom:
                        type: integer
                        description: >-
                          Original input length when duplicate IDs were deduped
                          server-side. Omitted when the input had no duplicates.
                    required:
                      - processed
                required:
                  - success
                  - data
        '400':
          description: Bad request
          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 transactions 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:
    GroupTradesBody:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
          minItems: 1
          maxItems: 500
          description: >-
            Transaction IDs to group into trades (max 500). The engine buckets
            them by timestamp and external reference, then forms a trade from
            each qualifying group. A group qualifies when the legs have opposite
            directions (one in, one out), different tokens, at most two wallets,
            and none is spam, already a trade (has an exchangeId), or internal.
            Non-qualifying transactions are left unchanged. Duplicate IDs are
            deduplicated server-side.
      required:
        - ids

````