- Transaction Routes define the complete structure of a transaction — the required sequence of operations and how they fit together to form a valid financial event.
- Operation Routes define the rules for each individual operation (or “leg”) of that transaction, including the expected account type or specific account, the accounting annotation, and whether it’s a debit or credit.
You define the validation patterns through Operation Routes and Transaction Routes. Midaz ensures your transactions comply with these rules before processing.
What is Transaction Routing for?
Transaction Routing provides structured control over your financial operations by separating transaction logic from business code. Instead of hardcoding validation rules in your application, you configure reusable patterns that ensure every financial movement follows your organization’s requirements. These entities are dedicated to linking Transactions and Operations from the Midaz ledger to higher-level abstractions that facilitate integration with specialized plugins and external systems, especially for accounting and treasury abstractions. The structured annotations and classifications create a standardized vocabulary that other components can understand and leverage. This approach delivers:- Consistency: All transactions follow predefined structures regardless of where they originate.
- Flexibility: Adapt your ledger design to match your business needs without code changes.
- Integrity: Automatic validation prevents malformed transactions from affecting your ledger.
- Maintainability: Centralized configuration makes it easier to update financial rules as your business evolves.
- Interoperability: Business-semantic fields enable seamless integration with accounting plugins and external financial systems.
Working with Transaction Routing
To use Transaction Routing, you must complete the initial configuration followed by ongoing transaction execution. Here’s your step-by-step process:Initial Setup
1. Configure Ledger for Transaction Route Validation
To activate transaction route validation for a specific ledger, you must configure it in the Transaction service. This means updating the Transaction variables in the.env
file of Midaz Transaction service where you want to use route validation.
Your configuration should look like this:
2. Create Operation Routes
Create Operation Routes that define validation rules and behavior for individual transaction components. Key fields:- title: Brief label that identifies the operation route.
- description: Optional detailed explanation.
- metadata: Key-value pairs for business context and custom categorization.
- operationType:
source
ordestination
indicating the operation’s directional flow. - account: Optional validation rules specifying required account type or specific account.
- ruleType: Type of account validation rule (
account_type
,alias
). - validIf: The expected value that must match for validation to pass.
- ruleType: Type of account validation rule (
- Target Specific Account
- Target Account Type
3. Build Transaction Routes
Complete your setup by combining Operation Routes into Transaction Routes. These define your complete transaction patterns, mapping how different operations work together to form balanced financial events that match your business processes.Ongoing Operations
4. Execute Validated Transactions
With your routing configuration in place, you can now submit transactions with confidence by including the ID of the previously created Transaction Route in your transaction request. Midaz will automatically validate the transaction against your defined routing patterns, ensuring consistency and integrity across all financial operations. For the previously configured Transaction Route and Operation Routes examples, the system composes the following validation structure:@user/wallet_123
account matches the user_wallet
account type rule, and @external/BRL
matches the exact alias requirement, ensuring the transaction follows your configured routing patterns.
Managing Operation and Transaction Routes
To configure your Operation Routes, use the following endpoints:- Create an Operation Route — Define a new accounting rule for your operations.
- List Operation Routes — View all configured Operation Routes.
- Retrieve an Operation Route — Get detailed information on a specific Operation Route.
- Update an Operation Route — Modify existing accounting rules.
- Delete an Operation Route — Remove an outdated or unused Operation Route.
- Create a Transaction Route — Define new routing logic to connect transactions to accounting operations.
- List Transaction Routes — View all configured Transaction Routes.
- Retrieve a Transaction Route — Get details of a specific Transaction Route.
- Update a Transaction Route — Modify existing routing criteria.
- Delete a Transaction Route — Remove routes that are no longer applicable.