Lerian APIs
This section answers common questions about Lerian’s APIs. It covers general behavior, configuration, and best practices across all services.
Is there a maximum number of records per page in API listings? Can I increase this limit?
Is there a maximum number of records per page in API listings? Can I increase this limit?
MAX_PAGINATION_LIMIT environment variable in your deployment configuration. The API accepts larger page sizes after you restart the application.Important: A larger page size can slow response times, especially with large datasets. Test in staging before you change production.Multi-tenancy and SaaS
These questions cover data isolation, tenant scoping, and how multi-tenancy works in Lerian deployments.
Is my data isolated from other customers in SaaS?
Is my data isolated from other customers in SaaS?
Do I need to pass a tenant ID in my API requests?
Do I need to pass a tenant ID in my API requests?
Can I have multiple Organizations under a single tenant?
Can I have multiple Organizations under a single tenant?
Is the API different between SaaS and self-hosted deployments?
Is the API different between SaaS and self-hosted deployments?
Midaz
These questions cover Organizations, Ledgers, Accounts, Transactions, and more in Midaz.
Organizations
Do different Organizations communicate with each other?
Do different Organizations communicate with each other?
Can I use a single license across multiple Organizations?
Can I use a single license across multiple Organizations?
Can an Organization have multiple Plugins?
Can an Organization have multiple Plugins?
Can an Organization have multiple Ledgers?
Can an Organization have multiple Ledgers?
Can I create transactions between a Parent Organization and a Child Organization?
Can I create transactions between a Parent Organization and a Child Organization?
Ledgers
Do different Ledgers communicate with each other?
Do different Ledgers communicate with each other?
How can I make transactions between Ledgers?
How can I make transactions between Ledgers?
Do I need a separate Ledger for each Plugin?
Do I need a separate Ledger for each Plugin?
Assets
Can an Asset be linked to multiple Accounts?
Can an Asset be linked to multiple Accounts?
What types of Assets can I use?
What types of Assets can I use?
- currency: Traditional fiat currencies like BRL, USD, and EUR.
- fiat: An alternative type for fiat currencies; like
currency, the Asset code must follow ISO 4217. - crypto: Digital assets such as BTC, ETH, and other cryptocurrencies.
- commodities: Tangible goods like gold, soybean, and oil.
- others: Custom Assets, including loyalty points and tokenized securities.
Portfolios
How does a Portfolio work?
How does a Portfolio work?
segment_id values has two matching account_id values. You create a Portfolio for that CPF to link both accounts under one structure. This makes related accounts easier to find and manage.Accounts
Can an Account be associated with multiple Assets?
Can an Account be associated with multiple Assets?
What is an External Account?
What is an External Account?
How can I create an External Account?
How can I create an External Account?
Can an Account be linked to several Segments?
Can an Account be linked to several Segments?
account_id) links to only one Segment (segment_id).Is there a limit to how many Accounts I can create in Midaz?
Is there a limit to how many Accounts I can create in Midaz?
What is the process for adding funds to an account or performing a cash-in using money coming from outside the Ledger (Midaz) environment?
What is the process for adding funds to an account or performing a cash-in using money coming from outside the Ledger (Midaz) environment?
- When you create an Asset (for example, BRL) in the Midaz Ledger, Midaz also creates an External Account for that Asset.
- This External Account mirrors the balances the institution holds outside Midaz. Those balances can sit in a PI account, a settlement account, a reserve account, or a traditional bank or payment account.
- To deposit funds from outside the Midaz Ledger into a user account, follow these steps:
- Create a transaction with the External Account as the source and the target accounts as the destination.
- Midaz debits the External Account by the amount (so it becomes negative) and credits the destination accounts by the values in the transaction payload.
Transactions
What is the minimum structure of a Transaction?
What is the minimum structure of a Transaction?
- Operation 1: Debit R$ 100 from Account A.
- Operation 2: Credit R$ 100 to Account B.
Is it possible to generate a PDF transfer receipt containing the details of a completed transaction?
Is it possible to generate a PDF transfer receipt containing the details of a completed transaction?
- Via APIs — Retrieve transaction data through the APIs, then generate a visual receipt in any format you choose.
- With the Reporter — Extract transaction data and create custom visual receipts.
- Through the Console — Access transaction data directly in the Lerian Console.
Entities
How can I create an Entity?
How can I create an Entity?
entity_id) accepts external IDs. Midaz enforces no validation on this field. You can use the IDs that already exist in your database and integrate them into your system.Idempotency
What happens if I don't send an idempotency key?
What happens if I don't send an idempotency key?
Can I reuse an idempotency key across endpoints?
Can I reuse an idempotency key across endpoints?
What happens if I change the TTL on a retry?
What happens if I change the TTL on a retry?
Will the replayed response always be identical?
Will the replayed response always be identical?
X-Idempotency-Replayed header to true.What's the default TTL if I don't send X-TTL?
What's the default TTL if I don't send X-TTL?
X-TTL header to set a custom value in seconds.Accounting in Midaz
How can I reflect my own Chart of Accounts in Midaz?
How can I reflect my own Chart of Accounts in Midaz?
- Account Types — Create the logical categories from your chart, such as Assets, Liabilities, Revenue, and Expenses. Assign them to accounts in your ledger. When you enable the Account Types feature, the
typefield in the Accounts API becomes mandatory and must match a registered value. - Accounting Routes — Use Operation Routes to validate each leg of a transaction. For example, a debit must come from an account of type
user_wallet. Use Accounting Routes (thetransactionRouteresource in the API) to define complete transaction patterns that match your accounting logic.
Plugins
Plugins extend Midaz with integration and process orchestration. They provide abstractions so you can focus on your business model instead of system logic outside your domain. The questions below cover how plugins work, how you deploy them, and the options available.
What are Plugins?
What are Plugins?
Can plugins be used without Midaz?
Can plugins be used without Midaz?
How are plugins distributed?
How are plugins distributed?
What plugin options does Lerian offer?
What plugin options does Lerian offer?
- Native Plugins: Lerian develops and integrates these plugins into the Midaz ledger. Lerian provides full support for them.
- Marketplace Plugins: Lerian’s partners create these plugins for specific market niches. Lerian helps integrate them into Midaz. The partners provide and support them directly.
Fees Engine
These questions cover Fees Engine. Fees Engine is a licensed Midaz capability that runs inside the unified ledger process.
General Concepts
What is Fees Engine?
What is Fees Engine?
- Fee Packages (
/v1/packages): defines charging rules per transaction (flat fee, percentage, or whichever is greater). - Billing Packages (
/v1/billing-packages): defines periodic charges based on transaction volume or account maintenance. - Calculation and Estimation (
/v1/feesand/v1/estimates): endpoints for calculating fees in real time or simulating before confirming.
How does Fees Engine fit into the Lerian ecosystem?
How does Fees Engine fit into the Lerian ecosystem?
What do I need to send in every request to Fees Engine?
What do I need to send in every request to Fees Engine?
X-Organization-Id header with your Organization ID in Midaz. This header scopes the request to an Organization. It is specific to Fees Engine, not a tenant identifier. The platform still resolves your tenant context automatically from the JWT. When the authentication plugin is active, you also send a Bearer token in the Authorization header.What database does Fees Engine use for storage?
What database does Fees Engine use for storage?
deletedAt instead. A deleted record does not appear in listings, but you can still audit it.What is the minimum Midaz version required to use Fees Engine?
What is the minimum Midaz version required to use Fees Engine?
Fee Packages
What is a Fee Package?
What is a Fee Package?
Package) is a set of charging rules under one feeGroupLabel. Each package links to an Organization + Ledger, and optionally to a Segment. A package can contain several fees (Fee objects), each with its own calculation logic. Learn more about Fee Packages.How do I create a Fee Package?
How do I create a Fee Package?
POST /v1/packages with the following body. See the Create Package API reference for full details.Can a package be temporarily disabled?
Can a package be temporarily disabled?
enable field to false when you create or update the package. Fees Engine skips a disabled package during fee calculation, even when the transaction context matches its scope.How does the package scope work (minimumAmount / maximumAmount)?
How does the package scope work (minimumAmount / maximumAmount)?
[minimumAmount, maximumAmount] range. If the transaction value falls outside this range, Fees Engine ignores the package.Example: A package with minimumAmount: 100 and maximumAmount: 5000 charges fees only on transactions between 100 and 5,000.maximumAmount, the package can apply without an upper limit. Check the validation rules for your version.Can I filter a package by transaction route?
Can I filter a package by transaction route?
transactionRoute field in the package. Fees Engine then considers the package only for transactions with that route, such as "PIX", "TED", or "BOLETO".What are waivedAccounts?
What are waivedAccounts?
waivedAccounts, Fees Engine does not apply the package fees to it.Do listing endpoints have pagination?
Do listing endpoints have pagination?
GET /v1/packages, GET /v1/billing-packages) support the limit and page query parameters for pagination.Calculation Models
What calculation models are available?
What calculation models are available?
applicationRule field inside calculationModel defines how Fees Engine calculates the fee. See Calculation Models for full details. There are three options:How do I configure a flat fee (flatFee)?
How do I configure a flat fee (flatFee)?
flat:How do I configure a percentage fee (percentual)?
How do I configure a percentage fee (percentual)?
percentage:How does maxBetweenTypes work?
How does maxBetweenTypes work?
maxBetweenTypes requires 2 or more calculations that combine flat and percentage. Fees Engine calculates both and applies the greater result.Example: Minimum fee of 3.00 or 1% of the value — whichever is greater:Can I mix multiple percentages in maxBetweenTypes?
Can I mix multiple percentages in maxBetweenTypes?
flat and percentage. Fees Engine evaluates all of them and applies the greatest. Note that flatFee and percentual require exactly 1 calculation. Only maxBetweenTypes accepts 2 or more.Important Fields
What is referenceAmount and how does it affect calculation?
What is referenceAmount and how does it affect calculation?
referenceAmount defines which value Fees Engine calculates the fee on:originalAmount: the original transaction value, before any fees.afterFeesAmount: the transaction value after higher-priority fees apply.
priority: 1 runs first, so it must use originalAmount. No prior fees exist to consider.What is isDeductibleFrom and when should I use it?
What is isDeductibleFrom and when should I use it?
isDeductibleFrom: true, Fees Engine deducts the fee from the amount the sender sends. The recipient receives the discounted amount, and the sender pays extra to cover the charge.When false, Fees Engine charges the fee separately. The sender sends the full amount, and Fees Engine debits the fee apart.Constraints:isDeductibleFrom: truerequiresreferenceAmount: originalAmount- If the type is
percentage: the value cannot exceed 100 - If the type is
flat: the value cannot exceed the package’sminimumAmount
How does the priority field work?
How does the priority field work?
priority defines the execution order of fees within a package. Fees Engine runs lower values first.priority: 1→ executed first (must useoriginalAmount)priority: 2→ executed after, can useafterFeesAmount
What is creditAccount?
What is creditAccount?
creditAccount. This helps when different fees belong to different cost centers.What are routeFrom and routeTo inside a fee?
What are routeFrom and routeTo inside a fee?
Billing Packages
What are Billing Packages?
What are Billing Packages?
volume: charges based on the number of transactions in a period, with tiered pricing.maintenance: charges a fixed fee per account in a given scope.
When should I use volume billing?
When should I use volume billing?
maxQuantity). There must be no gaps or overlaps between tiers.When should I use maintenance billing?
When should I use maintenance billing?
segmentId, portfolioId, or aliases) and the fee amount.accountTarget must have exactly one of the three fields: segmentId, portfolioId, or aliases (maximum 100 aliases).How do tiers work in volume billing?
How do tiers work in volume billing?
- Must be contiguous — no gaps between tiers (
minQuantityof the next =maxQuantityof the previous + 1). - Must not overlap.
- The last tier must be unbounded (no
maxQuantity).
What is freeQuota?
What is freeQuota?
freeQuota: 100 means Fees Engine does not charge the first 100 transactions in the period.What are discountTiers?
What are discountTiers?
tiers.What is countMode in volume billing?
What is countMode in volume billing?
perRoute: counts transactions by route (e.g., total approved Pix).perAccount: counts transactions per individual account.
Fee Calculation and Estimation
What is the difference between /v1/fees and /v1/estimates?
What is the difference between /v1/fees and /v1/estimates?
How does /v1/fees work?
How does /v1/fees work?
ledgerId— requiredsegmentId— optionaltransactionRoute— optional- Transaction value — compared with the package’s
minimumAmount/maximumAmount
How does /v1/estimates work?
How does /v1/estimates work?
/v1/estimates endpoint simulates the fee of a specific package (packageId). You do not need an actual transaction. It works well for:- Show the estimated cost to the user before confirmation.
- Test configurations of newly created packages.
- Build fee simulators in your product.
Can I use /v1/estimates in production to show fees to end users?
Can I use /v1/estimates in production to show fees to end users?
/v1/estimates is a read-only endpoint. It does not alter state or register transactions. It is safe to use in UX flows to show the cost before confirmation.How do I calculate billing?
How do I calculate billing?
Common Errors
"Priority 1 must use originalAmount" — what does this mean?
"Priority 1 must use originalAmount" — what does this mean?
priority: 1 must have referenceAmount: "originalAmount". It is the first fee to run, so no prior fees exist to base the calculation on.Fix:"isDeductibleFrom requires originalAmount" — how to fix?
"isDeductibleFrom requires originalAmount" — how to fix?
isDeductibleFrom: true can only use referenceAmount: "originalAmount". Update the field:"Flat fee value cannot exceed minimumAmount" — why?
"Flat fee value cannot exceed minimumAmount" — why?
isDeductibleFrom: true and the type is flat, the fee value cannot exceed the package’s minimumAmount. This prevents a fee that is larger than the minimum transaction value.Example: If minimumAmount: 100, the flat fee cannot exceed 100."Percentage value cannot exceed 100" — when does this occur?
"Percentage value cannot exceed 100" — when does this occur?
isDeductibleFrom: true, the type is percentage, and the value is above 100. A deductible percentage fee of 100% would zero out the transaction. Values above 100 are invalid."Tiers must be contiguous" — how to fix?
"Tiers must be contiguous" — how to fix?
minQuantity of each tier is exactly maxQuantity + 1 of the previous tier."Last tier must be unbounded" — what does this mean?
"Last tier must be unbounded" — what does this mean?
maxQuantity). This keeps a price on transactions above the highest defined range."accountTarget must have exactly one of: segmentId, portfolioId, aliases"
"accountTarget must have exactly one of: segmentId, portfolioId, aliases"
accountTarget field accepts only one of the three options. Do not combine fields:Is there a limit on aliases in accountTarget?
Is there a limit on aliases in accountTarget?
aliases field accepts a maximum of 100 aliases per maintenance Billing Package."flatFee requires exactly 1 calculation of type flat"
"flatFee requires exactly 1 calculation of type flat"
applicationRule: "flatFee" accepts exactly 1 calculation, and it must be of type flat. Do not use percentage with flatFee."percentual requires exactly 1 calculation of type percentage"
"percentual requires exactly 1 calculation of type percentage"
flatFee, the applicationRule: "percentual" accepts exactly 1 calculation of type percentage."maxBetweenTypes requires 2 or more calculations"
"maxBetweenTypes requires 2 or more calculations"
maxBetweenTypes requires at least 2 calculations to work — it needs values to compare. Provide at least one flat and one percentage.The package is not being applied to the transaction — what should I check?
The package is not being applied to the transaction — what should I check?
enable: is the package active (enable: true)?ledgerId: is the package linked to the correct ledger?minimumAmount/maximumAmount: is the transaction value within the range?transactionRoute: if the package hastransactionRoute, does the transaction use the same route?segmentId: if the package is scoped to a segment, does the account belong to it?waivedAccounts: is the account listed as exempt?
Can a deleted record be recovered?
Can a deleted record be recovered?
deletedAt and does not remove them from the database. The API does not expose restoration endpoints by default. Contact the Lerian team if you need to recover a deleted record. For a full list of error codes, see the Error Codes reference.
