Lerian APIs
This section answers frequently asked questions about Lerian’s APIs, covering 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. Once updated and the application is restarted, the API will accept larger page sizes.Important: Increasing the page size may affect response times, especially in environments handling large datasets. Always test thoroughly in staging before applying changes in production.Multi-tenancy and SaaS
Common questions about 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
Here, you will find the answers to common questions about 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.
- 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, it will also have two corresponding account_id values. To simplify retrieval, a Portfolio is created for that CPF, linking both accounts under a single structure. This ensures easier access and management of related accounts.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) can be linked 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?
- In the Midaz Ledger, when an Asset (e.g., BRL) is created, an External Account associated with that asset is also generated.
- This External Account acts as a gateway between the Lerian ecosystem and the external world. In other words, it serves as a mirror of the balances held by the institution in its PI account, settlement account, reserve account, or even a traditional bank or payment account holding the actual funds.
- To deposit funds into a user account with a specific Asset coming from outside the Midaz Ledger, the process is as follows:
- Initiate a transaction where the source is the External Account and the destination is the target account(s).
- As a result, the External Account will be debited by the transferred amount (becoming negative), while the destination account(s) will be credited accordingly, based on the values provided 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 our APIs, enabling you to generate a visual receipt in the format of your choice.
- Using the Reporter - Extract transaction data and create customized visual receipts.
- Through the Console - Access transaction information directly from the Lerian Console.
Entities
How can I create an Entity?
How can I create an Entity?
entity_id) is open for external IDs, with no validation enforced by Midaz. This means you can use the IDs that already exist in your database, seamlessly integrating 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?
What's the default TTL if I don't send X-TTL?
What's the default TTL if I don't send X-TTL?
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 (e.g., Assets, Liabilities, Revenue, Expenses) and assign them to accounts in your ledger. When the Account Types feature is enabled, the type field in the Accounts API becomes mandatory and must match one of the values you’ve registered.
- Transaction Routing - Use Operation Routes to validate each “leg” of a transaction (e.g., debit must come from an account type
user_wallet) and Transaction Routes to define complete transaction patterns that align with your accounting logic.
Plugins
Plugins extend the capabilities of Midaz, enabling seamless integration and process orchestration. Designed to remove complexity, they provide powerful abstractions that let you focus on your business model while ensuring efficiency and scalability. Explore the most common questions about how plugins work, their deployment, and the options available to enhance your operations.
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: Developed and fully integrated into the Midaz ledger by Lerian, these plugins ensure complete support and seamless integration with the platform.
- Marketplace Plugins: Created by Lerian’s partners to serve specific market niches, these plugins are available in the marketplace. Lerian facilitates their integration into Midaz, but their offering and support are managed directly by the respective partners.
Plugin Fees
Frequently asked questions about the Plugin Fees — the Lerian service responsible for calculating and charging fees on financial transactions.
General Concepts
What is the Plugin Fees?
What is the Plugin Fees?
- 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 the Plugin Fees fit into the Lerian ecosystem?
How does the Plugin Fees fit into the Lerian ecosystem?
What do I need to send in every request to the Plugin Fees?
What do I need to send in every request to the Plugin Fees?
X-Organization-Id header with your Organization ID in Midaz. This is an organization-scope header specific to Plugin Fees, not a tenant identifier — your tenant context is still resolved automatically from the JWT. When the authentication plugin is active, a Bearer token in the Authorization header is also required.What database does the Plugin Fees use for storage?
What database does the Plugin Fees use for storage?
deletedAt. This means “deleted” records don’t appear in listings but can still be audited.What is the minimum Midaz version required to use the Plugin Fees?
What is the minimum Midaz version required to use the Plugin Fees?
Fee Packages
What is a Fee Package?
What is a Fee Package?
Package) is a set of charging rules grouped under a feeGroupLabel. Each package is linked to an Organization + Ledger and optionally to a Segment. A package can contain multiple individual 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 creating or updating the package. A disabled package is not considered during fee calculation, even if 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 doesn’t fit this range, the package is ignored.Example: A package with minimumAmount: 100 and maximumAmount: 5000 will only charge fees on transactions between 100 and 5,000.maximumAmount is not defined, the package may 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. When set, the package will only be considered for transactions with that specific route (e.g., "PIX", "TED", "BOLETO").What are waivedAccounts?
What are waivedAccounts?
waivedAccounts, the package fees are not applied 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 the fee is calculated. See Calculation Models for full details. There are three options:| Rule | Description |
|---|---|
flatFee | Fixed-amount fee |
percentual | Percentage fee based on the reference amount |
maxBetweenTypes | Calculates both flat and percentage; applies the greater result |
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 (combining flat and percentage). The system calculates both and applies the greater resulting value.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 — the system evaluates all and applies the greatest. However, 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 the fee is calculated on:originalAmount: the original transaction value, before any fees are applied.afterFeesAmount: the transaction value after higher-priority fees have already been applied.
priority: 1 (the first to be executed) must use originalAmount. This makes sense: there are no prior fees to consider.What is isDeductibleFrom and when should I use it?
What is isDeductibleFrom and when should I use it?
isDeductibleFrom: true, the fee is deducted from the amount sent by the sender. The recipient receives the amount already discounted, and the sender pays extra to cover the charge.When false, the fee is charged separately (the sender sends the full amount and the fee is debited 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. Lower values are executed first.priority: 1→ executed first (must useoriginalAmount)priority: 2→ executed after, can useafterFeesAmount
What is creditAccount?
What is creditAccount?
creditAccount — useful when different fees need to be accounted for in 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 the first 100 transactions in the period are not charged.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?
| Endpoint | When to use |
|---|---|
POST /v1/fees | Calculate the actual fee of an ongoing transaction. See the Calculate Fees API reference. The system automatically finds applicable packages based on ledger, segment, route, and amount. |
POST /v1/estimates | Simulate the fee of a specific package before confirming the transaction. Useful for showing end users the cost before execution. See the Simulate Fees API reference. |
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 allows you to simulate the fee of a specific package (packageId), without needing an actual transaction. Ideal for:- Displaying the estimated cost to the user before confirming.
- Testing configurations of newly created packages.
- Building 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 doesn’t alter state or register transactions. It’s 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". This is because it’s the first fee to be calculated — there are no prior fees 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 be greater than the package’s minimumAmount. This prevents scenarios where the fee exceeds the minimum transaction value itself.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 and the type is percentage with a value above 100. A deductible percentage fee of 100% would zero out the transaction — values above that 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 ensures transactions above the highest defined range are still priced."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. Don’t 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 are not removed from the database. However, the API does not expose restoration endpoints by default. Contact the Lerian team if you need to recover an accidentally deleted record. For a complete list of error codes, see the Error Codes reference.
