Understanding balance monitors
A balance monitor consists of:- Balance ID: The balance to monitor
- Condition: The trigger rule (field, operator, value)
- Callback URL: Where to send webhook notifications
- Description: Human-readable explanation
Creating a basic monitor
Set up a low balance alert:Monitoring different fields
You can monitor various balance fields:Available balance
Credit balance
Debit balance
Inflight balance
Supported operators
Less than
< - Triggers when field value is less than thresholdLess than or equal
<= - Triggers when field value is less than or equal to thresholdGreater than
> - Triggers when field value exceeds thresholdGreater than or equal
>= - Triggers when field value is greater than or equal to thresholdEqual
= - Triggers when field value exactly matches thresholdNot equal
!= - Triggers when field value differs from thresholdCommon use cases
Low balance warning
Fraud detection
Merchant payout threshold
Reserve requirement
Dormant account detection
Managing monitors
List all monitors
Get monitors for specific balance
Get specific monitor
Update a monitor
Delete a monitor
Webhook payload structure
When a monitor condition is met, Blnk sends a webhook:Implementation details (from balance.go:59-86)
How Blnk checks balance monitors:Performance optimization
Blnk caches balance monitors with a 5-minute TTL:Best practices
Use appropriate operators
Choose operators that match your use case (e.g.,
< for low balance, > for high activity)Set realistic thresholds
Base threshold values on actual usage patterns
Avoid monitor spam
Don’t set thresholds that trigger too frequently
Include descriptions
Write clear descriptions for easier debugging
Monitor critical balances
Set up monitors for high-value or sensitive accounts
Handle webhooks reliably
Implement idempotent webhook handlers
Multi-threshold monitoring
Set up multiple monitors for different alert levels:Troubleshooting
Monitor not triggering
Problem: Created a monitor but not receiving webhooks Checklist:- Verify webhook URL is configured in
blnk.json - Check condition is actually being met
- Verify webhook endpoint is accessible
- Check webhook logs for errors
Duplicate notifications
Problem: Receiving multiple webhook notifications for same event Solution: Monitors trigger on every transaction that meets the condition. Implement webhook deduplication:Next steps
Webhooks
Learn how to handle balance monitor webhooks
Wallet Management
Implement automated top-ups based on monitors