Skip to main content
Every Pix transaction follows a pattern: debit the sender, credit the receiver, maybe collect a fee. When that pattern lives only in application code, every team that touches Pix must re-implement the same validation logic — and every implementation is a chance for inconsistency. Transaction Routes move that pattern into the ledger itself. You define the rules once, and Midaz enforces them on every transaction automatically. The result is fewer integration errors, a clear audit trail, and a single source of truth for how Pix money flows through your system. This page walks through two real-world scenarios — a simple peer-to-peer transfer and a transfer with fee collection — showing how to set up routes and what your team gains from using them.

Why this matters


For product and operations teams, Transaction Routes mean predictable, auditable Pix flows without relying on application-level enforcement. Every transaction carries a reference to the route it followed, making compliance reviews and incident investigations straightforward. For engineering teams, routes eliminate repetitive validation code. Instead of checking account types and fee destinations in every Pix integration, you configure the rules once and let Midaz handle enforcement at the ledger level. For a deeper look at how Transaction Routes and Operation Routes work, see Accounting Routes.

Prerequisites


Both scenarios assume a Midaz environment with the following structure already in place:
Values in Midaz are represented in the smallest unit of the currency. For BRL, 15000 means R$ 150.00 (centavos).

Scenario 1: Simple Pix transfer


Alice sends R$ 150.00 to Bob via Pix. The money moves from one checking account to another — no fees, no splits, just a clean peer-to-peer transfer.

The goal

  • Debit Alice’s checking account by R$ 150.00
  • Credit Bob’s checking account by R$ 150.00
  • Validate that both accounts are of type checking before processing
  • Make this pattern reusable for every Pix transfer between checking accounts

Setting up the routes

1

Create the source Operation Route

This route defines the debit side of the transfer. The account_type rule means any account of type checking is valid as a source — the route doesn’t hardcode a specific sender.
Save the returned id — you’ll need it when building the Transaction Route.
2

Create the destination Operation Route

This route defines the credit side. Same rule type: any checking account qualifies as a valid receiver.
3

Create the Transaction Route

Group both Operation Routes into a single Transaction Route. This is the pattern that represents “Pix Transfer” in your system.
Replace the placeholder IDs with the actual Operation Route IDs returned in the previous steps.

Executing a Pix transfer

With the route in place, every Pix transfer references the Transaction Route ID. Midaz validates that the accounts match the route’s rules before processing.

What happens under the hood

1

Midaz receives the transaction

The request includes the Transaction Route ID in the route field. Midaz loads the route configuration.
2

Source validation

For each from entry, Midaz checks the account against the source Operation Route rules. Alice’s account is type checking — matches the account_type rule. Validation passes.
3

Destination validation

For each to entry, Midaz checks the account against the destination Operation Route rules. Bob’s account is type checking — validation passes.
4

Transaction is processed

Both validations pass, so Midaz creates the transaction atomically: debits @alice_checking by R$ 150.00 and credits @bob_checking by R$ 150.00.
If Alice tried to send from a savings account instead, Midaz would reject the transaction — the route only accepts checking accounts as sources. No application-side validation needed.

Scenario 2: Pix transfer with fee collection


Same flow as Scenario 1, but now the bank charges a R$ 1.50 fee on each Pix transfer. This adds a third Operation Route for the fee destination, and Alice’s total debit increases to R$ 151.50.

What changes

You already have the source and destination Operation Routes from Scenario 1. You need one additional Operation Route for the fee and a new Transaction Route that groups all three.

Setting up the fee route

1

Create the fee Operation Route

Unlike the previous routes that use account_type, this one uses the alias rule type. That means it targets a specific account — @revenue_pix_fees — and no other account can be used.
2

Create the Transaction Route with fee

This route groups the original source and destination routes with the new fee route. It’s a separate Transaction Route from the simple transfer — your system can offer both variants.

Executing a Pix transfer with fee

Alice sends R$ 150.00 to Bob. The bank collects R$ 1.50. Alice’s total debit is R$ 151.50.
Result: Alice is debited R$ 151.50. Bob receives R$ 150.00. The bank collects R$ 1.50 in fees. All in a single atomic transaction — fully balanced, fully auditable.

What this unlocks

  • Transparent fee collection — the fee is a first-class ledger entry, not hidden metadata. Finance and compliance teams see exactly where the R$ 1.50 went.
  • Reusable building blocks — the source and destination Operation Routes are shared between the simple and fee variants. You only add what changes.
  • Route-level control — your system can offer both “Pix Transfer” and “Pix Transfer with Fee” as distinct products, each backed by its own Transaction Route.
  • Easy evolution — need a percentage-based fee? A split across multiple revenue accounts? Add new Operation Routes and compose a new Transaction Route. Existing flows remain untouched.

Understanding rule types


The two rule types serve different purposes. Choosing the right one depends on whether the account in a route should be dynamic or fixed.
You can combine both rule types within a single Transaction Route. Scenario 2 does exactly that: account_type for the dynamic sender and receiver, alias for the fixed fee account.

What you need to get started


Transaction Route validation must be explicitly enabled per ledger. See Working with Accounting Routes for the configuration steps.

Next steps


Accounting Routes

Understand how Operation Routes and Transaction Routes work at a deeper level.

Transactions

Learn about Midaz’s double-entry transaction model and N:N capabilities.

Pix with automated fees

Combine the Pix Plugin with the Fees Engine for automated fee management.

Pix Switch

Explore the full Pix Plugin architecture and connection models.