Skip to main content
Fee handling in Matcher is split across two entities:
  • A fee schedule defines how much fee to compute: the currency, rounding, and one or more fee items (flat, percentage, tiered, or expression-based).
  • A fee rule decides when a fee schedule applies. It belongs to a reconciliation context, targets a matching side, and carries predicates that a transaction’s metadata must satisfy. When the predicates match, the rule selects its fee schedule.
Modeling expected fees this way lets Matcher check matched transactions against the expected fee. With fee normalization enabled, Matcher also accounts for the fee before comparing transactions, when the transaction and schedule currencies match.

What fee handling solves


Reconciliation fails when one side of a transaction includes fees or charges that the other side doesn’t record. A payment gateway deducts a processing fee before settling. A bank charges a wire transfer fee. An acquirer nets fees against payouts. Without modeled fees, Matcher treats these differences as amount mismatches and generates exceptions, even when you expect and document the difference. Fee schedules describe the charge, and fee rules select when to use it.

How rules and schedules fit together


A fee rule does not contain the fee amount or calculation itself. It references a fee schedule by ID and applies it to the transactions its predicates select.
  1. You create a fee schedule once at the tenant level. Many rules across many contexts can reuse it.
  2. You create a fee rule inside a context. It sets a side, a feeScheduleId, a priority, and a list of predicates.
  3. When Matcher processes a context, it evaluates the relevant side’s fee rules in priority order (lowest first). The first matching rule selects the referenced schedule.
This separation means you change when the fee applies by editing the rule, without touching the schedule. Editing a schedule changes only its name, application order, rounding scale, and rounding mode. To change its items or currency, create a new schedule and point the rule’s feeScheduleId at it.
A fee rule alone does not change comparison amounts. It changes them only when the context sets feeNormalization to NET or GROSS, the relevant side has rules, and the transaction and schedule currencies match. Once a context has fee rules, every COMMIT run also checks matched transactions against the expected fee and raises FEE_VARIANCE, FEE_DATA_MISSING, or FEE_CURRENCY_MISMATCH exceptions.

Fee rule structure


A fee rule belongs to a context and has the following fields.

Predicates

Each predicate tests one transaction metadata field with an operator. Available operators: Missing fields evaluate to false for every operator except EXISTS.

Fee schedule structure


A fee schedule is a tenant-level entity that computes a fee from a gross amount.

Fee items

Each item declares a name, a priority (application order, relevant for CASCADING), a structureType, and a type-specific structure.

Managing fee schedules


Fee schedules are tenant-scoped and managed independently of any context.

Create a fee schedule

This schedule computes a 2.9% processing fee on the gross amount, denominated in BRL.
cURL

Simulate a fee schedule

Before wiring a schedule into a rule, simulate it against a gross amount to confirm the computed fee.
cURL
The response returns the netAmount, totalFee, and a per-item breakdown.
A fee schedule cannot be deleted while a fee rule or fee-variance history references it. The delete request returns 409 Conflict with code MTCH-0108. When fee rules block the deletion, the response lists their contexts in the errors[] entry whose location is fee-schedule.delete.blocking-contexts. Remove or repoint current rule references first. Historical variance references continue to block deletion.

Managing fee rules


Fee rules are created inside a context and reference a fee schedule.

Create a fee rule

This rule applies the fee schedule created above to right-side transactions whose institution metadata equals Banco do Brasil.
cURL

End-to-end flow


Expected-fee handling follows three steps:
1

Create the fee schedule

Define how the fee is computed once at the tenant level with POST /v1/fee-schedules. Optionally validate it with the simulate endpoint. Note the returned id.
2

Create the fee rule in the context

Inside the reconciliation context, create a fee rule with POST /v1/contexts/{contextId}/fee-rules. Set feeScheduleId to the schedule’s id, choose the side, set a unique priority, and add the predicates that select the transactions the fee applies to.
3

Apply during matching

Set the context’s feeNormalization to NET or GROSS. The context then needs at least one fee rule to activate. Until it has one, activation readiness reports context.activation.requirement.fee-rule. During matching, Matcher evaluates rules for each relevant side in priority order. A matching rule changes the comparison amount only when its schedule and the transaction use the same currency.

Best practices


A fee schedule is tenant-scoped and can be referenced by many rules. Define a schedule once (e.g. “Card Processing - Visa”) and point rules in different contexts at it. Editing the schedule updates every rule that uses it.
Priorities are unique within a context and shared across LEFT, RIGHT, and ANY rules. Order them from most specific to most general so a narrow rule wins before a broad fallback.
Predicates are ANDed together and tested against transaction metadata. Combine operators (EQUALS, IN, BETWEEN, EXISTS) to target exactly the transactions a fee applies to and avoid unintended fee attribution.
Use POST /v1/fee-schedules/{scheduleId}/simulate to confirm a schedule produces the expected fee for representative amounts before referencing it from a rule.
A schedule referenced by a rule or fee-variance history cannot be deleted (409 MTCH-0108). When fee rules block it, the response lists their contexts in errors[]. Update or remove current rule references first; historical variance references continue to block deletion.

Next steps


Match rules

Configure how Matcher compares transactions once it accounts for expected fees.

Exception routing

Review explicit assignment, dispatch, and callback behavior for exceptions that fee handling doesn’t cover.

Fee schedules API

Full API reference for fee schedule endpoints.

Fee rules API

Full API reference for fee rule endpoints.