Skip to main content
Accounting Routes are Midaz’s two-layer validation system for financial transactions, built from Accounting Routes (which define the full transaction pattern) and Operation Routes (which validate each individual operation within that pattern). Together, they ensure every transaction is both structurally correct and compliant with your business rules.
Naming: This concept is called Accounting Routes in the Lerian Console and product documentation. In the API and SDKs the transaction-level route is represented by the transactionRoute resource (and transaction-route endpoints). The two terms refer to the same thing.
  • Accounting 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.
When a transaction is submitted, Midaz validates it in two layers: Accounting Routes ensure the overall structure matches the predefined pattern, while Operation Routes confirm that each component meets account requirements and business rules. If any part of the transaction fails these checks, it’s rejected before it can be recorded — protecting the integrity of your ledger without limiting its flexibility.
You define the validation patterns through Operation Routes and Accounting Routes. Midaz ensures your transactions comply with these rules before processing.

What are Accounting Routes for?


Accounting Routes provide 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.
Whether you’re processing simple transfers or complex multi-party transactions, Accounting Routes ensure your financial data remains structured, validated, and reliable at scale while providing the semantic foundation for advanced integrations.

Working with Accounting Routes


To use Accounting Routes, 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, enable the validation settings through the Ledger Settings API. This controls whether transactions in that Ledger must comply with your configured routes.
  • validateRoutes: When enabled, every transaction must reference a valid transaction route.
  • validateAccountType: When enabled, account types are validated against operation route rules.
Settings changes take effect immediately — no redeployment required. You can update them at any time via the API.

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.
  • code (deprecated): a legacy external reference kept for backward compatibility. It is not written to operations — the engine records the resolved rubric’s code (from accountingEntries) as routeCode on each operation instead.
  • description: Optional detailed explanation.
  • metadata: Key-value pairs for business context and custom categorization.
  • operationType: The accounting direction for this route — source, destination, or bidirectional.
    • source — Identifies accounts where funds originate (debit side).
    • destination — Identifies accounts where funds are sent (credit side).
    • bidirectional — Applies to both sides of the transaction, acting as both source and destination.
  • 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.
  • accountingEntries: Optional accounting entries for each action type. See Accounting Entries below.
Configure account rules based on your needs: Option A: No Account Rule If you don’t need account validation for the operation route, omit the account object:
Option B: Account Validation Rule If you need account validation for the operation, configure account rules based on your ledger setup:
  • Target Specific Account
Validate against a specific account using its alias.
  • Target Account Type
Validate against specific account types.
Option C: With Accounting Entries Attach accounting entries directly to the operation route through the accountingEntries field, mapping each transaction-lifecycle stage to the correct double-entry accounting codes. The full action-type model, debit/credit requirements, and validation matrix are covered in Configure Accounting Entries (Actions) below. A route with accounting entries configured:
The operationType field also supports bidirectional, which allows the route to operate in both directions — useful for routes that handle both sending and receiving, or for operations that may need to be reversed.

3. Build Accounting Routes

Complete your setup by combining Operation Routes into Accounting Routes (the transactionRoute resource in the API). These define your complete transaction patterns, mapping how different operations work together to form balanced financial events that match your business processes.
The operationRoutes field uses an array of objects with operationRouteId rather than a plain array of UUID strings.

4. Configure Accounting Entries (Actions)

Each Operation Route can include Accounting Entries — structured rubrics that define how debit and credit entries are recorded for each type of transactional event (direct, hold, commit, cancel, revert). They are what the engine uses to resolve which accounts get debited and credited for each action, and they determine the routeCode/routeDescription annotations written on each operation. Whether a missing rubric is tolerated (graceful) or rejected with 0117 ErrAccountingRouteNotFound (strict) is controlled by accounting.validateRoutes in the Ledger Settings.
The accounting-entry actions, the debit/credit requirements per operation type, the graceful vs. strict validation modes, and full configuration examples are documented in detail on the Accounting Entries page. This section covers only how rubrics attach to Operation Routes.
At the route level, accounting entries are supplied through the accountingEntries block (see Option C under Create Operation Routes above), with one entry per action and a debit and/or credit rubric depending on the route’s operationType:
  • Source routes require the debit rubric.
  • Destination routes require the credit rubric.
  • Bidirectional routes require both debit and credit rubrics.
Accounting entries validation matrix
Not every combination of operationType and action is valid. Midaz enforces a strict validation matrix when you create or update an Operation Route — if the rules aren’t met, the request is rejected before persisting. Understanding this matrix is critical for integrators: sending an invalid combination returns error 0166 (field required) or 0162/0165 (scenario not allowed for direction). source destination bidirectional
An entry with neither debit nor credit is always rejected, regardless of operation type or action.
Additional rules:
  • Reserve group atomicity: If you define hold, you must also define commit and cancel (and vice versa). These three actions form an atomic group — you can’t configure one without the others.
  • Direct is mandatory: If any other action (hold, commit, cancel, revert) is defined, direct must also be present. It serves as the baseline entry for the operation route.
When designing your operation routes, start with the direct action and add hold/commit/cancel only if you need two-phase transaction support. Add revert only on bidirectional routes.

Ongoing Operations

5. Execute Validated Transactions

With your routing configuration in place, you can now submit transactions with confidence by including the ID of the previously created Accounting 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 Accounting Route and Operation Routes examples, the system composes the following validation structure:
For route properties on Midaz transactions, an appropriate payload request:
When this transaction is submitted, Midaz validates that the @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.
Route fields on operations
When route validation is enabled and accounting entries are configured, every successfully processed operation will include two additional fields populated from the matched rubric:
  • routeCode — The code of the resolved AccountingRubric for that operation’s action and direction.
  • routeDescription — The description of the resolved accounting rubric, populated alongside routeCode.
These fields provide a direct link between each operation and its accounting classification, enabling downstream systems (such as Reporter) to produce accurate financial reports without additional lookups.

Managing Operation and Accounting Routes


To configure your Operation Routes, use the following endpoints: To configure your Accounting Routes (the transactionRoute resource in the API), use the following endpoints: