Blnk Watch is currently in beta. Send us a message
when clause is used to describe a set of conditions that trigger a transaction in Watch.
Rules still evaluate transactions only. If you need extra context, include it in meta_data on the transaction first.
When setting conditions, you can only use the supported fields in the Watch transaction payload: transaction_id, amount, reference, source, destination, description, created_at, and meta_data.
Basic conditions
Basic conditions compare transaction fields to literal values. You can compare numeric fields (e.g.amount), string fields (e.g. currency, source, destination), and metadata (e.g. meta_data.kyc_tier).
For example, this is a simple rule flagging amounts greater than 10,000:
largeTransfer.ws
Combined conditions
To create conditions with two or more filters, Watch supports two logical operators:- and: Every condition must be true.
- or: At least one of the conditions must be true.
highValueTransfer.ws
or, one of two conditions can trigger the same risk action. For example, in a cross-border app you might treat amounts over 10,000 as high-risk regardless of currency; but if the transaction is in PKR, IRR, or SYP, you treat it as high-risk regardless of amount.
highRiskTransaction.ws
Recommended: If your or conditions start to get complex, you should consider using a separate rule for each condition. For example, a complex set of conditions like this …
highRiskTransaction2.ws
… is better written as three separate rules:
This makes your rule set easier to read, reason about, and change in your workflow.
Metadata reference
When setting conditions on information that is not part of the top-level parameters, such as source country, destination country, customer KYC tier, or promo code, pass the value inmeta_data.
You can then reference the value in your rule using dot notation. For example, here’s a rule that flags when a customer has used at least one of the supported promo codes:
promoCodeReuse.ws
Dynamic references
Dynamic references allow you to reuse values from the transaction being evaluated when defining a condition. This works with any field in the transaction payload, including values inmeta_data.
Use dynamic references when the value you want to compare depends on the transaction being evaluated, rather than a fixed value.
To reference a value from the current transaction, use:
sameSourceAndDestination.ws
mismatchedCountries.ws
Aggregate operators
Aggregate conditions evaluate groups of transactions over a defined time window rather than a single transaction. This makes it possible to detect patterns in activity. Here are some examples of aggregate conditions in practice:aggregatedefines the metric to compute, e.g.countorsum.when <filter>selects the transactions to include in the calculation.<window>defines how far back to look from the current transaction.
The time window is written as an ISO 8601 duration string in quotes.
Use
PT for time units (hours, minutes, seconds) and P for days. Weeks and months are not supported. Use days instead (for example "P7D" for one week or "P30D" for roughly a month).Time-based functions
Time-based functions let you write rules that depend on when a transaction occurs. For example, you might want to review large transactions late at night:lateNightLargeTransfer.ws
created_at on the transaction: the value you send on inject or that Watch syncs from Blnk Core.
You can write time-based conditions using helper functions that extract parts of the timestamp.
Also note: Time-based conditions support standard comparison operators:==,!=,>,>=,<,<=,in, andnot_in.
ForFor example, to flag high value transactions that occur on a weekend:day_of_week, when using theinoperator, you can use day names instead of numbers. Soday_of_week(created_at) in ("Saturday", "Sunday")is equivalent today_of_week(created_at) in (0, 6).
weekendHighValueTransactions.ws
“Previous transaction” function
previous_transaction checks if any transaction in a past time window matches specific criteria. It returns true if at least one matching transaction exists, otherwise false.
Use it to detect patterns like:
- This source had a failed transaction recently
- This destination already received a transaction in the last hour
-
within - How far back to look. Uses ISO 8601 duration strings, e.g.
"PT1H"(1 hour),"P1D"(1 day). -
match - A set of fields that must all match for a transaction to count. You can use literal values, e.g.
meta_data.status: "failed"or dynamic references,source: $current.source.
blockIfPreviousFailed.ws
burstToSameDestination.ws
Note:
- This is a boolean check, not a count. It only answers: “Did at least one matching transaction occur?”
- The lookback window ends at the current transaction’s
created_at, not server time.matchkeys must be table columns (source,destination,status, and so on) or metadata paths (meta_data.status,metadata.status). Dotted keys in object literals are supported (for examplemeta_data.status: "failed").- Uses the same transaction store and time window format as aggregate conditions.