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

# Calculate Balances API

> Recompute Breezing token balances across wallets and dates to refresh aggregated holdings and fiat values for crypto accounting.



## OpenAPI

````yaml POST /balances/calculate
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:
  /balances/calculate:
    post:
      tags:
        - Balances
      summary: Recompute balances
      description: >-
        Recompute the daily-snapshot balances table from the current transaction
        state. Long-running background job that deletes the existing snapshots
        for the scope (one wallet or all wallets), then walks the transactions
        to rebuild them. Returns immediately once the jobs are queued; poll GET
        /tasks for `operation: "calculateBalances"` (or `operation:
        "deleteBalances"` while the previous snapshot is being cleared) to
        monitor progress.


        **Duplicate-run protection:** if a `calculateBalances` or
        `deleteBalances` task is already in `pending` or `progress` status for
        this company, this endpoint returns 409 CONFLICT regardless of which
        wallet was specified. Running two recomputes in parallel can corrupt the
        snapshot. Always call GET /tasks first.
      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/CalculateBalancesBody'
      responses:
        '200':
          description: Recompute queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      started:
                        type: boolean
                        enum:
                          - true
                      scope:
                        type: string
                        enum:
                          - wallet
                          - all_wallets
                        description: What this run is recomputing.
                      note:
                        type: string
                    required:
                      - started
                      - scope
                      - note
                required:
                  - success
                  - data
        '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
        '409':
          description: A balances recompute is already running for this company
          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:
    CalculateBalancesBody:
      type: object
      properties:
        walletId:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          description: >-
            Optional wallet ID. When provided, recompute balances only for that
            wallet. Omit to recompute balances for ALL wallets in the company.

````