Balance Alerts

Overview of balance alerts using ledger account balance monitors

Overview

If you want to be alerted or trigger a process when a ledger account exceeds a given range, you can use a ledger_account_balance_monitor. You can find the API reference for Ledger Account Balance Monitors here and the webhook information here.

Balance monitors should be used for cases where ledger accounts are allowed to exit a certain range, but where this activity needs to be flagged. For example, you may have a range within which a cash or user account should remain over the normal course of business, outside of which operational users should be alerted.

For ledger accounts that should never exceed a given range (e.g. user balances that should never go below zero), you can use balance locking on ledger entry creation. See Handling Concurrency.

Listening to webhooks

One the balance monitor is created, it will send an initial webhook which reflects the initial state. Then, every time the alert condition transitions from true to false, or false to true, a webhook will be sent.

Learn more about webhooks in general here and Ledger Account Balance Monitor webhook information here.

Alert Conditions

An alert condition is comprised of three parts; the field, operator, and value.

The field denotes the specific balance/value we are comparing against.is one of available_balance_amount, pending_balance_amount, posted_balance_amount, ledger_account_lock_version.

The operator is used compare the field against the value. It is one of less_than, less_than_or_equals, equals, greater_than_or_equals, greater_than.

The value is the comparison value which is compared against the value retrieved through the field.