Meter usage in exact units, even when the price is a fraction of a cent
Usage pricing produces many small charges, often priced below the smallest currency unit. Choose a precision that fits your pricing, post charges as exact integers and batch them with explicit atomic behaviour.
- API calls0.000400 USDprecise_amount 400
- Storage0.018250 USDprecise_amount 18250
Where this usually goes wrong
Prices smaller than a cent
A per-call price of 0.0004 USD doesn't fit in cents, and floating-point arithmetic rounds it differently depending on where the sum happens.
Pipelines replay events
Metering systems retry and replay. Without idempotency enforced at the ledger, a replayed batch bills the customer twice.
Credits, holds and settlement disagree
Prepaid credit, reservations against it and end-of-period settlement need to read from one consistent balance, not three services.
Primitives in the open-source core, not patterns you rebuild
Precision you choose
Precision is a multiplier, not a count of decimal places. At precision 1000000, precise_amount 400 is 0.0004 USD. Keep one multiplier per currency.
Bulk transfers
POST /transactions/bulk submits a batch with explicit atomic and asynchronous options, and reports each item's outcome.
Idempotent metering
Give each metered period a stable reference. A replayed charge is rejected instead of posted again.
Prepaid credit with holds
Reserve expected usage against a credit balance, then commit what was actually consumed and release the rest.
Previews
dry_run: true projects a charge's effect on balances without posting, consuming the reference or sending a webhook.
Published rounding rules
The compatibility amount field rounds to the nearest unit, ties away from zero. Prefer precise_amount and nothing is rounded at all.
Two metered charges, applied together or not at all
{ "atomic": true, "skip_queue": true, "transactions": [ { "source": "bln_<customer_credits>", "destination": "bln_<usage_revenue>", "currency": "USD", "precise_amount": 400, "precision": 1000000, "reference": "usage-acct42-2026-10-10-api-calls" }, { "source": "bln_<customer_credits>", "destination": "bln_<usage_revenue>", "currency": "USD", "precise_amount": 18250, "precision": 1000000, "reference": "usage-acct42-2026-10-10-storage" } ]}Request shape from the v1.0.0 API. IDs in angle brackets are placeholders.
Put a provable ledger under your money movement
Start with the open-source core, or let the LedgerForge team run it for you on dedicated infrastructure.