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

# Get balance history

> Daily evolution of the account's balances for dashboard charts: one series per asset (the closing available balance of each day, carried forward on days without movements) plus an aggregated USD series that values BTC/GOLD at each day's historical reference price. Includes the period's total inflows/outflows and the current snapshot (available + held), so a front can render a Mercury-style balance card with its percentage change. The series tracks the **available** balance (holds have no history); `current` carries today's `held` per asset. Days valued with today's spot price (before historical prices exist) are disclosed in `spot_priced_dates` — values are never invented.

The `assets` map also includes the banking account mirrors (`BANK_USD`, `BANK_EUR`) as their own series in their own currency (2 decimals). They are **not** part of the `total_usd` aggregate, which only covers the operational balances (USDT, USDC, BTC, GOLD).




## OpenAPI

````yaml /openapi.yaml get /v1/balances/history
openapi: 3.1.0
info:
  title: CBPay API
  version: '1.89'
  description: |
    CBPay is a multi-currency payment platform: fiat payouts and collections
    across Latin America, internal transfers, on-chain funding and
    withdrawals, and KYC screening. Every account holds four independent
    virtual balances — USDT (the operating currency), USDC, BTC and GOLD
    (grams of fine gold) — that never mix or convert automatically.
    Payouts and service fees can be paid from any of the four balances:
    set a default with `PUT /v1/settlement` or override per payout with
    `settlement_asset`.

    All amounts are decimal strings in each currency's precision (6 decimals
    for USDT/USDC/GOLD, 8 for BTC). Errors always return
    `{"error": "<code>", "message": "<detail>"}`.
servers:
  - url: https://api.qbank.cl/platform
    description: Live (production, real money)
  - url: https://cryptobank.qbank.cl/platform
    description: Test (sandbox, simulated money — pk_test_ keys)
security:
  - bearerAuth: []
tags:
  - name: Receipts
    description: >-
      Branded PDF receipt per operation, with a public signed-QR authenticity
      check, receipt_url on every response/webhook and automatic email delivery
      on final states.
  - name: Authentication
    description: Register and log in account members. Sessions last 24 hours.
  - name: Account
    description: Profile, members and API keys of the calling account.
  - name: Balances
    description: Balances, movement history and FX rates.
  - name: Payouts
    description: >-
      Fiat dispersals debited from the settlement balance of your choice (USDT
      by default).
  - name: Payins
    description: Fiat top-ups credited to the USDT balance.
  - name: Transfers
  - name: Contacts
  - name: Swaps
    description: >-
      Free internal transfers between CBPay accounts (person or company, any
      combination).
  - name: Crypto
    description: On-chain funding and withdrawals (TRON, Ethereum and Bitcoin).
  - name: Segregated wallets
    description: >-
      On-chain wallets with their own balance (companies unlimited; persons 1
      per network+asset pair) — create, import, send, export the private key and
      auto-forward. The balance lives on-chain, never in the ledger.
  - name: QR Crypto POS
    description: >-
      Amount-bearing crypto QR charges for processors with physical POS
      terminals (company accounts): verified merchants, exclusive address + QR
      per charge, early payment detection, per-merchant reconciliation and
      refunds over the crypto withdrawal rail.
  - name: KYC / KYB
  - name: AML screening
    description: >-
      Identity verification: KYC for persons, KYB for companies, with AML
      screening, rescreening and continuous monitoring.
  - name: Wallet screening
    description: >-
      AML risk assessment of blockchain addresses (sanctions, illicit-fund
      exposure) with a per-scan fee, plus free automatic protection on
      withdrawals and deposits.
  - name: Analytics
  - name: Webhooks
    description: Subscriptions to receive signed event notifications.
  - name: Status
    description: Service availability.
  - name: Banking
    description: >-
      Real bank accounts: receive, hold and send money over international
      banking rails.
  - name: Cards
    description: >-
      Virtual and physical cards that spend Just-In-Time from the account's USDT
      balance, with per-card spending limits.
  - name: Security (OTP)
    description: >-
      One-time verification codes over SMS/WhatsApp/email protecting sensitive
      actions, plus self-service 2FA preferences. Applies to user sessions only
      — API keys are exempt.
  - name: Passkeys
    description: >-
      Passwordless sign-in with the device's biometrics (Face ID, Touch ID,
      Windows Hello, security keys) via WebAuthn, authenticator apps (TOTP) with
      backup codes, and session/device management.
  - name: Social login
    description: >-
      Passwordless sign up and sign in with Google, Apple, Microsoft and
      Facebook via token exchange. The front end obtains the provider
      credential; the API verifies it and issues the CBPay session.
paths:
  /v1/balances/history:
    get:
      tags:
        - Balances
      summary: Get balance history
      description: >
        Daily evolution of the account's balances for dashboard charts: one
        series per asset (the closing available balance of each day, carried
        forward on days without movements) plus an aggregated USD series that
        values BTC/GOLD at each day's historical reference price. Includes the
        period's total inflows/outflows and the current snapshot (available +
        held), so a front can render a Mercury-style balance card with its
        percentage change. The series tracks the **available** balance (holds
        have no history); `current` carries today's `held` per asset. Days
        valued with today's spot price (before historical prices exist) are
        disclosed in `spot_priced_dates` — values are never invented.


        The `assets` map also includes the banking account mirrors (`BANK_USD`,
        `BANK_EUR`) as their own series in their own currency (2 decimals). They
        are **not** part of the `total_usd` aggregate, which only covers the
        operational balances (USDT, USDC, BTC, GOLD).
      operationId: getBalancesHistory
      parameters:
        - name: from
          in: query
          required: true
          schema:
            type: string
            format: date
          description: Start date (YYYY-MM-DD, UTC, inclusive).
        - name: to
          in: query
          required: true
          schema:
            type: string
            format: date
          description: End date (YYYY-MM-DD, UTC, inclusive). Max range 366 days.
      responses:
        '200':
          description: Daily balance series per asset plus USD aggregate.
          content:
            application/json:
              schema:
                type: object
                properties:
                  account_id:
                    type: string
                  from:
                    type: string
                  to:
                    type: string
                  granularity:
                    type: string
                    example: day
                  timezone:
                    type: string
                    example: UTC
                  assets:
                    type: object
                    description: >
                      One daily closing-balance series per asset. Includes the
                      operational balances (USDT, USDC, BTC, GOLD) and the
                      banking account mirrors (BANK_USD, BANK_EUR) in their own
                      currency; the banking series are excluded from
                      `total_usd`.
                    additionalProperties:
                      type: object
                      properties:
                        series:
                          type: array
                          items:
                            type: object
                            properties:
                              date:
                                type: string
                                example: '2026-07-10'
                              balance:
                                type: string
                                example: '125.430000'
                        first:
                          type: string
                        last:
                          type: string
                        change_pct:
                          type: string
                          nullable: true
                          description: >-
                            Signed percentage change first→last (null when the
                            series starts at zero).
                  total_usd:
                    type: object
                    description: Aggregated USD value of all balances per day.
                    properties:
                      series:
                        type: array
                        items:
                          type: object
                          properties:
                            date:
                              type: string
                            balance_usd:
                              type: string
                      first:
                        type: string
                      last:
                        type: string
                      change_pct:
                        type: string
                        nullable: true
                      spot_priced_dates:
                        type: array
                        items:
                          type: string
                        description: >-
                          Days valued with today's spot price because no
                          historical price existed.
                      unpriced_assets:
                        type: array
                        items:
                          type: string
                        description: >-
                          Assets excluded from the USD aggregate for lack of any
                          price.
                  period:
                    type: object
                    description: Total inflows/outflows of the period in USD.
                    properties:
                      in_usd:
                        type: string
                      out_usd:
                        type: string
                      net_usd:
                        type: string
                  current:
                    type: object
                    description: Current snapshot (available + held, valued at spot).
                    properties:
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            asset:
                              type: string
                            available:
                              type: string
                            held:
                              type: string
                            usd_estimate:
                              type: string
                              nullable: true
                      net_worth_usd_estimate:
                        type: string
                        nullable: true
              example:
                account_id: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                from: '2026-06-12'
                to: '2026-07-11'
                granularity: day
                timezone: UTC
                assets:
                  USDT:
                    series:
                      - date: '2026-06-12'
                        balance: '100.000000'
                      - date: '2026-06-13'
                        balance: '100.000000'
                      - date: '2026-07-11'
                        balance: '125.430000'
                    first: '100.000000'
                    last: '125.430000'
                    change_pct: '25.43'
                  BTC:
                    series:
                      - date: '2026-06-12'
                        balance: '0.00060000'
                      - date: '2026-07-11'
                        balance: '0.00060000'
                    first: '0.00060000'
                    last: '0.00060000'
                    change_pct: '0.00'
                  BANK_USD:
                    series:
                      - date: '2026-06-12'
                        balance: '1500.00'
                      - date: '2026-07-11'
                        balance: '1725.50'
                    first: '1500.00'
                    last: '1725.50'
                    change_pct: '15.03'
                total_usd:
                  series:
                    - date: '2026-06-12'
                      balance_usd: '163.73'
                    - date: '2026-07-11'
                      balance_usd: '191.34'
                  first: '163.73'
                  last: '191.34'
                  change_pct: '16.86'
                  spot_priced_dates: []
                  unpriced_assets: []
                period:
                  in_usd: '280.20'
                  out_usd: '254.77'
                  net_usd: '25.43'
                current:
                  items:
                    - asset: USDT
                      available: '125.430000'
                      held: '10.000000'
                      usd_estimate: '135.43'
                    - asset: USDC
                      available: '0.000000'
                      held: '0.000000'
                      usd_estimate: '0.00'
                    - asset: BTC
                      available: '0.00060000'
                      held: '0.00000000'
                      usd_estimate: '65.91'
                    - asset: GOLD
                      available: '0.000000'
                      held: '0.000000'
                      usd_estimate: '0.00'
                  net_worth_usd_estimate: '201.34'
        '400':
          description: Missing or invalid date range (`invalid_range`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: invalid_range
                message: from and to are required (YYYY-MM-DD)
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/AccountRequired'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Machine-readable error code (snake_case).
          example: insufficient_funds
        message:
          type: string
          description: Human-readable explanation.
  responses:
    Unauthorized:
      description: Missing or invalid credential (`unauthorized`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
            message: invalid or missing credentials
    AccountRequired:
      description: This endpoint requires an account credential (`account_required`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: account_required
            message: this endpoint requires an account credential
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        Session JWT (from register/login) or API key (`pk_...`).
        `X-API-Key: <token>` is accepted as an alternative header.

````