> ## 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.

# Payment rails

> Reach Brazil's payment systems through Lerian-owned messaging to BACEN, or through a connectivity partner.

Brazil's payment systems each carry their own messaging contract, certification, and operating windows. Depending on the payment system, you reach BACEN on Lerian-owned software or through a connectivity partner. Both models preserve your ledger, your accounts, and your business logic.

A Brazil rail is Lerian-owned messaging software that connects your institution to BACEN or to a market infrastructure, with no intermediary. An interface is the product surface over a rail. Lerian offers its own interfaces (TED Lerian, Pix Lerian) and partner interfaces (Pix JD, Pix BTG, TED JD, Payments BTG). Partner interfaces ship as Midaz plugins: separately deployed services that extend Midaz and that Lerian licenses separately.

Pix runs in production through two interfaces. [The JD interface](/en/rails/pix/jd/direct-pix-via-jd) connects your institution as a direct participant through a certified PSTI. [The BTG interface](/en/rails/pix/btg/indirect-pix-overview) connects you as an indirect participant. TED runs through JD. The native Lerian rails are Lerian-owned software for a direct, non-intermediated connection to BACEN. They do not replace the JD and BTG paths.

## What you get

***

<Columns cols={3}>
  <Card title="Brazil Rails" icon="money-bill-transfer" href="/en/rails/what-are-brazil-rails">
    Lerian-owned messaging straight to BACEN and its market infrastructures.
  </Card>

  <Card title="Interfaces" icon="plug" href="/en/interfaces/introduction">
    The product surface over a rail: the API, the ledger integration, and the operational controls.
  </Card>

  <Card title="Midaz" icon="https://mintcdn.com/lerian-49cb71fc/fChpL6UWCA02zfZr/images/icons/midaz-yellow.png?fit=max&auto=format&n=fChpL6UWCA02zfZr&q=85&s=66030808cf88e9836f58b228bdb04718" href="/en/midaz/what-is-midaz" width="270" height="270" data-path="images/icons/midaz-yellow.png">
    The ledger that records the money an interface moves.
  </Card>

  <Card title="Reporter" icon="https://mintcdn.com/lerian-49cb71fc/fChpL6UWCA02zfZr/images/icons/reporter-yellow.png?fit=max&auto=format&n=fChpL6UWCA02zfZr&q=85&s=9b7bb2c96d24d86b973ab98b82eb825b" href="/en/reporter/what-is-reporter" width="270" height="270" data-path="images/icons/reporter-yellow.png">
    Renders the daily CCS remittance file Lerian CCS submits.
  </Card>

  <Card title="Streaming Hub" icon="tower-broadcast" href="/en/streaming-hub/what-is-streaming-hub">
    Delivers Lerian CCS and Lerian SCR events to a sink you own.
  </Card>
</Columns>

## How the pieces fit together

***

```mermaid theme={null}
flowchart LR
  App["Your application"]
  Iface["TED Lerian<br/>Lerian interface"]
  Rail["Lerian SPB<br/>native messaging to the STR"]
  Plugin["Pix JD, Pix BTG, TED JD, Payments BTG<br/>plugins that post to Midaz"]
  PixLerian["Pix Lerian<br/>Lerian interface, posts to Midaz"]
  LerianSPI["Lerian SPI<br/>native messaging to SPI/DICT"]
  Partner["JD, BTG, or the provider you contract"]
  Bacen["BACEN"]
  Ledger["Your ledger consumer<br/>records the movement"]
  Midaz["Midaz ledger"]
  App -->|"API call"| Iface
  Iface -->|"messages"| Rail
  Rail -->|"RSFN, no intermediary"| Bacen
  Rail -.->|"settlement facts"| Ledger
  App -->|"API call"| Plugin
  App -->|"API call"| PixLerian
  Plugin -->|"provider API"| Partner
  PixLerian -->|"provider API"| Partner
  Partner -->|"regulated connectivity"| Bacen
  PixLerian -->|"native SPI/DICT"| LerianSPI
  LerianSPI -->|"RSFN, no intermediary"| Bacen
  LerianSPI -.->|"settlement facts"| Ledger
  Plugin -->|"posts to Midaz"| Midaz
  PixLerian -->|"posts to Midaz"| Midaz
  classDef lerian fill:#fff8e1,stroke:#f4b400,color:#333;
  classDef yours fill:#e8f0fe,stroke:#4285f4,color:#333;
  classDef ext fill:#f1f3f4,stroke:#9aa0a6,color:#333;
  class Iface,Rail,Plugin,PixLerian,LerianSPI,Midaz lerian;
  class App,Ledger yours;
  class Partner,Bacen ext;
```

The native path takes four steps:

1. Your application calls TED Lerian. The interface gives you the API, the ledger events, and the operator workflows.
2. TED Lerian hands the message to Lerian SPB, which reaches the STR over the RSFN.
3. Lerian SPB dispatches the message to BACEN, with no connectivity partner in the path. BACEN confirms settlement asynchronously.
4. The rail emits settlement facts and computes no balance of its own. Your ledger consumer records the money movement.

Lerian SPI, the native Pix rail, has the same shape: it holds no accounting position and emits settlement facts for your ledger consumer. Pix Lerian sits above it and connects Lerian SPI to the rest of your stack.

The partner path takes three steps:

1. Your application calls a plugin. Pix JD, Pix BTG, TED JD, and Payments BTG ship as Midaz plugins. Pix Lerian is Lerian's own Pix plugin, and it also posts to Midaz.
2. The provider carries the regulated connectivity. JD reaches BACEN's SPI and DICT for a direct participant, and BTG connects an indirect participant.
3. Pix JD posts every settled Pix movement to Midaz, with the external leg against the clearing account. TED JD reserves funds in Midaz as a hold, then debits them when the transfer settles. Payments BTG records boletos and bill payments against your Midaz ledger.

Pix Lerian is Lerian's Pix plugin, and one plugin serves every path below it. Midaz is its mandatory ledger. It covers account validation, balance checks, debit and credit posting, and routing. Pix Lerian does not speak to BACEN itself. The gateway layer below it is a direct participant, a certified PSTI, or Lerian SPI.

Two more chains run on files rather than payment messages.

Reporter renders your daily ACCS001 remittance from your customer data. Lerian CCS reads that file, builds one batch line item per operation, and submits it through Lerian STA. Lerian CCS does not connect to BACEN directly, and it cannot build the file without Reporter. BACEN answers on the inbound file channel. An accepted record moves that customer relationship to the accepted state.

Courts issue asset orders, and BACEN delivers them through its STA channel. Lerian SISBAJUD receives each order as a fixed-layout file. It runs the block or unblock against your Midaz ledger and reports each outcome to BACEN. No order enters through the API.

Lerian SLC sends card settlement files to Nuclea over the RSFN, and Lerian SILOC relays card traffic to it.

## What each piece owns

***

| Piece                                                     | Source of truth for                                                | Talks to                                                 | You keep                                                                                                                            |
| --------------------------------------------------------- | ------------------------------------------------------------------ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Native rail (Lerian SPI, SPB, SLC, SILOC)                 | the message and its settlement state                               | BACEN or the market infrastructure, with no intermediary | your ledger, accounts, and business logic                                                                                           |
| Lerian interface (TED Lerian)                             | the API, the ledger events, the operator workflows                 | the rail below it                                        | your application contract                                                                                                           |
| Partner interface (Pix JD, Pix BTG, TED JD, Payments BTG) | the provider integration and its postings                          | JD or BTG, and Midaz                                     | your ledger data. BTG provides connectivity, not account management                                                                 |
| Pix Lerian                                                | the Pix application layer: orchestration, keys, QR codes, disputes | the provider you contract, and Midaz                     | your ledger. Pix Lerian requires you to own the ledger layer logically                                                              |
| Midaz                                                     | balances and postings                                              | receives postings from the plugins                       | pure accounting. A Pix JD posting carries no counterparty data, and the banking detail stays in the plugin's own transaction record |
| Streaming Hub                                             | delivery of the events Lerian CCS and Lerian SCR publish           | Lerian CCS and Lerian SCR                                | your sinks and signing secrets                                                                                                      |

## Adopt it one piece at a time

***

<Steps>
  <Step title="Pick the rail and the model">
    Choose native messaging for a direct link, or a partner interface for JD or BTG connectivity.
  </Step>

  <Step title="Start with one interface">
    Lerian sets a partner interface's connection to Midaz at deploy time, and your application never sees it.
  </Step>

  <Step title="Wire your ledger consumer">
    On Lerian SPB, record a pending posting on `str.operation.accepted`. Take the final position from the `settlement.*` facts, and deduplicate on the `(ce-source, ce-id)` pair.
  </Step>

  <Step title="Add the regulatory rails">
    Add Lerian CCS, Lerian SISBAJUD, and Lerian SCR as your obligations require.
  </Step>
</Steps>

## Bring your own

***

* **Your ledger.** A native rail emits settlement facts for your ledger consumer, and it does not require a particular ledger.
* **Your certificates and keys.** [Lerian SLC](/en/rails/native/slc/what-is-lerian-slc) delegates signing to a custody backend you control, and the private key never leaves your custody. Each Consignado CLT (Dataprev) tenant uses its own ICP-Brasil client certificate.
* **Your access control.** Access Manager authenticates a partner plugin's API, and the plugin validates every incoming request when you enable it.
* **Your event consumers.** TED Lerian delivers control-plane events to webhooks you register. TED JD notifies your endpoint when a transfer completes, fails, or needs attention. The Consignado CLT (Dataprev) rail has its own subscription API.
* **Your operators.** Enable a payment plugin in the Lerian Console, and its menu item appears in the Midaz module sidebar. If you disable it, its configuration stays.

## A worked example

***

One TED through TED Lerian posts in two phases:

1. Your application calls TED Lerian to send the transfer.
2. Lerian SPB dispatches the STR message to BACEN and returns the status `ACCEPTED`. That status means dispatch acceptance, not settlement.
3. The `str.operation.accepted` event signals that acceptance. Your ledger consumer records a pending posting.
4. The operation moves to `CONFIRMED` when `settlement.settled` arrives. Your consumer finalizes the posting.
5. On `settlement.returned`, a confirmed return reverses a settled original. Your consumer reverses the parent posting.

Pix JD does the posting for you instead. It posts every settled Pix movement to Midaz, keyed by the end-to-end ID, so a retried settlement never double-posts.

## Start here

***

<Columns cols={3}>
  <Card title="Brazil Rails" icon="money-bill-transfer" href="/en/rails/what-are-brazil-rails">
    One anchor per rail, and the messaging that reaches it.
  </Card>

  <Card title="Interfaces" icon="plug" href="/en/interfaces/introduction">
    Every interface, and the paths in production today.
  </Card>

  <Card title="Native messaging and partner interfaces" icon="tower-broadcast" href="/en/rails/native/native-messaging">
    How the two connection models compare.
  </Card>
</Columns>
