> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# TED Lerian business rules

> How TED Lerian applies the operating window, usage limits, fees, idempotency, regulatory deadlines and personal data rules.

## Operating window

***

The effective window of a day combines three sources. `GET /v1/policy/window` returns which one decided (`source`).

* **The official STR schedule**, published by Lerian SPB. Schedule changes the STR announces during the day apply without a restart.
* **The institution's cut-off**, optional, always equal to or earlier than the official close. TED Lerian refuses a later time with `TED-0081`.
* **The national holiday calendar**, kept per year.

| Situation | Answer when you send a TED |
| - | - |
| Outside the schedule or after the cut-off | `422 TED-0020`, nothing held |
| Weekend or holiday | `422 TED-0021`, nothing held |
| The window could not be determined | `503 TED-0022`. TED Lerian refuses rather than guessing. |
| Internal transfer | The STR window does not apply |

## Usage limits

***

* Per source account: a maximum per transfer, a total per day and a total per month, by calendar day and month in Brasília time (`America/Sao_Paulo`). The ceilings follow the order transfer ≤ day ≤ month. A missing ceiling means no ceiling.
* They count the total debited: the amount plus the fee.
* An institution must configure its limits before the first TED. Without them, TED Lerian refuses each send with `503 TED-0080`.
* Above a limit, TED Lerian refuses the TED before the hold with `422 TED-0030`. The answer names the limit.
* A rejected or cancelled transfer frees them up again.
* With `enabled=false`, the limits count nothing and refuse nothing.
* Only the administrator changes them. Each change records who made it and when.

## Fees

***

* Charging a fee is optional and off by default. While it is off, every fee is zero: on the quote, on sending and on receiving.
* When it is on for an institution, Midaz calculates the fee from the configured fee package (`feePackageId`).
* The quote shows the fee and the total with no financial effect. The quoted fee is the fee that a send of the same request would hold.
* If the calculation is unavailable when you send, TED Lerian refuses the TED with `503 TED-0040`. The institution can choose to send with a zero fee in that case instead.
* On an incoming TED, the fee shows in `feeAmount` and the credited amount in `creditedAmount`. If the calculation fails, the customer receives the full amount with a zero fee.
* When another institution returns a TED, TED Lerian does not refund the sending fee by default. The institution can turn the refund on, and `returned.feeRefunded` shows what happened.

## Idempotency and duplicate requests

***

* Every write needs the `X-Idempotency` header: 1 to 128 printable ASCII characters. Without it, the answer is `400 TED-0011`.
* The same key with the same body returns the original response with `X-Idempotency-Replayed: true`. TED Lerian creates no new transfer.
* `X-TTL` sets for how many seconds TED Lerian replays the response (default 300). Only the TTL of the first request counts.
* A request with the same key and another body gets `422 TED-0012`. On `POST /v1/transfers`, the key stays bound to the transfer it created: a later request with the same key never creates a second transfer.
* A request with the same key still in progress gets `409 TED-0013` with `Retry-After`.
* Whatever the key, `POST /v1/transfers` refuses a materially identical request in the same anti-duplication window (5 minutes by default) with `409 TED-0014`.

## Regulatory deadlines

***

| Deadline | Starts at | Ends at | Limit |
| - | - | - | - |
| Debit to submission | The debit hold | Submission to the STR | 30 min |
| Settlement to credit | Interbank settlement at the STR | Credit to the recipient | 60 min |
| Settlement to return | Interbank settlement at the STR | The return | 60 min |

`GET /v1/operations/sla` shows p50, p95 and p99 for each deadline, the breaches of the day and the items at risk.

## Personal data

***

* **API responses:** the name and the CPF or CNPJ of the sender and of the recipient come in full, for roles allowed to read them.
* **Logs:** TED Lerian masks documents and names.
* **Events for sent TEDs** (`transfer.*`) carry no counterparty data.
* **Events for incoming TEDs** (`incoming_transfer.*`) carry the recipient, the institution's own customer, in full. The sender, a customer of another institution, is masked.
* The free-text description of an incoming TED is published as the sending institution wrote it.

## Isolation between institutions

***

Each record belongs to one institution. The institution always comes from the authenticated token, never from a field in the request. An identifier from another institution answers as not found (`404`), without revealing that it exists.

## Audit

***

Each transfer has a timeline that is never edited. It records each status change with the date and time, the origin (`API`, `RAIL`, `STR`, `LEDGER`, `WORKER`, `OPERATOR`, `SYSTEM`), the official reason and, for operator actions, who acted. TED Lerian deletes no business record.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.