Why this matters
For product and operations teams, each balance becomes its own account. The Ledger then enforces every segregation rule — a blocked outflow, a benefit-only spend, a promotional balance with an expiry. The rule lives in the Ledger, not in application logic. Each account carries its own statement and reconciliation trail. For engineering teams, each external address resolves to a specific account before Midaz posts a transaction. Core banking numbers and payment-rail identifiers each point to one balance. You never guess which balance an incoming event belongs to. There is no separate balance store to keep in sync with the Ledger.
The reference architecture
The model is one owner, N accounts, N external identifiers:
- One owner — the customer, identified by a document (CPF, CNPJ, tax ID). The owner represents who holds the relationship. It does not carry a balance and does not decide transaction routing.
- N accounts — each account is a self-contained accounting position, with its own balance, ledger, statement, and rules.
- N external identifiers — the addresses other systems (a core banking platform, a payment rail) use to reach a specific account. Each identifier resolves to exactly one account.
Reference architecture: one customer, many accounts.
When balance, ledger, statement, or operational rule differs by destination, point each identifier at a distinct account. An external identifier is not just a nickname for one shared balance.
How Midaz maps the model
Every part of this architecture maps to a native Midaz entity. You do not build a separate balance store or invent an accounting layer.
Prerequisites
This example assumes a running Midaz environment with the following in place:
Midaz represents values in the smallest unit of the currency. For BRL,
15000 means R$ 150.00 (centavos).Building three accounts for one customer
The customer with document
12345678900 needs three accounts. The main account is free for ordinary movement. The benefit account follows product rules. The blocked account accepts inflows but restricts outflows.
1
Enable Account Type validation
Turn on validation so every account must declare a registered type. This is what lets the Ledger enforce each account’s nature.Settings take effect immediately — no redeployment needed.
2
Register the Account Types
Create one Account Type per balance nature. The Repeat for
keyValue is what each account’s type field must match.benefit_account (movement under product rules) and restricted_account. The restricted_account is the blocked account: it accepts inflows but conditions or blocks outflows.3
Create the three accounts
Each account links to the Create the benefit account with
BRL asset and declares its type. It carries an alias (its in-Ledger address) and an entityId (its identifier in your external system).alias @cust_12345678900_benefit, entityId 0001/88888-2, and type benefit_account. Create the blocked account with alias @cust_12345678900_blocked, entityId 0002/77777-0, and type restricted_account.4
Register the customer as a Holder
Create one Holder for the customer. The same Holder owns all three accounts and keeps identity in one place.Save the returned
In Midaz v4, CRM is part of the ledger binary, so it needs no separate service or port. The organization ID travels in the URL path — see Getting started with CRM for the full schema.
holderId — you’ll use it in the next step.5
Link each account to the Holder
Create one Instrument per ledger account to attach banking and regulatory context. The Instrument powers CRM-driven features and keeps customer-facing details out of the Ledger.Notice how the main account’s
entityId (0001/12345-1) decomposes into the branch (0001) and account (12345) you record here. That external address now resolves to one specific account. Repeat for the benefit and blocked accounts, and point accountId at each one.The transaction boundary
When an external event arrives, the resolution happens before the call to Midaz. Each layer stays in its lane, and that preserves accounting clarity.
1
External event
A transaction, query, or settlement arrives with an external identifier.
2
Middleware resolves the identifier
The middleware looks up the external identifier and resolves it to the correct Midaz account alias. It also applies status validation (active, blocked, closed).
3
Midaz posts to the right account
Midaz records the entry against the resolved account and preserves balance and ledger. Statement and reconciliation stay separate by account.
What this unlocks
- Real segregation — each balance has its own ledger and statement. You cannot spend a blocked balance through the main account by accident.
- Unambiguous routing — every external event has a single, well-defined destination account.
- Centralized identity — one Holder owns many accounts. Identity and contact data live in one place while balances stay separate.
- Native, not bolted-on — accounts, types, aliases, and
entityIdare platform primitives, so there’s no parallel balance store to reconcile against the Ledger.
What you need to get started
Next steps
Accounts
The core financial unit — aliases,
entityId, and external accounts.Account Types
Classify accounts and enforce their nature with route validation.
Portfolios
Group a customer’s accounts to view the total relationship.
CRM: Holders & Instruments
Centralize identity and attach banking and regulatory context.

