What are balances?
Balances represent individual accounts that hold funds in your ledger system. Each balance tracks the total amount of money, along with detailed credit and debit information. Balances are the fundamental building blocks of your financial system - they’re where money is stored and from which transactions flow. Every balance:- Belongs to exactly one ledger
- Has a specific currency
- Maintains separate credit and debit totals
- Tracks inflight (pending) amounts
- Uses high-precision arithmetic to prevent rounding errors
Balance structure
The Balance model in Blnk contains the following fields:Unique identifier for the balance (auto-generated)
Current balance in minor units (credit - debit)
Total amount credited to this balance
Total amount debited from this balance
Total amount in pending/inflight transactions
Pending credits not yet committed
Pending debits not yet committed
Scheduled debit amounts
Scheduled credit amounts
Currency code (e.g., “USD”, “EUR”, “NGN”)
Multiplier for currency conversion (defaults to 1.0)
ID of the ledger this balance belongs to
Optional link to an identity record
Custom identifier for balance lookup
Version number for optimistic locking
When the balance was created
When inflight amounts expire
Custom metadata for additional information
Enable fund flow tracking for this balance
Strategy for allocating funds (e.g., “FIFO”, “LIFO”)
Example balance object
Understanding balance types
Credit balance
Thecredit_balance field tracks the total amount of money that has been credited (added) to this balance over time. Credits increase the balance.
Debit balance
Thedebit_balance field tracks the total amount of money that has been debited (removed) from this balance over time. Debits decrease the balance.
Current balance
The currentbalance is calculated as:
Inflight balances
Inflight amounts represent pending transactions that have been initiated but not yet committed:- inflight_credit_balance: Credits that are held but not yet applied
- inflight_debit_balance: Debits that are held but not yet applied
- inflight_balance: Net inflight amount (credit - debit)
Precision and currency handling
Working with precision
Blnk uses big.Int for all balance amounts to ensure perfect precision and avoid floating-point rounding errors. All amounts are stored in the smallest unit of the currency (minor units):- USD: Cents (100 = $1.00)
- EUR: Cents (100 = €1.00)
- JPY: Yen (1 = ¥1, as yen has no minor unit)
- BTC: Satoshis (100000000 = 1 BTC)
precision multiplier:
The
precision field in transactions tells Blnk how to interpret amounts. For most currencies, use 100 (2 decimal places). For cryptocurrencies or high-precision requirements, you can use larger values.Currency multiplier
Thecurrency_multiplier field allows you to apply conversion rates or scaling factors to balance calculations. This is useful for:
- Multi-currency operations
- Internal conversion rates
- Scaled accounting systems
Creating a balance
Create a balance by sending a POST request to/balances:
Response
Response
Creating a balance with an identity
You can link a balance to an identity for customer association:Using custom indicators
Theindicator field lets you use custom identifiers for balance lookup:
Balance monitoring
Blnk provides Balance Monitors to track balance conditions and trigger webhooks when thresholds are met.Creating a balance monitor
Monitor conditions
You can monitor various balance fields:balance: Current balancecredit_balance: Total creditsdebit_balance: Total debitsinflight_balance: Pending amounts
lt: Less thangt: Greater thanlte: Less than or equal togte: Greater than or equal toeq: Equal to
Example: High balance warning
Balance monitors are useful for compliance, risk management, and customer notifications. You can set up monitors for low balance alerts, high balance warnings, or any custom threshold.
Balance snapshots
Blnk can create point-in-time snapshots of balances for reporting and auditing:- Generate daily balance reports
- Track balance trends over time
- Perform historical balance lookups
Retrieving historical balance
Get a balance’s state at a specific time:Response
Response
Managing balances
Retrieve a balance
List balances
Update balance identity
Link a balance to an identity:Best practices
Use metadata for searchability
Use metadata for searchability
Store relevant information in the
meta_data field to make balances easy to find and filter:Set up monitoring for critical balances
Set up monitoring for critical balances
Create balance monitors for:
- User wallets that shouldn’t drop below zero
- Operational accounts that need minimum reserves
- Settlement accounts that need maximum limits
Track fund lineage when needed
Track fund lineage when needed
Enable
track_fund_lineage for balances where you need to track the source and flow of funds. This is useful for:- Compliance and auditing
- Chargeback handling
- Dispute resolution
Use indicators for external ID mapping
Use indicators for external ID mapping
If you have existing user or account IDs in your system, use the This makes it easy to look up balances using your existing identifiers.
indicator field to map them:Never manipulate balances directly
Never manipulate balances directly
Always update balances through transactions. Direct balance manipulation breaks double-entry accounting principles and audit trails.
Next steps
Transactions
Learn how to record financial movements between balances
Identities
Link balances to customer identities
Balance Monitoring
Set up alerts and notifications for balance thresholds
Ledgers
Understand how ledgers organize balances