Accounts BalanceThresholdTrigger

Accounts BalanceThresholdTrigger

Certified

Trigger execution on Mercury balance threshold

Periodically polls Mercury bank account balances and triggers an execution when an account drops below a configured minimum threshold.

yaml
type: io.kestra.plugin.mercury.accounts.BalanceThresholdTrigger

Trigger flow execution when any Mercury account drops below minimum balance

yaml
id: trigger_mercury_balance_threshold
namespace: company.team

tasks:
  - id: alert_low_balance
    type: io.kestra.plugin.core.log.Log
    message: "Account {{ trigger.account.name }} ({{ trigger.account.id }}) has balance {{ trigger.balance }}, {{ trigger.size }} account(s) below threshold"

triggers:
  - id: watch_balance
    type: io.kestra.plugin.mercury.accounts.BalanceThresholdTrigger
    apiToken: "{{ secret('MERCURY_API_TOKEN') }}"
    minBalance: 5000.00

Trigger flow execution when a specific Mercury account drops below minimum balance

yaml
id: trigger_mercury_account_balance
namespace: company.team

tasks:
  - id: alert_account_balance
    type: io.kestra.plugin.core.log.Log
    message: "Account {{ trigger.account.id }} balance {{ trigger.balance }} below {{ trigger.account.minBalance }}"

triggers:
  - id: watch_specific_account
    type: io.kestra.plugin.mercury.accounts.BalanceThresholdTrigger
    apiToken: "{{ secret('MERCURY_API_TOKEN') }}"
    accountId: "d0e567d8-76a7-11e9-a22d-0b33e9de0755"
    minBalance: 10000.00
    balanceType: AVAILABLE
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-mercury --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

For Kestra CLI, replace LATEST with a specific version or version range to pin the plugin version.

Properties

Mercury API token

API token for authentication with the Mercury API.

Minimum balance threshold

The minimum balance threshold in USD. When an account's balance drops below this amount, the trigger fires.

Account ID

Optional unique identifier (UUID) of a specific Mercury account to monitor. When omitted, all active Mercury accounts are evaluated.

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

DefaultAVAILABLE
Possible Values
AVAILABLECURRENT

Balance type to evaluate

The balance type to compare against the threshold: AVAILABLE or CURRENT. Default is AVAILABLE.

Defaulthttps://api.mercury.com/api/v1

Mercury API base URL

Base URL for the Mercury API. Override for the Mercury sandbox (https://api-sandbox.mercury.com/api/v1). Must use HTTPS, except for loopback hosts (localhost, 127.0.0.1, ::1) during local testing.

DefaultPT5M
Formatduration

Polling interval

The interval between consecutive polls. Default is PT5M (5 minutes).

Default100

Maximum pages to retrieve

Safety cap on the number of pages fetched when listing all accounts. Minimum 1. Default is 100.

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

First account below threshold

The first account that newly dropped below the threshold. Use accounts when several accounts crossed in the same poll.

Definitions
balancenumber

Account balance

The balance of the account evaluated against the threshold.

idstring

Account ID

The unique identifier (UUID) of the Mercury account.

minBalancenumber

Minimum balance threshold

The configured minimum balance threshold in USD.

namestring

Account name

The name of the Mercury account.

Accounts below threshold

List of accounts that have newly dropped below the minimum balance threshold.

Definitions
balancenumber

Account balance

The balance of the account evaluated against the threshold.

idstring

Account ID

The unique identifier (UUID) of the Mercury account.

minBalancenumber

Minimum balance threshold

The configured minimum balance threshold in USD.

namestring

Account name

The name of the Mercury account.

Balance of the first account below threshold

The evaluated balance of the account exposed in account.

Number of accounts below threshold

The count of accounts that have newly dropped below the minimum balance threshold.