What are transactions?
Transactions represent the movement of funds between balances in your ledger. Every transaction records a financial event, moving money from a source balance to a destination balance. Blnk ensures that all transactions follow double-entry accounting principles, maintaining data integrity and providing a complete audit trail. Transactions in Blnk:- Move funds between balances atomically
- Track both source and destination
- Support multiple states (pending, committed, voided)
- Handle multi-destination splits
- Enable inflight (pending) operations
- Maintain precision with big integer arithmetic
Transaction structure
The Transaction model in Blnk contains the following fields:Unique identifier for the transaction (auto-generated)
Transaction amount in major units (e.g., 100.00 for $100)
Transaction amount in minor units for precision
Multiplier for converting amount to minor units (100 for 2 decimals)
Exchange rate for currency conversion
Source balance ID (where funds come from)
Destination balance ID (where funds go to)
Multiple source balances with distribution rules
Multiple destination balances with distribution rules
External reference or transaction ID from your system
Currency code for the transaction
Human-readable description of the transaction
Transaction status: “QUEUED”, “APPLIED”, “INFLIGHT”, “VOID”, “REJECTED”
Cryptographic hash of transaction data for integrity
ID of parent transaction for splits and refunds
Whether to allow negative balances
Maximum allowed negative balance
Whether this is a pending/inflight transaction
Whether to ensure atomic execution in batch operations
Process immediately without queuing
When the transaction was created
When the transaction takes effect (for backdating)
When to execute the transaction (for scheduling)
When inflight transaction expires and auto-voids
Custom metadata for additional information
Example transaction object
Creating a transaction
Create a simple transaction between two balances:Response
Response
The
reference field must be unique for each transaction. Blnk uses it for idempotency - if you retry the same request with the same reference, you’ll get the existing transaction instead of creating a duplicate.Transaction lifecycle and states
Transactions move through different states during their lifecycle:QUEUED
The transaction is scheduled for processing. This happens when:- Transaction is scheduled for a future time
- System is processing at high volume
- Transaction is part of a batch operation
APPLIED
The transaction has been successfully committed. Balances have been updated and the transaction is permanent.INFLIGHT
The transaction is pending. Funds are held but not yet committed. The transaction can be:- Committed: Convert to APPLIED status
- Voided: Reverse the hold and cancel the transaction
VOID
The transaction has been cancelled or reversed. For inflight transactions, this releases the hold. For applied transactions, this creates a reversal transaction.REJECTED
The transaction failed validation or processing. Common reasons:- Insufficient balance (when
allow_overdraftis false) - Invalid source or destination balance
- Validation errors
Sources, destinations, and distributions
Single source and destination
The simplest transaction moves money from one balance to another:Multiple destinations (splits)
Split funds from one source to multiple destinations:Distribution types
Blnk supports three distribution types:Percentage distribution
Use percentages to split amounts:Fixed amount distribution
Specify exact amounts:Left distribution
Allocate remaining funds after other distributions:Example: Payment with fees
Split a $100 payment between merchant (95%) and platform fee (5%):- Parent transaction: Links all related transactions
- Child transaction 1: $95.00 to merchant
- Child transaction 2: $5.00 to platform fee
Inflight transactions
Inflight transactions hold funds without immediately committing them. This is useful for:- Payment authorizations
- Escrow operations
- Two-phase commits
- Reversible operations
Creating an inflight transaction
inflight_debit_balance and destination’s inflight_credit_balance.
Committing an inflight transaction
To apply the held funds:Voiding an inflight transaction
To cancel and release the hold:Inflight transactions automatically void when they reach their
inflight_expiry_date. Set expiry dates to prevent funds from being held indefinitely.Scheduled transactions
Schedule transactions for future execution:Refunds and reversals
To refund a transaction, create a new transaction in the opposite direction:parent_transaction field links the refund to the original transaction.
Bulk transactions
Process multiple transactions in a single request:atomic: true, all transactions succeed together or all fail together.
Managing transactions
Retrieve a transaction
List transactions
Query transactions for a balance
Best practices
Use unique references
Use unique references
Always provide unique
reference values. This enables:- Idempotency (safe retries)
- Easy correlation with your system
- Better debugging and support
payment_${orderId}transfer_${timestamp}_${userId}refund_${originalReference}
Store context in metadata
Store context in metadata
Use
meta_data to store relevant transaction context:Handle insufficient balance gracefully
Handle insufficient balance gracefully
Set If you need to allow overdrafts, set limits:
allow_overdraft: false (default) to prevent negative balances. When a transaction fails due to insufficient funds, handle it in your application:Use inflight for two-phase operations
Use inflight for two-phase operations
When you need to verify something before committing funds:
- Create inflight transaction (hold funds)
- Perform verification (check with payment provider, etc.)
- Commit or void based on result
inflight_expiry_date to prevent indefinite holds.Link related transactions
Link related transactions
Validate precision values
Validate precision values
Ensure the
precision value matches your currency:- Standard currencies (USD, EUR): 100 (2 decimals)
- Zero-decimal currencies (JPY, KRW): 1
- Cryptocurrencies: May vary (Bitcoin: 100000000)
Next steps
Balances
Learn about the balances that transactions move funds between
Double-Entry Accounting
Understand the accounting principles behind Blnk
Bulk Transactions
Process thousands of transactions efficiently
Reconciliation
Match transactions with external records