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

# Configure a provider's ledger counterparty

> Sets the ledger account used as counterparty for the postings of one provider, in one ledger, for one asset. A ledger with no configured counterparty uses `@external/<asset>`.

<Info>**Providers:** Lerian (PCR) and BTG.</Info>

<Warning>**Under development.** This endpoint can change before it is released.</Warning>

**How it works**

- The tenant comes from your credential. Send the organization that owns the ledger in `X-Organization-Id`.
- Send `ledger_id` as a canonical UUID, in any case. The ledger is stored and answered in lower case.
- Send `assetCode`, `accountAlias`, `reason` and the `version` you read with the get operation (`0` if never configured).
- To go back to the default, write `@external/<asset>`. It must name the same `assetCode`.
- Any other alias must be an account of that ledger in Midaz, of type `external` and of the asset `assetCode`.
- Use an `external` account. Midaz applies no balance floor to it, so postings run against the provider's position.
- Each ledger has one counterparty per provider and asset. Each write is recorded in the history with the actor, the time, the old and new account and the reason.
- One counterparty per organization: the external leg of the accounting routes `BOLETO_IN_DEBIT`, `PAYMENT_OUT_CREDIT` and `DARF_OUT_CREDIT` belongs to the organization and names one account for all its ledgers. So all its ledgers and providers must name the same account. A different account is refused with reason `LEDGER_COUNTERPARTY_CONFLICT`.
- A ledger or provider still on `@external/<asset>` never conflicts. Its postings are refused until you write the same account there too. You can write providers and ledgers in any order.
- Writing `@external/<asset>` is never refused for a conflict. That provider's postings are then refused until the organization's accounting routes name the account in effect again.
- A posting uses the counterparty of the ledger and of the provider recorded on the operation, not the provider currently on the route.
- The commit or cancel of a reserve follows the original pending transaction, not the new counterparty.
- If the account later stops passing the checks, the posting fails with `PBP-0706`. It is never sent to `@external/<asset>` instead.
- While a payment of that provider in that ledger waits for its pending-debit posting, or a settled boleto waits for its settlement-credit posting, the write is refused with reason `POSTINGS_IN_FLIGHT`. Resend under the same `Idempotency-Key` once the posting settles.
- Nothing is written on any refusal.
- Send an `Idempotency-Key`. A retry under the same key replays the stored `200`.



## OpenAPI

````yaml /en/openapi/v3-current/payments-pcr.yaml post /v1/admin/ledgers/{ledger_id}/providers/{provider_type}/ledger-counterparty
openapi: 3.1.0
info:
  title: Payments PCR preview
  version: 2026-11-23-preview
  description: >-
    Preview of Payments with boleto collections through Lerian (PCR), CNAB 240,
    electronic payers (DDA), bill payments, and shared administration. This
    reference includes current behavior and planned changes. Read each
    operation's provider information: some operations support BTG only today.
    The preview is under development and can change before release. Confirm
    availability with Lerian before integration.


    The webhooks section describes notices Payments sends to your callback URL.
    Verify the signature and timestamp before processing a notice. Use the
    eventId and X-Webhook-Id described by each notice to detect repeated
    delivery. Do not assume delivery order.
servers:
  - url: https://api.example.com
    description: >-
      Replace the example host with the URL provided during environment
      onboarding.
security: []
tags:
  - description: >-
      Tenant-level setup: connecting the banking provider and configuring where
      status notifications are delivered.
    name: Admin
  - description: Issuing, querying and cancelling boletos, and retrieving the rendered PDF.
    name: Boletos
  - name: CNAB Agreements
    description: >-
      CNAB agreements: the link between a Lerian-provider collections agreement
      and the CNAB 240 Lerian files of one account, with its remittance and
      return sequence numbers (NSA) and its return cut times. Every operation of
      this section answers 422 PBP-0900 to a tenant without CNAB 240 enabled.
  - name: CNAB Remittances
    description: >-
      CNAB remittances: the CNAB 240 Lerian remittance files of an organization,
      each received whole, validated and stored encrypted, its title lines
      executed afterwards. A file already received is answered with its stored
      receipt; a new one answers 422 PBP-0900 to a tenant without CNAB 240
      enabled.
  - name: CNAB Returns
    description: >-
      CNAB 240 Lerian return files, one per agreement and cut, built from the
      journal of what happened to the titles that entered by remittance, and
      their download. Every operation of this section answers 422 PBP-0900 to a
      tenant without CNAB 240 enabled.
  - description: >-
      Boleto collections agreements and their reconciliation with the
      beneficiary base of the PCR: the consumption of each beneficiary inventory
      the PCR publishes and the divergences it raises, which carry only
      agreement and situation attributes, never a document or a name. Every
      operation of this section answers 422 PBP-0830 to a tenant without
      collections enabled.
    name: Collections Agreements
  - description: >-
      Boleto collections audit trail: every operation and configuration action,
      append-only, with its author, instant, reason, evidence and the module's
      fields before and after it. Every operation of this section answers 422
      PBP-0830 to a tenant without collections enabled.
    name: Collections Audit
  - description: >-
      Boleto collections beneficiaries: the enablement of the tenant's accounts
      for collections, in batches of up to 5,000 accounts, and the progress and
      per-item outcome of the enablement and bulk adoption batches. Every
      operation of this section answers 422 PBP-0830 to a tenant without
      collections enabled.
    name: Collections Beneficiaries
  - name: Collections Credit Entries
    description: >-
      Boleto collections credit entries: what the credit of each write-off moves
      in the ledger, one entry per write-off and phase, the RELEASE to the
      available balance of the title's account and the CHARGEBACK of a write-off
      cancelled after its release, with where each entry stands with the ledger
      and, when it is not posted, why, as a closed code and never the ledger's
      own text. Every operation of this section answers 422 PBP-0830 to a tenant
      without collections enabled.
  - description: >-
      Boleto collections operation queues: each case that waits for an operator
      and already has its state in collections, with its reason, since when it
      waits and the operations that act on it, read over the states collections
      keeps rather than from a list of its own. Each queue counts the items
      whose age reached its age limit, a per-tenant operational parameter. Every
      operation of this section answers 422 PBP-0830 to a tenant without
      collections enabled.
    name: Collections Operation Queues
  - description: >-
      Boleto collections commands to the PCR: each registration, change and
      write-off sent to the PCR of the institution, with the idempotency key it
      keeps across attempts, its attempts, its next attempt and the last answer
      that did not accept it, never the body sent. Every operation of this
      section answers 422 PBP-0830 to a tenant without collections enabled.
    name: Collections PCR Commands
  - description: >-
      Boleto collections notice subscription of the tenant's connection to the
      PCR: its synchronization with the PCR, the rotation of the secret the PCR
      signs the notices with, the deliveries of notices the PCR recorded for it,
      and the redelivery of a notice whose delivery failed. Every operation of
      this section answers 422 PBP-0830 to a tenant without collections enabled.
    name: Collections PCR Connection
  - description: >-
      Boleto collections notices received from the PCR: each event the PCR of
      the institution delivered to collections, stored once per connection and
      event, with where its processing stands and what it was matched with,
      never the body received. Every operation of this section answers 422
      PBP-0830 to a tenant without collections enabled.
    name: Collections PCR Notices
  - description: >-
      Boleto collections pooled accounts: the links of accounts that issue under
      the agreement of a pooled account, whose holder stays the beneficiary
      while the account's holder is the final one. A link registers nothing at
      Núclea. Every operation of this section answers 422 PBP-0830 to a tenant
      without collections enabled.
    name: Collections Pooled Accounts
  - description: >-
      Boleto collections setup: the tenant's business settings, with the default
      agreement template, the automatic enablement and the retention periods,
      and the tenant's connection to the PCR of its institution. Every operation
      of this section answers 422 PBP-0830 to a tenant without collections
      enabled.
    name: Collections Settings
  - description: >-
      Boleto collections titles: each boleto collections issues at the PCR of
      the institution, with its four state axes (registration, situation at the
      base, credit and block), never the data of a payer or of a beneficiary.
      The barcode and the digitable line are answered only while the title is
      REGISTERED. Every operation of this section answers 422 PBP-0830 to a
      tenant without collections enabled.
    name: Collections Titles
  - name: Collections Write-offs
    description: >-
      Boleto collections write-offs: each write-off of a collections title the
      PCR of the institution notified, with its route, its settlement, the state
      of its credit, its hold and its cancellation deadline, never the data of a
      payer. Every operation of this section answers 422 PBP-0830 to a tenant
      without collections enabled.
  - description: >-
      Aggregated counts, amounts and breakdowns over a period, for boletos and
      for payments.
    name: Dashboards
  - name: Electronic payers
    description: >-
      Electronic payer (DDA): adhesion of the institution's customer to
      electronic presentment of boletos, its accounts and aggregates, and the
      outcome of each request. Under development: can change before it is
      released.
  - description: >-
      The notices Payments posts to the tenant's callback URL, one per type
      enabled in enabledEvents, each signed with the configuration's secret.
      Each item describes the body, the delivery headers, when the notice is
      sent and which providers send it. The webhook is the channel of the first
      delivery: delivery will later move to Lerian's Streaming Hub, which will
      then be the only channel, with a change of subscription and a migration
      plan communicated to the client.
    name: Notices
  - description: >-
      Paying bankslips, utility bills and DARF tax slips, and querying those
      payments.
    name: Payments
  - name: Presented boletos
    description: >-
      Boletos of other institutions presented to the electronic payer: list,
      detail, acceptance and authorized third parties. Under development: can
      change before it is released.
paths:
  /v1/admin/ledgers/{ledger_id}/providers/{provider_type}/ledger-counterparty:
    post:
      tags:
        - Admin
      summary: Configure a provider's ledger counterparty
      description: >-
        Sets the ledger account used as counterparty for the postings of one
        provider, in one ledger, for one asset. A ledger with no configured
        counterparty uses `@external/<asset>`.


        <Info>**Providers:** Lerian (PCR) and BTG.</Info>


        <Warning>**Under development.** This endpoint can change before it is
        released.</Warning>


        **How it works**


        - The tenant comes from your credential. Send the organization that owns
        the ledger in `X-Organization-Id`.

        - Send `ledger_id` as a canonical UUID, in any case. The ledger is
        stored and answered in lower case.

        - Send `assetCode`, `accountAlias`, `reason` and the `version` you read
        with the get operation (`0` if never configured).

        - To go back to the default, write `@external/<asset>`. It must name the
        same `assetCode`.

        - Any other alias must be an account of that ledger in Midaz, of type
        `external` and of the asset `assetCode`.

        - Use an `external` account. Midaz applies no balance floor to it, so
        postings run against the provider's position.

        - Each ledger has one counterparty per provider and asset. Each write is
        recorded in the history with the actor, the time, the old and new
        account and the reason.

        - One counterparty per organization: the external leg of the accounting
        routes `BOLETO_IN_DEBIT`, `PAYMENT_OUT_CREDIT` and `DARF_OUT_CREDIT`
        belongs to the organization and names one account for all its ledgers.
        So all its ledgers and providers must name the same account. A different
        account is refused with reason `LEDGER_COUNTERPARTY_CONFLICT`.

        - A ledger or provider still on `@external/<asset>` never conflicts. Its
        postings are refused until you write the same account there too. You can
        write providers and ledgers in any order.

        - Writing `@external/<asset>` is never refused for a conflict. That
        provider's postings are then refused until the organization's accounting
        routes name the account in effect again.

        - A posting uses the counterparty of the ledger and of the provider
        recorded on the operation, not the provider currently on the route.

        - The commit or cancel of a reserve follows the original pending
        transaction, not the new counterparty.

        - If the account later stops passing the checks, the posting fails with
        `PBP-0706`. It is never sent to `@external/<asset>` instead.

        - While a payment of that provider in that ledger waits for its
        pending-debit posting, or a settled boleto waits for its
        settlement-credit posting, the write is refused with reason
        `POSTINGS_IN_FLIGHT`. Resend under the same `Idempotency-Key` once the
        posting settles.

        - Nothing is written on any refusal.

        - Send an `Idempotency-Key`. A retry under the same key replays the
        stored `200`.
      operationId: configureLedgerCounterparty
      parameters:
        - description: >-
            Midaz ledger whose counterparty is read or written, the same
            identifier the boleto and the payment record as their ledger. Each
            ledger has its own counterparty per provider and asset. Must be a
            canonical UUID (any case); otherwise 400 PBP-0026.
          in: path
          name: ledger_id
          required: true
          schema:
            description: >-
              Midaz ledger whose counterparty is read or written, the same
              identifier the boleto and the payment record as their ledger. Each
              ledger has its own counterparty per provider and asset. Must be a
              canonical UUID (any case); otherwise 400 PBP-0026.
            examples:
              - 0199a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a6c
            maxLength: 100
            minLength: 1
            type: string
        - description: >-
            Provider whose ledger counterparty is read or written, as the
            capabilities read names it. Matched case-insensitively.
          in: path
          name: provider_type
          required: true
          schema:
            description: >-
              Provider whose ledger counterparty is read or written, as the
              capabilities read names it. Matched case-insensitively.
            examples:
              - LERIAN
            maxLength: 20
            minLength: 1
            pattern: ^[A-Za-z][A-Za-z0-9_]{0,19}$
            type: string
        - description: >-
            Midaz organization that owns the ledger in the path. Required: a
            request without it, or with a value that is not a canonical UUID, is
            refused with 400 PBP-0025. Used only to look the account of
            accountAlias up in that ledger; it does not select the tenant, which
            comes from the validated identity.
          in: header
          name: X-Organization-Id
          schema:
            description: >-
              Midaz organization that owns the ledger in the path. Required: a
              request without it, or with a value that is not a canonical UUID,
              is refused with 400 PBP-0025. Used only to look the account of
              accountAlias up in that ledger; it does not select the tenant,
              which comes from the validated identity.
            type: string
        - description: >-
            Client-supplied idempotency key, a UUID. Required: a request without
            it, with a value that is not a UUID, or with the nil UUID
            (00000000-0000-0000-0000-000000000000) is refused with 400 PBP-0012.
            A retry with the same key replays the stored 2xx answer.
          in: header
          name: Idempotency-Key
          required: true
          schema:
            description: >-
              Client-supplied idempotency key, a UUID. Required: a request
              without it, with a value that is not a UUID, or with the nil UUID
              (00000000-0000-0000-0000-000000000000) is refused with 400
              PBP-0012. A retry with the same key replays the stored 2xx answer.
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfigureLedgerCounterpartyRequest'
              description: The asset, the account, the reason and the version read.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfiguredLedgerCounterpartyResponse'
          description: >-
            OK. The counterparty was written. A retry under the same
            `Idempotency-Key` returns this same answer.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body breaks the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Idempotency Key Required
                    status: 400
                    detail: The Idempotency-Key header is required for this endpoint.
                    code: PBP-0012
                PBP-0025:
                  summary: 'PBP-0025: Organization header missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0025
                    title: Bad Request
                    status: 400
                    detail: >-
                      X-Organization-Id header is required and must be a
                      canonical UUID
                    code: PBP-0025
                PBP-0026:
                  summary: 'PBP-0026: Ledger is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0026
                    title: Bad Request
                    status: 400
                    detail: ledgerId is required and must be a canonical UUID
                    code: PBP-0026
          description: >-
            Bad Request. Nothing was written.


            - `PBP-0001`: the body breaks the schema. For example,
            `accountAlias` does not match its pattern, `assetCode` is not
            uppercase, `reason` is blank, or a default alias is not `@external/`
            followed by `assetCode`.

            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the
            nil UUID.

            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical
            UUID.

            - `PBP-0026`: `ledger_id` is not a canonical UUID.


            See the [error
            list](/en/reference/interfaces/payments-btg/payments-error-list) for
            every code.
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0003:
                  summary: 'PBP-0003: Invalid credential'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0003
                    title: Unauthorized
                    status: 401
                    detail: authentication required
                    code: PBP-0003
          description: >-
            Unauthorized.


            - `PBP-0003`: the credential is missing or invalid, or does not
            identify a tenant. Get a valid bearer token.
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0004:
                  summary: 'PBP-0004: No permission'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0004
                    title: Forbidden
                    status: 403
                    detail: permission denied
                    code: PBP-0004
          description: >-
            Forbidden.


            - `PBP-0004`: the credential does not have the
            `provider-routes:configure` permission. Only the `editor` role
            carries it; a machine credential acts as `editor`. `viewer` and
            `operator` are refused.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0705:
                  summary: 'PBP-0705: Stale version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0705
                    title: PROVIDER_ROUTE_VERSION_MISMATCH
                    status: 409
                    detail: >-
                      The ledger counterparty of this provider changed since it
                      was read. Read it again and send the write with the
                      current version.
                    code: PBP-0705
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Request In Progress
                    status: 409
                    detail: >-
                      A request with this idempotency key is already being
                      processed.
                    code: PBP-0007
          description: >-
            Conflict.


            - `PBP-0705`: `version` is stale. Another write changed this
            counterparty since you read it. Read it again and resend with the
            current version and a new `Idempotency-Key`.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is
            still running. Retry under the same key after a few seconds. Do not
            switch keys: the earlier request can still take effect. The key
            answers this code for at most five minutes. After that, the same key
            replays the stored answer, answers `500` `PBP-0002` if it cannot be
            replayed, or runs the request if no answer was kept.


            See the [error
            list](/en/reference/interfaces/payments-btg/payments-error-list) for
            every code.
        '413':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0010:
                  summary: 'PBP-0010: Body too large'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0010
                    title: Request Entity Too Large
                    status: 413
                    detail: request body too large
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '415':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0022:
                  summary: 'PBP-0022: Body is not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0022
                    title: Unsupported Media Type
                    status: 415
                    detail: unsupported media type
                    code: PBP-0022
          description: >-
            Unsupported Media Type.


            - `PBP-0022`: the body is not JSON. Send `Content-Type:
            application/json`.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProviderRouteRejectedProblem'
              examples:
                PBP-0702:
                  summary: 'PBP-0702: Counterparty write refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0702
                    title: PROVIDER_ROUTE_REJECTED
                    status: 422
                    detail: >-
                      The ledger counterparty was not written. The account does
                      not exist in this ledger.
                    code: PBP-0702
                    reason: ACCOUNT_NOT_FOUND
                PBP-0013:
                  summary: 'PBP-0013: Key used for another body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: >-
                      The request body does not match the original request for
                      this idempotency key.
                    code: PBP-0013
          description: >-
            Unprocessable Entity. Nothing was written.


            - `PBP-0702`: the write was refused. The `reason` member says why:
            `NO_CHANGE` (the account is already the one in effect),
            `PROVIDER_NOT_INSTALLED` (provider not installed on this
            deployment), `PROVIDER_NOT_CONNECTED` (not connected to your
            tenant), `ACCOUNT_NOT_FOUND` (no such account in the ledger),
            `ACCOUNT_NOT_EXTERNAL` (type is not exactly `external`),
            `ACCOUNT_ASSET_MISMATCH` (account asset is not `assetCode`),
            `POSTINGS_IN_FLIGHT` (a posting of that provider in that ledger is
            still pending) or `LEDGER_COUNTERPARTY_CONFLICT` (another ledger or
            provider of the organization names a different account). For
            `POSTINGS_IN_FLIGHT`, resend under the same key once the posting
            settles.

            - `PBP-0013`: the `Idempotency-Key` was already used with a
            different body. Send under a new key.


            See the [error
            list](/en/reference/interfaces/payments-btg/payments-error-list) for
            every code.
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0002:
                  summary: 'PBP-0002: Unexpected failure'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0002
                    title: Internal Server Error
                    status: 500
                    detail: internal error
                    code: PBP-0002
          description: >-
            Internal Server Error. The `detail` is a fixed text.


            - `PBP-0002`: an unexpected failure, or the stored answer of this
            key cannot be replayed. Contact support. Do not resend under a new
            key.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0008:
                  summary: 'PBP-0008: Dependency unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0008
                    title: Service Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0008
          description: >-
            Service Unavailable. Nothing was written. The `detail` is a fixed
            text. This write never answers `PBP-0706`: a later posting gets it
            when the configured account stops passing the checks.


            - `PBP-0008`: a dependency is unavailable: authentication, storage,
            Midaz or the provider connection. It also answers when another write
            in the same organization and asset holds the turn too long. Retry
            under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
components:
  schemas:
    ConfigureLedgerCounterpartyRequest:
      additionalProperties: false
      properties:
        accountAlias:
          description: >-
            Alias of the ledger account, with the leading @. @external/<asset>
            returns to the default and must name the assetCode of the request;
            any other value is the alias of an account created through the Midaz
            API, of a-zA-Z0-9@:_- only. Otherwise 400 PBP-0001.
          examples:
            - '@siloc-a-liquidar'
          maxLength: 100
          minLength: 2
          pattern: ^(@external/[A-Z]{3,10}|@[A-Za-z0-9@:_-]{1,99})$
          type: string
        assetCode:
          description: >-
            Asset code in the ledger. The postings of the Payments use BRL
            today.
          examples:
            - BRL
          maxLength: 10
          minLength: 3
          pattern: ^[A-Z]{3,10}$
          type: string
        reason:
          description: >-
            Why the counterparty is changed. Recorded in the history. Blank is
            refused with 400 PBP-0001.
          examples:
            - >-
              Contrapartida do provider Lerian passa para a conta transitória do
              SILOC.
          maxLength: 500
          minLength: 1
          pattern: \S
          type: string
        version:
          description: >-
            The counterparty's current version, as read; 0 when never
            configured.
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
      required:
        - assetCode
        - accountAlias
        - reason
        - version
      type: object
    ConfiguredLedgerCounterpartyResponse:
      additionalProperties: false
      properties:
        changeId:
          description: Identifier of the history line this write recorded.
          examples:
            - 019a5c1e-2b3d-7f4a-8c5d-6e7f8a9b0c1d
          format: uuid
          type: string
        counterparty:
          $ref: '#/components/schemas/LedgerCounterparty'
          description: The counterparty as written, with its new version.
      required:
        - counterparty
        - changeId
      type: object
    Detail:
      additionalProperties: true
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    ProviderRouteRejectedProblem:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - properties:
            maxDays:
              description: >-
                The provider's maximum payment deadline, in calendar days after
                the due date. Present only with reason
                PAYMENT_DEADLINE_ABOVE_MAXIMUM.
              minimum: 0
              type: integer
            reason:
              description: >-
                Why the route, counterparty or payment deadline write was
                refused (PBP-0702 only). ACCOUNT_NOT_FOUND,
                ACCOUNT_NOT_EXTERNAL, ACCOUNT_ASSET_MISMATCH, POSTINGS_IN_FLIGHT
                and LEDGER_COUNTERPARTY_CONFLICT only on the counterparty write;
                PAYMENT_DEADLINE_ABOVE_MAXIMUM only on the payment deadline
                write.
              enum:
                - PROVIDER_NOT_CONNECTED
                - CAPABILITY_MISSING
                - PROVIDER_NOT_INSTALLED
                - UNKNOWN_OPERATION
                - NO_CHANGE
                - PROVIDER_SWITCH_UNAVAILABLE
                - ACCOUNT_NOT_FOUND
                - ACCOUNT_NOT_EXTERNAL
                - ACCOUNT_ASSET_MISMATCH
                - POSTINGS_IN_FLIGHT
                - LEDGER_COUNTERPARTY_CONFLICT
                - PAYMENT_DEADLINE_ABOVE_MAXIMUM
              type: string
          type: object
      description: >-
        Problem document of the configure 422 (route, ledger counterparty and
        payment deadline). `reason` is present only when code is PBP-0702; the
        counterparty write answers only NO_CHANGE, PROVIDER_NOT_INSTALLED,
        PROVIDER_NOT_CONNECTED, ACCOUNT_NOT_FOUND, ACCOUNT_NOT_EXTERNAL,
        ACCOUNT_ASSET_MISMATCH, POSTINGS_IN_FLIGHT or
        LEDGER_COUNTERPARTY_CONFLICT; the payment deadline write only NO_CHANGE,
        PROVIDER_NOT_INSTALLED, CAPABILITY_MISSING,
        PAYMENT_DEADLINE_ABOVE_MAXIMUM or PROVIDER_NOT_CONNECTED.
    LedgerCounterparty:
      additionalProperties: false
      properties:
        accountAlias:
          description: >-
            Alias of the ledger account, with the leading @ of the Midaz alias;
            @external/<asset> is the default counterparty.
          examples:
            - '@external/BRL'
          maxLength: 100
          minLength: 2
          type: string
        assetCode:
          description: >-
            Asset code in the ledger. The postings of the Payments use BRL
            today.
          examples:
            - BRL
          maxLength: 10
          minLength: 3
          pattern: ^[A-Z]{3,10}$
          type: string
        isDefault:
          description: >-
            True when the postings of the (ledger, provider, asset) use
            @external/<asset>: no counterparty is configured, or the configured
            one is @external/<asset>.
          examples:
            - false
          type: boolean
        ledgerId:
          description: >-
            Midaz ledger of the counterparty. Null only on the default item of
            the tenant list, which applies to every ledger with no configured
            counterparty.
          examples:
            - 0199a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a6c
          maxLength: 100
          type:
            - string
            - 'null'
        providerType:
          description: Provider whose operations post against the counterparty.
          examples:
            - BTG
          maxLength: 20
          type: string
        updatedAt:
          description: >-
            When the counterparty was last written, in UTC. Null when never
            configured.
          examples:
            - '2026-11-07T14:05:09Z'
          format: date-time
          type:
            - string
            - 'null'
        version:
          description: >-
            Version of this (tenant, ledger, provider, asset) counterparty. 0
            when never configured. Incremented by every accepted write. A write
            sends it back; a stale one is refused with 409 PBP-0705.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
      required:
        - ledgerId
        - providerType
        - assetCode
        - accountAlias
        - isDefault
        - version
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: 'Never returned: the service drops the rejected value.'
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````

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