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.\n\nThe 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.
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/accounting-routes/preflight:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Reports whether Payments can post to one ledger of your organization, and the state of each canonical accounting flow there.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Send the organization in `X-Organization-Id` and the ledger in the `ledgerId` query parameter.
        - The flows are `BOLETO_IN`, `PAYMENT_OUT` and `DARF_OUT`. Each reads `complete`, `absent`, `incomplete`, `ambiguous` or `malformed`.
        - An `incomplete` flow lists the missing route codes. An `ambiguous` flow lists the repeated codes. A `malformed` flow names the code and the reason.
        - Accounting routes belong to the organization. From Midaz v4.1.0 on, every ledger of one organization reports the same flows.
        - `validateRoutes` and `ready` belong to the requested ledger.
        - `ready` is the verdict on the whole ledger. A `complete` flow in a ledger that is not ready still does not post.
        - `reason` names the class of the verdict. It is absent when the ledger holds every canonical route.
        - The values of `reason` are `accounting_routes_not_provisioned`, `accounting_routes_required_but_absent`, `accounting_routes_incomplete`, `accounting_routes_ambiguous`, `accounting_routes_malformed`, `accounting_routes_dependency_unavailable`, `accounting_routes_access_denied` and `accounting_routes_unreadable`.
        - `accounting_routes_not_provisioned` comes with `ready: true`: the ledger has no canonical route and does not validate routes.
        - The verdict is judged as if the accounting routes check were on. `accountingRoutesEnabled` shows its current value in this deployment.
        - The call is read-only. It reads the ledger live and posts, caches or stores nothing. Run it right after provisioning and as often as needed.
      operationId: preflightAccountingRoutes
      parameters:
        - description: 'Midaz organization of the ledger to inspect. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization of the ledger to inspect. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            type: string
        - description: 'Midaz ledger to inspect. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          explode: false
          in: query
          name: ledgerId
          schema:
            description: 'Midaz ledger to inspect. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreflightAccountingRoutesResponse'
          description: OK. The body has the verdict for the ledger and one entry per canonical flow.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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 missing or invalid'
                  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.

            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0026`: `ledgerId` is missing, blank or 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 `admin:read` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Organization or ledger unknown'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: organization or ledger not found for this tenant
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the organization or the ledger is not known for this tenant. The answer does not say which. Check both identifiers.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Preflight the accounting routes of a ledger
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/preflight-the-accounting-routes-of-a-ledger
  /v1/admin/boletos/batches/{batch_id}/provider-binding:
    get:
      description: |-
        Returns the provider a boleto batch is bound to and the provider account resolved for it.

        <Info>**Providers:** BTG.</Info>

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

        **How it works**

        - The provider is recorded when the batch is created.
        - Every boleto of the batch, and every submission of it, carries the same provider.
        - Send the batch's organization in `X-Organization-Id`. A batch of another organization answers `404`, like one that does not exist.
      operationId: getBoletoBatchProviderBinding
      parameters:
        - description: 'Organization the batch belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A batch of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Organization the batch belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A batch of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Boleto batch identifier (UUID).
          in: path
          name: batch_id
          required: true
          schema:
            description: Boleto batch identifier (UUID).
            examples:
              - 0199b2c3-d4e5-7f60-8a1b-2c3d4e5f6a7b
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoBatchProviderBinding'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Batch id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: `batch_id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 `boletos:read` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Batch not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto batch with ID 0199b2c3-d4e5-7f60-8a1b-2c3d4e5f6a7b not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the batch does not exist or belongs to another organization.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Get a boleto batch's provider binding
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-boleto-batchs-provider-binding
  /v1/admin/boletos/{id}/adopt:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Records the provider's title on an installment that the emission check did not adopt. Use it for an installment that is `PENDING`, has no provider id and was already attempted. Typical cases: the provider proved the title exists, a lapsed discount withheld the resend, or the provider keeps refusing the resends.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Send the `providerId` of the title at the provider.
        - The service reads that title and compares its `clientRequestId`, amount and due date with the installment's.
        - All three match: the provider id is recorded, and the installment moves to `CREATED` on the next acceptance sweep. The response is the boleto, as in `GET /v1/boletos/{id}`.
        - Any of them differs, the title does not exist, or the installment is not in that state: the request is refused and nothing is written.
        - A repeat with the same `providerId` on an installment already adopted returns `200`.
        - Each call is audited: who called, when, the `providerId` and the result of the comparison.
        - There is no route to fail an installment.
      operationId: adoptBoletoEmission
      parameters:
        - 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.'
          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.'
            type: string
        - description: Identifier of the installment's boleto (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Identifier of the installment's boleto (UUID).
            examples:
              - 01928f6e-7a1b-7c3d-9e4f-5a6b7c8d9e0f
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdoptBoletoEmissionRequestBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetBoletoResponse'
          description: OK. The provider id is recorded on the installment. The body is the boleto, as in `GET /v1/boletos/{id}`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected required property providerId to be present
                        location: body.providerId
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the `id` is not a UUID, or `providerId` is missing or blank.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist in the tenant.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0121:
                  summary: 'PBP-0121: Adoption refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0121
                    title: EMISSION_ADOPTION_REFUSED
                    status: 422
                    detail: the provider has no title with this id
                    code: PBP-0121
          description: |-
            Unprocessable Entity.

            - `PBP-0121`: the installment is not `PENDING` without a provider id and already attempted, the provider has no title with that id, or the title does not match (`clientRequestId`, amount or due date). The `detail` says which. Nothing was written.
        '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
                PBP-0015:
                  summary: 'PBP-0015: Provider did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: PROVIDER_UNAVAILABLE
                    status: 503
                    detail: internal error
                    code: PBP-0015
          description: |-
            Service Unavailable. Nothing was written. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
            - `PBP-0015`: the provider did not answer the title read.
      security:
        - BearerAuth: []
      summary: Adopt the provider title of an installment
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/adopt-the-provider-title-of-an-installment
  /v1/admin/boletos/{id}/provider-binding:
    get:
      description: |-
        Returns the provider a boleto is bound to, the boleto's identifier at that provider and the provider account.

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

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

        **How it works**

        - The provider is recorded when the boleto is created and never changes.
        - Cancellation, PDF, reconciliation and notices of the boleto always go to that provider, whatever the current route says.
        - Boletos created before provider routing read `BTG`.
        - `providerId` is null while the provider has not returned an identifier.
        - `GET /v1/boletos/{id}` does not carry these fields.
        - Send the boleto's organization in `X-Organization-Id`. A boleto of another organization answers `404`, like one that does not exist.
      operationId: getBoletoProviderBinding
      parameters:
        - description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoProviderBinding'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Boleto id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 `boletos:read` permission (roles `viewer`, `operator` and `editor` carry it).
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto with ID 123e4567-e89b-12d3-a456-426614174000 not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist or belongs to another organization.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Get a boleto's provider binding
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-boletos-provider-binding
  /v1/admin/ledgers/{ledger_id}/providers/{provider_type}/ledger-counterparty:
    get:
      description: |-
        Returns the ledger account used as counterparty for the postings of one provider, in one ledger, for one 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. The ledger and the provider come from the path.
        - `assetCode` selects the asset. It defaults to `BRL`.
        - `provider_type` is matched case-insensitively.
        - With no configured counterparty, the answer is `isDefault: true`, `accountAlias: "@external/<asset>"` and `version: 0`.
        - A counterparty written back to `@external/<asset>` also reads `isDefault: true`, with its own version.
        - Read it before a write. Send its `version` in the write.
      operationId: getLedgerCounterparty
      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: Asset of the counterparty, uppercase. BRL when omitted.
          explode: false
          in: query
          name: assetCode
          schema:
            default: BRL
            description: Asset of the counterparty, uppercase. BRL when omitted.
            examples:
              - BRL
            maxLength: 10
            minLength: 3
            pattern: ^[A-Z]{3,10}$
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LedgerCounterparty'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid parameter'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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.

            - `PBP-0001`: `assetCode` or `provider_type` does not match its format.
            - `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:read` permission (roles `viewer`, `operator` and `editor` carry it).
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Get a provider's ledger counterparty
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-providers-ledger-counterparty
    post:
      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: []
      summary: Configure a provider's ledger counterparty
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/configure-a-providers-ledger-counterparty
  /v1/admin/payments/{id}/provider-binding:
    get:
      description: |-
        Returns the provider a payment is bound to and the payment's identifier at that provider.

        <Info>**Providers:** BTG.</Info>

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

        **How it works**

        - The provider is the one that quoted the payment when it was prepared.
        - Submission and reconciliation always go to that provider, even if the route changes between preparation and submission.
        - Payments created before provider routing read `BTG`.
        - `providerId` is null while the payment is `UNCONFIRMED` without a provider answer.
        - Send the payment's organization in `X-Organization-Id`. A payment of another organization answers `404`, like one that does not exist.
      operationId: getPaymentProviderBinding
      parameters:
        - description: 'Midaz organization the payment belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A payment of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the payment belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A payment of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Payment identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Payment identifier (UUID).
            examples:
              - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProviderBinding'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Payment id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 `payments:read` permission (roles `viewer`, `operator` and `editor` carry it).
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Payment not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: payment with ID 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the payment does not exist or belongs to another organization.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Get a payment's provider binding
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-payments-provider-binding
  /v1/admin/pix-config:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        This operation is not available. It answers `501` with code `PBP-0127` to every request that passes authentication and validation.

        <Info>**Providers:** none. This endpoint answers 501 Not Implemented for every provider.</Info>

        **How it works**

        - The Pix receiver configuration exists for hybrid boletos (boleto with Pix), which this service does not offer yet.
        - The configuration is not read. A configuration already stored is kept as it is.
        - A request refused before that keeps its own status and code.

        **Planned changes**

        - The Pix receiver configuration (Pix key and receiver address) becomes available with hybrid boletos (boleto with Pix). The write answer will also carry `receiverAddress`.
      operationId: getAdminPixConfig
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PixConfigResponse'
          description: 'OK. Not returned today: every request that reaches the operation gets `501`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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 `admin:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boletos unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented. This operation is not available. Nothing is read or changed.

            - `PBP-0127`: hybrid boletos (boleto with Pix) are not available on this service. Retrying does not help.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Get the tenant's Pix receiver configuration
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-the-tenants-pix-receiver-configuration
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        This operation is not available. It answers `501` with code `PBP-0127` to every request that passes authentication and validation.

        <Info>**Providers:** none. This endpoint answers 501 Not Implemented for every provider.</Info>

        **How it works**

        - The Pix receiver configuration exists for hybrid boletos (boleto with Pix), which this service does not offer yet.
        - Nothing is written. A configuration already stored is kept, and no `PIX_KEY_CHANGED` notice is sent.
        - A request refused before that keeps its own status and code, for example a missing `Idempotency-Key` or a body that breaks the schema.
        - A resend under an `Idempotency-Key` whose answer was stored before this operation answered `501` gets that stored answer until the key expires.

        **Planned changes**

        - The Pix receiver configuration (Pix key and receiver address) becomes available with hybrid boletos (boleto with Pix). The write answer will also carry `receiverAddress`.
      operationId: configureAdminPixConfig
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfigurePixConfigRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfiguredPixConfigResponse'
          description: 'OK. Not returned today: every request that reaches the operation gets `501`.'
        '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
          description: |-
            Bad Request. Answered before the `501`.

            - `PBP-0001`: the body breaks the schema.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-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.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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. Answered before the `501`.

            - `PBP-0013`: the `Idempotency-Key` was already used with a different body. Send under a new key.
        '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.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boletos unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented. This operation is not available. Nothing is written.

            - `PBP-0127`: hybrid boletos (boleto with Pix) are not available on this service. Retrying does not help.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Configure the tenant's Pix receiver
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/configure-the-tenants-pix-receiver
  /v1/admin/pix-config/history:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        This operation is not available. It answers `501` with code `PBP-0127` to every request that passes authentication and validation.

        <Info>**Providers:** none. This endpoint answers 501 Not Implemented for every provider.</Info>

        **How it works**

        - The Pix key history records changes to the Pix receiver configuration, which exists for hybrid boletos (boleto with Pix).
        - The history is not read. Changes already recorded are kept.
        - A request refused before that keeps its own status and code.

        **Planned changes**

        - The Pix receiver configuration (Pix key and receiver address) becomes available with hybrid boletos (boleto with Pix). The write answer will also carry `receiverAddress`.
      operationId: listAdminPixKeyHistory
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Changes per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Changes per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListPixKeyHistoryResponse'
          description: 'OK. Not returned today: every request that reaches the operation gets `501`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid page or limit'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request. Answered before the `501`.

            - `PBP-0001`: `page` is below 1, or `limit` is outside 1 to 100.
        '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 `admin:read` permission (roles `editor`, `operator` and `viewer` carry it).
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boletos unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented. This operation is not available. The history is not read.

            - `PBP-0127`: hybrid boletos (boleto with Pix) are not available on this service. Retrying does not help.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: List the changes of the tenant's Pix key
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-changes-of-the-tenants-pix-key
  /v1/admin/provider-routes:
    get:
      description: |-
        Returns the provider of each operation type for the tenant of your credentials.

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

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

        **How it works**

        - The answer always lists four operations, in this order: `BOLETO_ISSUANCE`, `BANKSLIP_PAYMENT`, `BARCODE_BILL_PAYMENT`, `DARF_PAYMENT`.
        - An operation with no provider reads `providerType: null` and `status: NO_PROVIDER`. New operations of that type are refused until you set a provider with `POST /v1/admin/provider-routes/{operation_type}`.
        - The route decides only new operations. Records already created keep the provider they were created with.
        - Requires the `provider-routes:read` permission, held by the `viewer`, `operator` and `editor` roles.

        **Planned changes**

        - DDA (electronic payer): a fifth operation type, `ELECTRONIC_PAYER`, joins the list. The list loses its fixed length: one entry per operation type, configured or not. Do not assume a fixed number of entries. This changes the published contract.
      operationId: getProviderRoutes
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProviderRouteSet'
          description: OK. The body lists every operation type with its provider. While an operation has no provider, new operations of that type are refused with 422 `PBP-0700`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: Get the tenant's provider route
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-the-tenants-provider-route
  /v1/admin/provider-routes/history:
    get:
      description: |-
        Lists the changes to the tenant's provider route, most recent first, with pagination.

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

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

        **How it works**

        - Each change shows the operation, the previous and the new provider, who made it (actor type and identifier), when, and the reason.
        - Values set by the system count as changes too. They are recorded with actor type `SYSTEM`.
        - A tenant with no change gets `200` with an empty `items` list and `total: 0`, never `404`.
        - `page` starts at 1. `limit` goes from 1 to 100.
        - Requires the `provider-routes:read` permission, held by the `viewer`, `operator` and `editor` roles.

        **Planned changes**

        - DDA (electronic payer): `operationType` can be `ELECTRONIC_PAYER`.
      operationId: listProviderRouteHistory
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Changes per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Changes per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProviderRouteHistoryPage'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `page` is below 1, or `limit` is outside 1 to 100.
        '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:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: List provider route changes
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-provider-route-changes
  /v1/admin/provider-routes/{operation_type}:
    post:
      description: |-
        Sets the provider of one operation type for the tenant of your credentials. Send `providerType: null` to remove it.

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

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

        **How it works**

        - Choose among the providers enabled for the tenant: installed on this deployment and connected to the tenant. `GET /v1/admin/providers/capabilities` lists them.
        - Send the `version` you read with `GET /v1/admin/provider-routes`. It is 0 when the operation was never configured.
        - The write is checked against the current state, in this order: `UNKNOWN_OPERATION`, `PROVIDER_NOT_INSTALLED`, `PROVIDER_NOT_CONNECTED`, `CAPABILITY_MISSING`, `NO_CHANGE`, `PROVIDER_SWITCH_UNAVAILABLE`. The first check that fails is the `reason` of the `422` `PBP-0702`. Any refusal writes nothing.
        - Moving boleto issuance (`BOLETO_ISSUANCE`) to another provider is not available yet. Issuance stays with the route's current provider, or with the last one after a removal.
        - The route history decides this, not the boletos issued. A tenant with no route history that issued boletos before routes existed stays with BTG.
        - Accepted for issuance: a removal, and setting the same provider back. A tenant with no route, no route history and no boleto can also set its first provider.
        - Only new operations go to the new provider. Records already created finish with their recorded provider, including consultation, cancellation and settlement.
        - Each change is recorded in the route history with the actor, the time, the previous and new provider, and the reason.
        - A retry under the same `Idempotency-Key` returns the stored `200`.
        - Requires the `provider-routes:configure` permission, held by `editor` and by machine credentials. It is separate from `admin:create`, so a role can choose providers without changing the tenant's credentials.

        **Planned changes**

        - DDA (electronic payer): `operation_type` accepts `ELECTRONIC_PAYER`. Switching or removing that route is refused with `PROVIDER_SWITCH_UNAVAILABLE` while the previous provider has active or pending adhesions, or when the provider cannot count them.
      operationId: configureProviderRoute
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
        - description: 'Operation type whose provider is set: BOLETO_ISSUANCE, BANKSLIP_PAYMENT, BARCODE_BILL_PAYMENT or DARF_PAYMENT. Any other well-formed name is refused with 422 PBP-0702 reason UNKNOWN_OPERATION; a value outside the pattern with 400 PBP-0001.'
          in: path
          name: operation_type
          required: true
          schema:
            description: 'Operation type whose provider is set: BOLETO_ISSUANCE, BANKSLIP_PAYMENT, BARCODE_BILL_PAYMENT or DARF_PAYMENT. Any other well-formed name is refused with 422 PBP-0702 reason UNKNOWN_OPERATION; a value outside the pattern with 400 PBP-0001.'
            examples:
              - BOLETO_ISSUANCE
            maxLength: 50
            minLength: 1
            pattern: ^[A-Z][A-Z0-9_]*$
            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/ConfigureProviderRouteRequest'
              description: The provider, the reason and the version read.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfiguredProviderRouteResponse'
          description: OK. The route 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: Request malformed'
                  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
          description: |-
            Bad Request.

            - `PBP-0001`: `operation_type` does not match the expected pattern, or the body does not match the schema.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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.
        '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 route 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 operation after you read it. Read the route 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 short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.

            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: the request body must be JSON
                    code: PBP-0022
          description: |-
            Unsupported Media Type.

            - `PBP-0022`: the body is not JSON.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProviderRouteRejectedProblem'
              examples:
                PBP-0702:
                  summary: 'PBP-0702: Route write refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0702
                    title: PROVIDER_ROUTE_REJECTED
                    status: 422
                    detail: The provider is not connected to the tenant, so the route was not changed.
                    code: PBP-0702
                    reason: PROVIDER_NOT_CONNECTED
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  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.

            - `PBP-0702`: the state checks refused the write. Nothing was written. The `reason` member names the first check that failed: `UNKNOWN_OPERATION`, `PROVIDER_NOT_INSTALLED`, `PROVIDER_NOT_CONNECTED`, `CAPABILITY_MISSING`, `NO_CHANGE` or `PROVIDER_SWITCH_UNAVAILABLE`.
            - `PBP-0013`: the `Idempotency-Key` was already used for a different request. 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.

            - `PBP-0002`: an unexpected failure. The write may or may not have taken effect, and a resend under the same key returns `500` `PBP-0002` again. Read the route with `GET /v1/admin/provider-routes`. If the write did not land, send it under a new `Idempotency-Key` with the current `version`.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Configure the provider of one operation
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/configure-the-provider-of-one-operation
  /v1/admin/providers/capabilities:
    get:
      description: |-
        Lists what each provider connected to the tenant and installed on this deployment declares it supports.

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

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

        **How it works**

        - For each provider: the operation types it can be routed to, boleto types and features, the nosso número mode, payment segments and inbound webhook features.
        - Connected follows the same rule as the `PROVIDER_NOT_CONNECTED` reason of the route write: the tenant holds a usable credential of the provider.
        - A tenant with no connected provider gets `200` with an empty `items` list.
        - Use it before you configure a route. A provider missing here is refused by the route write with `PROVIDER_NOT_CONNECTED` or `PROVIDER_NOT_INSTALLED`. A provider whose `operations` lacks the operation is refused with `CAPABILITY_MISSING`.
        - Requires the `provider-routes:read` permission, held by the `viewer`, `operator` and `editor` roles.

        **Planned changes**

        - DDA (electronic payer): a provider can declare the `ELECTRONIC_PAYER` operation (capability `OPERATION_ELECTRONIC_PAYER`). It can also declare optional electronic payer capabilities: multiple accounts, aggregates, authorized third parties, acceptance, initial load event, boleto listing, boleto version source and payment channel. How this endpoint shows them is not defined yet.
      operationId: listProviderCapabilities
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProviderCapabilitiesList'
          description: OK. An operation that needs a capability the routed provider does not declare is refused before any provider call, with 422 `PBP-0701` and the `capability` member naming it.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: List provider capabilities
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-provider-capabilities
  /v1/admin/providers/connect:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Connects the tenant to the banking provider with the tenant's client credentials.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Configure the tenant's provider client credentials before you call it.
        - The call checks that the credentials get an access token and stores it. It sets the provider `company_id` from the CNPJ (`legalDocument`) of the organization in `X-Organization-Id`. That organization owns the provider account.
        - Connecting again with another organization replaces the `company_id`. The last successful connect wins.
        - Send an empty JSON object as the body: `{}`. A missing body, `null` or any field is refused.
        - Where the deployment verifies provider accounts, the credentials must resolve to exactly one usable account. `account_verified` says whether the account was verified. When it is `true`, `provider_account_id` names the account.
        - When `account_verified` is `false`, the connection works but the account was not verified, and `provider_account_id` is absent. Do not treat the account as validated. Contact support to enable verification.
        - Multi-tenant deployments only: the answer has `webhook_url` and `webhook_subscription_registered`. The URL has a token that identifies the tenant, so treat the response body as a secret.
        - The service creates a signing key for each connection and registers the URL and the key at the provider. The provider signs each delivery body with HMAC-SHA256. The key is never returned.
        - Each connect rotates the connection: new `webhook_url`, new signing key. The previous pair keeps working for a grace window (30 minutes by default), so deliveries in flight are not lost.
        - `webhook_subscription_registered` says whether this call registered the new pair. When it is `false`, the previous pair stops working when the grace window closes.
        - If the URL or the key may have leaked, call `POST /v1/admin/providers/webhooks/{provider_type}/cancel` first, then connect. A connect made before the cancel is cut by it too. Rotation alone does not stop the exposed pair: it keeps working until the grace window closes. If the cancel gets `403` `PBP-0004`, call connect anyway, and contact support if the exposure cannot wait for the window to close.
        - This operation is not idempotent. An `Idempotency-Key` is ignored. A retry creates a new connection and replaces the one the provider may be using.
      operationId: connectProvider
      parameters:
        - description: 'Midaz organization whose legalDocument (CNPJ) is provisioned as the provider company_id. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization whose legalDocument (CNPJ) is provisioned as the provider company_id. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0025.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProviderConnectRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProviderConnectResponse'
          description: 'OK. The tenant is connected. Read `account_verified` before you treat the account as validated. On multi-tenant deployments, keep the body secret: it has the webhook URL.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0025`: `X-Organization-Id` is missing, blank or is not a UUID. Nothing is sent to the provider.
            - `PBP-0001`: the body is missing, is `null` or has a field. Send `{}`.

            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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No provider credentials'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Tenant has no provider credentials configured. Please sync credentials first.
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no provider client credentials. Configure them, then connect.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0017:
                  summary: 'PBP-0017: Provider account setup incomplete'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: 'provider not configured: the credential does not resolve to exactly one usable account. Verify that exactly one account is marked as the default at the provider and that it is active and unlocked.'
                    code: PBP-0017
          description: |-
            Unprocessable Entity.

            - `PBP-0017`: the provider account setup must be fixed: there is no default account, there is more than one, or the default account is locked or not active. Also returned when the organization in `X-Organization-Id` has no valid CNPJ to set the `company_id`.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '502':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0016:
                  summary: 'PBP-0016: Provider answer invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0016
                    title: Bad Gateway
                    status: 502
                    detail: internal error
                    code: PBP-0016
          description: |-
            Bad Gateway.

            - `PBP-0016`: the provider returned an invalid answer, authentication at the provider failed, or the account does not belong to the credentials. Try again later. Contact support if it persists.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: Connect the provider
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/connect-the-provider
  /v1/admin/providers/ledger-counterparties:
    get:
      description: |-
        Lists the ledger account used as counterparty for the postings of each provider of your tenant, per ledger.

        <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. `X-Organization-Id` does not select it.
        - Each configured item is one ledger, provider and asset.
        - Each provider installed and connected to your tenant also has a `BRL` default item: `ledgerId: null`, `isDefault: true`, `accountAlias: "@external/BRL"`, `version: 0`.
        - The default item applies to every ledger with no configured item. Its postings use `@external/<asset>`.
        - A configured item written back to `@external/<asset>` also reads `isDefault: true`.
        - 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 in the ledger.
        - To change a counterparty, use the configure operation. It needs the `provider-routes:configure` permission.
      operationId: listLedgerCounterparties
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LedgerCounterpartyList'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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:read` permission (roles `viewer`, `operator` and `editor` carry it).
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity. This read answers no business code. The `PBP-0702` refusal with reason `POSTINGS_IN_FLIGHT` belongs to the configure operation.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: List ledger counterparties
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-ledger-counterparties
  /v1/admin/providers/ledger-counterparties/history:
    get:
      description: |-
        Lists the changes of your tenant's ledger counterparties, most recent first, paginated.

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

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

        **How it works**

        - Each change has the ledger, the provider, the asset, the old and new account, the actor (type and identifier), the time and the reason.
        - The tenant comes from your credential. `X-Organization-Id` does not select it.
        - A tenant with no change gets `200` with an empty `items` list and `total: 0`, never `404`.
        - `page` starts at 1. `limit` goes from 1 to 100.
      operationId: listLedgerCounterpartyHistory
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Changes per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Changes per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LedgerCounterpartyHistoryPage'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid page or limit'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `page` is below 1, or `limit` is outside 1 to 100.
        '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:read` permission (roles `viewer`, `operator` and `editor` carry it).
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: List ledger counterparty changes
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-ledger-counterparty-changes
  /v1/admin/providers/payment-deadlines:
    get:
      description: |-
        Lists the default payment deadline of each provider for the tenant of your credentials, in calendar days after the due date.

        <Info>**Providers:** BTG.</Info>

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

        **How it works**

        - Only providers installed on this deployment that register a payment deadline and leave its default to this setting are listed. Lerian (PCR) takes the deadline from the collections agreement and is not listed.
        - A provider with nothing configured, or set back to the default, reads `isDefault: true`, with the provider's default in `days` and `providerDefaultDays`. `version` is 0 only when never written.
        - `aboveMaximum` flags configured days above the provider's current maximum.
        - The setting applies to boletos the provider issues after the write: single boletos and installment series without `paymentDeadline`, and batch items (`POST /v1/boletos/batches`). Their deadline is the due date plus these days.
        - A `paymentDeadline` sent on a single boleto or a series takes precedence. Boletos already issued keep their deadline.
        - An issuance reads the setting once (a batch, once for all its items). A change during an issuance does not affect it, and a resend of the same request returns the boletos as issued.
        - Change the setting with `POST /v1/admin/providers/{provider_type}/payment-deadline`.
        - Requires the `provider-routes:read` permission, held by the `viewer`, `operator` and `editor` roles.
      operationId: listProviderPaymentDeadlines
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentDeadlineList'
          description: OK. While configured days are above the provider's current maximum, or are 0 with a fine or interest that starts the day after the due date, issuance is refused with 422 `PBP-0006`. In a batch, each such item is a `PBP-0006` problem and the whole batch is refused with 422 `PBP-0123`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: List default payment deadlines
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-default-payment-deadlines
  /v1/admin/providers/payment-deadlines/history:
    get:
      description: |-
        Lists the changes to the tenant's default payment deadlines, most recent first, with pagination.

        <Info>**Providers:** BTG.</Info>

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

        **How it works**

        - Each change shows the provider, the previous and the new days, who made it (actor type and identifier), when, and the reason. Days are `null` when the provider's default applied.
        - A tenant with no change gets `200` with an empty `items` list and `total: 0`, never `404`.
        - `page` starts at 1. `limit` goes from 1 to 100.
        - Requires the `provider-routes:read` permission, held by the `viewer`, `operator` and `editor` roles.
      operationId: listProviderPaymentDeadlineHistory
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Changes per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Changes per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentDeadlineHistoryPage'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `page` is below 1, or `limit` is outside 1 to 100.
        '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:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: List payment deadline changes
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-payment-deadline-changes
  /v1/admin/providers/webhooks/{provider_type}/cancel:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Cuts the tenant's inbound webhook channel for one provider, at once.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Served only on multi-tenant deployments that issue webhook connections. Elsewhere the endpoint answers `404`.
        - It cuts the current connection and any previous connection still in its rotation grace window.
        - The effect is immediate: the first delivery after the call gets `401`.
        - After the cut, call `POST /v1/admin/providers/connect` to issue and register a new URL and signing key. Check that `webhook_subscription_registered` is `true`. A connect made before the cut is cut too.
        - `revoked_connections` counts the connections that could still serve a delivery. Zero is a success: nothing was live.
        - The answer has no credential: no token, no URL and no signing key.
        - Use a new `Idempotency-Key` for every cut. A retry under the same key returns the first answer for 48 hours by default and cuts nothing. If a connect ran between the two calls, the replay still reports the first call's `revoked_connections` while the new channel is live.
        - `provider_type` is matched case-insensitively. A provider this deployment does not serve gets `404`.
        - Requires the `admin:cancel` permission, held by `editor`. If you get `403`, call connect anyway: the exposed pair stops working when the grace window closes (30 minutes by default). Contact support if that cannot wait.
        - Check the permission before an incident: call this endpoint with a `provider_type` this deployment does not serve (for example `PROBE`) and a new `Idempotency-Key`. `404` `PBP-0005` with the detail "No webhook connection exists for that provider on this deployment" means you are authorized, and nothing was cut. A `404` without that detail means this endpoint is not served on this deployment. `403` `PBP-0004` means the permission has not reached you.
      operationId: revokeProviderWebhookConnection
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            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.'
          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.'
            type: string
        - description: Provider whose inbound webhook channel is being cut, as the connect answer names it in provider_type. Matched case-insensitively; a provider this deployment does not serve is refused with 404 rather than answered with a count of zero.
          in: path
          name: provider_type
          required: true
          schema:
            description: Provider whose inbound webhook channel is being cut, as the connect answer names it in provider_type. Matched case-insensitively; a provider this deployment does not serve is refused with 404 rather than answered with a count of zero.
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RevokeWebhookConnectionResponse'
          description: OK. The channel is cut. `revoked_connections` can be 0.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
          description: |-
            Bad Request.

            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
        '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 `admin:cancel` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Provider not served'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: No webhook connection exists for that provider on this deployment
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: no webhook connection exists for that provider on this deployment.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. The cut may or may not have taken effect, and a resend under the same key returns `500` `PBP-0002` again. A repeated cut is harmless: send it again under a new `Idempotency-Key`. `revoked_connections: 0` means nothing was left to cut.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Revoke a provider webhook connection
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/revoke-a-provider-webhook-connection
  /v1/admin/providers/webhooks/{provider_type}/resubscribe:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Registers the tenant's existing webhook subscription at the provider again, without rotating the connection.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - It sends the provider the declared resource set, pointed at the delivery URL of the tenant's current connection. The token, the signing key and the URL do not change.
        - It does not promise that a subscription the provider blocked after delivery failures resumes. Check the subscription state at the provider afterwards.
        - The write replaces the provider's whole resource list. The call first reads what the provider holds. If it holds resources outside the declared set, the call is refused with `409`, names them, and writes nothing.
        - To go ahead anyway, send `acknowledge_revoking` with exactly the resources the `409` named. Those resources are then removed from the provider's subscription. If the set changed in the meantime, you get another `409` and nothing is written.
        - The provider keeps one subscription per credential. Where tenants share a credential, this write points it at your tenant's URL until the other tenants' health checks register their own URL again. This service cannot see which tenants share a credential.
        - The answer has the delivery URL, which works as a credential. Treat the response body as a secret. It has no signing key.
        - There is no `Idempotency-Key`: a retry runs again and sends the same write.
        - After a call with `acknowledge_revoking`, a retry can get `409` because the resources are already gone. That does not prove the first call landed, nor that it did not. Retry without `acknowledge_revoking` to see the current state.
        - `provider_type` is matched case-insensitively.
      operationId: resubscribeProviderWebhook
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            type: string
        - description: Provider whose subscription is being re-registered, as the connect answer names it in provider_type. Matched case-insensitively; a provider this deployment does not serve is refused with 404.
          in: path
          name: provider_type
          required: true
          schema:
            description: Provider whose subscription is being re-registered, as the connect answer names it in provider_type. Matched case-insensitively; a provider this deployment does not serve is refused with 404.
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResubscribeWebhookSubscriptionRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResubscribeWebhookSubscriptionResponse'
          description: 'OK. The subscription was registered again. `resources` is the full set registered now. Keep the body secret: it has the delivery URL.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No webhook connection'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: No webhook connection exists for that provider on this tenant
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no webhook connection for that provider, or this deployment does not serve the provider.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Write would remove resources'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: "Nothing was written. The provider currently holds webhook resources this deployment does not declare, and a re-registration replaces the provider's resource array whole, so it would revoke them: PaymentSlipPay/SOME_EVENT."
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0007`: the provider holds resources outside the declared set, and the write would remove them. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. The `detail` names them. Nothing was written. To go ahead, send `acknowledge_revoking` with exactly those names. Also returned when `acknowledge_revoking` does not match the set measured on this call.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '502':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0016:
                  summary: 'PBP-0016: Subscription read failed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0016
                    title: Bad Gateway
                    status: 502
                    detail: internal error
                    code: PBP-0016
          description: |-
            Bad Gateway.

            - `PBP-0016`: the provider's current subscription could not be read, so nothing was written. Try again later.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: Re-register a provider webhook subscription
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/re-register-a-provider-webhook-subscription
  /v1/admin/providers/{provider_type}/disconnect:
    post:
      description: |-
        Disconnects one provider from the tenant of your credentials.

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

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

        **How it works**

        - It records the provider as disconnected and deactivates the tenant's credential of that provider, if any. Then it revokes the tenant's inbound webhook connections for it.
        - The disconnect is refused, and nothing changes, while an operation of the route points to the provider (`routedOperations`). It is also refused while the provider has open operations (`openOperations`): boletos `PENDING` or `CREATED`, unfinished batch submissions, live payments, or unprocessed inbound notices.
        - After the disconnect, new payments and boletos of the provider are refused, and its new inbound notices are rejected.
        - If the webhook revocation fails after the disconnect was recorded, you get `503`. The provider stays disconnected. Call again to complete the revocation. Until then, a reconnect is refused.
        - The provider stays disconnected until `POST /v1/admin/providers/{provider_type}/reconnect`. The credential sync does not recreate its credential.
        - A provider already disconnected returns `outcome: ALREADY_DISCONNECTED` with the `disconnectedAt` of the disconnect in force, and the revocation runs again.
        - A retry under the same `Idempotency-Key` answers from the earlier disconnect and only completes its revocation.
        - `provider_type` is matched case-insensitively, as `GET /v1/admin/providers/capabilities` names it.
        - This is not an incident tool. To cut a leaked webhook channel at once, use `POST /v1/admin/providers/webhooks/{provider_type}/cancel`.
        - Requires the `admin:create` permission, held by `editor`. Every refusal is recorded with the actor, the reason and the counts.

        **Planned changes**

        - DDA (electronic payer): the disconnect also counts the provider's active electronic payer adhesions. With any, it is refused, and the refusal gains `activeElectronicPayers` and `activeElectronicPayersUnavailable`. If the provider cannot count them, the disconnect is refused even when every other count is zero.
      operationId: disconnectProvider
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
        - description: Provider to disconnect, as the capabilities read names it. Matched case-insensitively.
          in: path
          name: provider_type
          required: true
          schema:
            description: Provider to disconnect, 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: 'Client-supplied idempotency key, a UUID. Required: a request without it, with a value that is not a UUID, or with the nil UUID is refused with 400 PBP-0012.'
          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 is refused with 400 PBP-0012.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProviderDisconnectionRequest'
              description: Why the provider is disconnected.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DisconnectProviderResponse'
          description: OK. The provider is disconnected. From now on, new payments and boletos of this provider are refused with 503 `PBP-0704`, and its new inbound notices with 401 `PBP-0500`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: The reason must have 1 to 500 characters of text, not only spaces and without NUL bytes, and the request must carry an identified actor.
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the `reason` is not 1 to 500 characters of text (only spaces, or NUL bytes), or the request has no identified actor.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 `admin:create` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Provider unknown'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: The provider is not installed and the tenant has neither a credential nor a disconnect record of it.
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the provider is not installed, and the tenant has neither a credential nor a disconnect record of it.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProviderDisconnectBlockedProblem'
              examples:
                PBP-0703:
                  summary: 'PBP-0703: Disconnect blocked'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0703
                    title: PROVIDER_DISCONNECT_BLOCKED
                    status: 409
                    detail: The provider cannot be disconnected while it is on the route, has open operations or has pending notices.
                    code: PBP-0703
                    openOperations:
                      boletos: 2
                      boletoBatches: 0
                      payments: 1
                      pendingNotices: 0
                    routedOperations:
                      - BOLETO_ISSUANCE
                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-0703`: the provider is on the route, has open operations or has pending notices. `routedOperations` and `openOperations` say which and how many. Nothing changed.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.

            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: the request body must be JSON
                    code: PBP-0022
          description: |-
            Unsupported Media Type.

            - `PBP-0022`: the body is not JSON.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. The disconnect may or may not have taken effect, and a resend under the same key returns `500` `PBP-0002` again. A repeated disconnect is safe: send it again under a new `Idempotency-Key`. A provider already disconnected answers `outcome: ALREADY_DISCONNECTED`.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable, or the webhook revocation failed after the disconnect was recorded. Retry under the same `Idempotency-Key` to complete it.
      security:
        - BearerAuth: []
      summary: Disconnect a provider
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/disconnect-a-provider
  /v1/admin/providers/{provider_type}/payment-deadline:
    get:
      description: |-
        Returns the default payment deadline of one provider for the tenant of your credentials, with the provider's default and maximum.

        <Info>**Providers:** BTG.</Info>

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

        **How it works**

        - Read it before a write: send its `version` with `POST /v1/admin/providers/{provider_type}/payment-deadline`.
        - `provider_type` is matched case-insensitively, as `GET /v1/admin/providers/capabilities` names it.
        - Lerian (PCR) takes the deadline from the collections agreement, so it has no setting here.
        - Requires the `provider-routes:read` permission, held by the `viewer`, `operator` and `editor` roles.
      operationId: getProviderPaymentDeadline
      parameters:
        - description: Provider whose default payment deadline is read or written, as the capabilities read names it. Matched case-insensitively.
          in: path
          name: provider_type
          required: true
          schema:
            description: Provider whose default payment deadline 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: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentDeadline'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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:read` permission.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0702:
                  summary: 'PBP-0702: No deadline setting'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0702
                    title: PROVIDER_ROUTE_REJECTED
                    status: 422
                    detail: The provider registers no payment deadline, or sets its default itself, so none can be configured.
                    code: PBP-0702
                    reason: CAPABILITY_MISSING
          description: |-
            Unprocessable Entity.

            - `PBP-0702`: the provider has no setting here. `reason` `PROVIDER_NOT_INSTALLED`: the provider is not installed on this deployment. `reason` `CAPABILITY_MISSING`: the provider registers no payment deadline, or sets its default itself, like Lerian (PCR).
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: Get a provider's default payment deadline
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-providers-default-payment-deadline
    post:
      description: |-
        Sets the default payment deadline of one provider for the tenant of your credentials, in calendar days after the due date.

        <Info>**Providers:** BTG.</Info>

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

        **How it works**

        - `days: 0` sets the deadline on the due date. `days: null` goes back to the provider's default. Like any accepted write, it moves `version` on.
        - `days` is `null` or 0 to 3650. `reason` must not be blank. `version` must not be negative.
        - Send the `version` read with `GET /v1/admin/providers/{provider_type}/payment-deadline`. It is 0 when never written.
        - Days above the provider's maximum are refused, with the maximum in `maxDays`.
        - Writing the days already stored, or `null` with nothing stored, is refused with reason `NO_CHANGE`.
        - Writing the provider's default as a number stores it. It stays if the provider's default changes later.
        - The setting applies to boletos the provider issues after the write: single boletos and installment series without `paymentDeadline`, and batch items (`POST /v1/boletos/batches`). Their deadline is the due date plus these days.
        - A `paymentDeadline` sent on a single boleto or a series takes precedence. Boletos already issued keep their deadline.
        - An issuance reads the setting once (a batch, once for all its items). A change during an issuance does not affect it, and a resend of the same request returns the boletos as issued.
        - With 0 days, an issuance with a fine or interest that starts the day after the due date is refused.
        - Nothing is written on any refusal. Each change is recorded in the history with the actor, the time, the previous and new days, and the reason.
        - A retry under the same `Idempotency-Key` returns the stored `200`.
        - Requires the `provider-routes:configure` permission, held by `editor` and by machine credentials. `viewer` and `operator` are refused.
      operationId: configureProviderPaymentDeadline
      parameters:
        - description: Provider whose default payment deadline is read or written, as the capabilities read names it. Matched case-insensitively.
          in: path
          name: provider_type
          required: true
          schema:
            description: Provider whose default payment deadline 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: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            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/ConfigurePaymentDeadlineRequest'
              description: The days, the reason and the version read.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfiguredPaymentDeadlineResponse'
          description: OK. The setting was written. While configured days are above the provider's current maximum, or are 0 with a fine or interest that starts the day after the due date, issuance is refused with 422 `PBP-0006`. In a batch, each such item is a `PBP-0006` problem and the whole batch is refused with 422 `PBP-0123`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  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
          description: |-
            Bad Request.

            - `PBP-0001`: `days`, `reason` or `version` is out of range, or the body does not match the schema. Nothing was written.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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.
        '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 default payment deadline 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 setting after 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 short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.

            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: the request body must be JSON
                    code: PBP-0022
          description: |-
            Unsupported Media Type.

            - `PBP-0022`: the body is not JSON.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProviderRouteRejectedProblem'
              examples:
                PBP-0702:
                  summary: 'PBP-0702: Days above the maximum'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0702
                    title: PROVIDER_ROUTE_REJECTED
                    status: 422
                    detail: The default payment deadline was not written. The days are past the furthest deadline the provider accepts, in maxDays.
                    code: PBP-0702
                    reason: PAYMENT_DEADLINE_ABOVE_MAXIMUM
                    maxDays: 365
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  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.

            - `PBP-0702`: the write was refused. Nothing was written. The `reason` member says why: `NO_CHANGE`, `PROVIDER_NOT_INSTALLED`, `CAPABILITY_MISSING`, `PAYMENT_DEADLINE_ABOVE_MAXIMUM` (with the maximum in `maxDays`) or `PROVIDER_NOT_CONNECTED`.
            - `PBP-0013`: the `Idempotency-Key` was already used for a different request. 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.

            - `PBP-0002`: an unexpected failure. The write may or may not have taken effect, and a resend under the same key returns `500` `PBP-0002` again. Read the setting with `GET /v1/admin/providers/{provider_type}/payment-deadline`. If the write did not land, send it under a new `Idempotency-Key` with the current `version`.
        '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.

            - `PBP-0008`: a dependency is unavailable, the provider connection could not be read, or another write of the same provider kept its turn too long. Nothing was written. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Configure a provider's default payment deadline
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/configure-a-providers-default-payment-deadline
  /v1/admin/providers/{provider_type}/reconnect:
    post:
      description: |-
        Takes a provider out of the disconnected state for the tenant of your credentials.

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

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

        **How it works**

        - If the revocation of the last disconnect is still pending, the reconnect is refused and nothing is recorded. Repeat the disconnect until it answers `200`, then reconnect.
        - It records the reconnection with the actor and the reason, then syncs the provider credential once.
        - `credentialActive` says whether the tenant holds a usable credential after that sync. A failed sync is not an error: it is retried later. A provider that does not connect through a credential answers `false`.
        - The route does not change.
        - A provider that is not disconnected answers `outcome: ALREADY_CONNECTED`, and the call is recorded too.
        - A retry under the same `Idempotency-Key` returns the stored answer of a completed call. A refusal releases the key, so a corrected retry under the same key runs again.
        - `provider_type` is matched case-insensitively, as `GET /v1/admin/providers/capabilities` names it.
        - Requires the `admin:create` permission, held by `editor`.
      operationId: reconnectProvider
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            format: uuid
            type: string
        - description: Provider to reconnect, as the capabilities read names it. Matched case-insensitively.
          in: path
          name: provider_type
          required: true
          schema:
            description: Provider to reconnect, 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: 'Client-supplied idempotency key, a UUID. Required: a request without it, with a value that is not a UUID, or with the nil UUID is refused with 400 PBP-0012.'
          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 is refused with 400 PBP-0012.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProviderDisconnectionRequest'
              description: Why the provider is reconnected.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReconnectProviderResponse'
          description: OK. The provider is reconnected, or was already connected (`outcome`). Read `credentialActive` to know whether the credential is usable.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: The reason must have 1 to 500 characters of text, not only spaces and without NUL bytes, and the request must carry an identified actor.
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the `reason` is not 1 to 500 characters of text (only spaces, or NUL bytes), or the request has no identified actor.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 `admin:create` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Provider unknown'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: The provider is not installed and the tenant has neither a credential nor a disconnect record of it.
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the provider is not installed, and the tenant has neither a credential nor a disconnect record of it.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProviderDisconnectBlockedProblem'
              examples:
                PBP-0703:
                  summary: 'PBP-0703: Revocation pending'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0703
                    title: PROVIDER_DISCONNECT_BLOCKED
                    status: 409
                    detail: The provider cannot be reconnected while the revocation of its last disconnect is pending. Repeat the disconnect, then reconnect.
                    code: PBP-0703
                    reason: REVOCATION_PENDING
                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-0703`: `reason` `REVOCATION_PENDING`: the revocation of the provider's last disconnect has not completed. Repeat the disconnect until it answers `200`, then reconnect.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.

            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: the request body must be JSON
                    code: PBP-0022
          description: |-
            Unsupported Media Type.

            - `PBP-0022`: the body is not JSON.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. The reconnect may or may not have taken effect, and a resend under the same key returns `500` `PBP-0002` again. A repeated reconnect is safe: send it again under a new `Idempotency-Key`. A provider already connected answers `outcome: ALREADY_CONNECTED`.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Reconnect a disconnected provider
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/reconnect-a-disconnected-provider
  /v1/admin/quarantine/webhooks/{id}/represent:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Takes one inbound provider webhook out of quarantine so it is processed again. This call applies nothing by itself.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Quarantine is the final `PERMANENTLY_FAILED` state. The service could not apply the event within its retry budget and stopped retrying it.
        - This call returns the webhook to normal processing with a full retry budget. The next processing cycle picks it up, on the same path as any other delivery.
        - It does not contact the ledger or the provider, and does not change any boleto or payment.
        - A `200` only means the webhook left quarantine. Whether the event applies is decided by the next cycle.
        - Fix the cause first. A webhook released into the same failing condition returns to quarantine.
        - A webhook that is not in quarantine is refused with `409`, even under a new `Idempotency-Key`. It is never released twice.
        - Send an `Idempotency-Key`. A retry under the same key replays the stored `200`. Most refusals release the key, so a corrected request under the same key runs again.
      operationId: representQuarantinedWebhook
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            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.'
          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.'
            type: string
        - description: Identifier of the quarantined webhook journal row (UUID), as reported by the PERMANENTLY_FAILED log line and metric.
          in: path
          name: id
          required: true
          schema:
            description: Identifier of the quarantined webhook journal row (UUID), as reported by the PERMANENTLY_FAILED log line and metric.
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RepresentQuarantinedWebhookResponse'
          description: OK. The webhook left quarantine. Nothing was applied yet.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: The webhook id in the path is not a valid UUID.
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a valid UUID.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Webhook not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: No webhook journal row carries this id in your tenant.
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: no webhook with this `id` exists in your tenant. Check the identifier.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Webhook not in quarantine'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: This webhook is not in quarantine. Either it does not hold the terminal PERMANENTLY_FAILED status, or a previous re-presentation already released it. Nothing was changed.
                    code: PBP-0007
          description: |-
            Conflict. `PBP-0007` has two meanings here.

            - `PBP-0007`: the webhook exists and is not in quarantine. A previous call already released it, or it was never quarantined. Nothing was changed.
            - `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 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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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.

            - `PBP-0013`: the `Idempotency-Key` was already used with a different body. Send under a new key.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Re-present a quarantined provider webhook
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/re-present-a-quarantined-provider-webhook
  /v1/admin/webhooks:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns your tenant's outbound webhook configuration.

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

        **How it works**

        - There is one configuration per tenant. The tenant comes from your credential.
        - `secret` always reads `[REDACTED]`. The signing secret is never returned.
        - A tenant with no configuration gets `404`.

        **Planned changes**

        - Under evaluation, not yet approved: `enabledEvents` may accept `PAYMENT_UNDER_REVIEW` and, later, `PAYMENT_RETURNED`.
      operationId: getAdminWebhookConfig
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookConfigResponse'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request.
        '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 `admin:read` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No webhook configuration'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Webhook configuration not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: your tenant has no webhook configuration. Create one with `POST /v1/admin/webhooks`.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry after a few seconds.
      security:
        - BearerAuth: []
      summary: Get webhook configuration
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-webhook-configuration
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Creates or updates the callback URL that receives your status change notifications. There is one configuration per tenant.

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

        **How it works**

        - Send `callbackUrl`, `secret` and `enabledEvents`. `active` defaults to `true`.
        - `callbackUrl` must use HTTPS and cannot point to a private, loopback or blocked address.
        - `secret` must have at least 32 characters.
        - `enabledEvents` must list at least one supported event type.
        - A second call updates the existing configuration and keeps its `id`.
        - Send an `Idempotency-Key`. A retry under the same key replays the stored `200`. Most refusals release the key, so a corrected request under the same key runs again.

        **Planned changes**

        - Under evaluation, not yet approved: `enabledEvents` may accept `PAYMENT_UNDER_REVIEW` and, later, `PAYMENT_RETURNED`.
        - Under evaluation, not yet approved: `enabledEvents` may accept eight new event types. An unknown type is still refused with `PBP-0402`.
        - `enabledEvents` will accept `CNAB_RETURN_AVAILABLE`, the notice that a CNAB 240 return file was generated. Until then it is refused with `PBP-0402`.
        - Under evaluation, not yet approved: `enabledEvents` may accept the 17 electronic payer (DDA) notice types (`ELECTRONIC_PAYER_*` and `RECEIVER_BOLETO_*`). Until then they are refused with `PBP-0402`. These notices are sent once per organization with an adhered account.
      operationId: configureAdminWebhook
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfigureWebhookRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookConfigResponse'
          description: OK. The configuration was saved. `secret` reads `[REDACTED]`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Required value missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: callbackUrl is required
                    code: PBP-0001
                PBP-0400:
                  summary: 'PBP-0400: Callback URL invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0400
                    title: Webhook URL Invalid
                    status: 400
                    detail: Webhook callback URL is invalid or blocked
                    code: PBP-0400
                PBP-0401:
                  summary: 'PBP-0401: Secret too short'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0401
                    title: Webhook Secret Too Short
                    status: 400
                    detail: Secret must be at least 32 characters
                    code: PBP-0401
                PBP-0402:
                  summary: 'PBP-0402: Unknown event type'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0402
                    title: Webhook Events Invalid
                    status: 400
                    detail: 'Invalid event type. Valid types are: [BOLETO_CREATED BOLETO_SETTLED ...]'
                    code: PBP-0402
                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
          description: |-
            Bad Request. Nothing was saved.

            - `PBP-0001`: the body breaks the schema, `callbackUrl`, `secret` or `enabledEvents` is empty, or `callbackUrl` cannot be parsed as a URL or has no host.
            - `PBP-0400`: `callbackUrl` is not HTTPS, or points to a private, loopback or blocked address.
            - `PBP-0401`: `secret` is shorter than 32 characters.
            - `PBP-0402`: `enabledEvents` has an unknown event type. The `detail` lists the valid types.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-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.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. The request was not processed. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Configure outbound webhook
      tags:
        - Admin
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/configure-outbound-webhook
  /v1/boletos:
    get:
      description: |-
        Lists the boletos of the `X-Organization-Id` organization, paginated, with optional filters.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Filter by status, kind, type, batch, creation date and due date.
        - `kind=BATCH` lists the items of batches. `batchId` lists the items of one batch.
        - A `batchId` that does not exist, or belongs to another organization, returns an empty list, not `404`.
        - `batchId` with a kind other than `BATCH` returns an empty list.
        - `from` and `to` take a date (`YYYY-MM-DD`, a UTC day) or an RFC 3339 date-time with offset. Percent-encode a positive offset (`%2B`).
        - `settlementState` matches only `SETTLED` boletos. `baseSituation` never matches `PENDING` or `FAILED` boletos.
        - Hybrid boletos (type `HYBRID`) are not listed and not counted in `total`.

        **Planned changes**

        - Items gain `settlement` and `baseSituation`, with new filters `settlementState` and `baseSituation`.
      operationId: listBoletos
      parameters:
        - description: 'Midaz organization whose boletos are listed. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only boletos of this organization are listed and counted.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization whose boletos are listed. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only boletos of this organization are listed and counted.'
            type: string
        - description: 'Status filter. REVERSED: the payment was returned to the payer; the boleto will not be paid.'
          explode: false
          in: query
          name: status
          schema:
            description: 'Status filter. REVERSED: the payment was returned to the payer; the boleto will not be paid.'
            enum:
              - PENDING
              - CREATED
              - SETTLED
              - CANCELED
              - INACTIVATED
              - FAILED
              - REVERSED
            examples:
              - CREATED
            type: string
        - description: Boleto kind filter. BATCH lists the items of batches.
          explode: false
          in: query
          name: kind
          schema:
            description: Boleto kind filter. BATCH lists the items of batches.
            enum:
              - SINGLE
              - INSTALLMENT
              - BATCH
            examples:
              - SINGLE
            type: string
        - description: Boleto type filter. Hybrid boletos (type HYBRID) are not listed, and type=HYBRID is answered with 501 PBP-0127.
          explode: false
          in: query
          name: type
          schema:
            description: Boleto type filter. Hybrid boletos (type HYBRID) are not listed, and type=HYBRID is answered with 501 PBP-0127.
            enum:
              - TRADITIONAL
              - QR_CODE
              - HYBRID
            examples:
              - TRADITIONAL
            type: string
        - description: 'Batch filter: only the boletos created as items of this batch. A value that is not a UUID is refused with 400 PBP-0001. A batch that does not exist, or that belongs to another organization, yields an empty list (total 0), not 404: this is a filter. Combined with a kind other than BATCH, the list is empty.'
          explode: false
          in: query
          name: batchId
          schema:
            description: 'Batch filter: only the boletos created as items of this batch. A value that is not a UUID is refused with 400 PBP-0001. A batch that does not exist, or that belongs to another organization, yields an empty list (total 0), not 404: this is a filter. Combined with a kind other than BATCH, the list is empty.'
            examples:
              - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
            format: uuid
            type: string
        - description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-01-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-12-31'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Due-date lower bound, inclusive.
          explode: false
          in: query
          name: dueDateFrom
          schema:
            description: Due-date lower bound, inclusive.
            examples:
              - '2026-02-01'
            format: date
            type: string
        - description: Due-date upper bound, inclusive.
          explode: false
          in: query
          name: dueDateTo
          schema:
            description: Due-date upper bound, inclusive.
            examples:
              - '2026-11-30'
            format: date
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Items per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
        - description: 'Settlement stage filter: only SETTLED boletos whose settlement.state is this value. A boleto that is not SETTLED never matches, even when a stage was already recorded for it. A value outside the list is refused with 400 PBP-0001, like every other enum filter of this operation.'
          explode: false
          in: query
          name: settlementState
          schema:
            description: 'Settlement stage filter: only SETTLED boletos whose settlement.state is this value. A boleto that is not SETTLED never matches, even when a stage was already recorded for it. A value outside the list is refused with 400 PBP-0001, like every other enum filter of this operation.'
            enum:
              - PENDING_RELEASE
              - RELEASED
              - REVERSED
              - CHARGEBACK_PENDING
              - CHARGED_BACK
            examples:
              - PENDING_RELEASE
            type: string
          x-mint:
            post:
              - Under development
        - description: 'Base situation filter: only boletos whose baseSituation is this value. PENDING and FAILED boletos carry no baseSituation and never match. OPEN also matches a SETTLED boleto whose title was reopened at the base (PAID to OPEN) and a REVERSED boleto. CANCELLED and LAPSED also match a SETTLED boleto whose reopened title was then canceled by the payee''s bank or lapsed. A value outside the list is refused with 400 PBP-0001.'
          explode: false
          in: query
          name: baseSituation
          schema:
            description: 'Base situation filter: only boletos whose baseSituation is this value. PENDING and FAILED boletos carry no baseSituation and never match. OPEN also matches a SETTLED boleto whose title was reopened at the base (PAID to OPEN) and a REVERSED boleto. CANCELLED and LAPSED also match a SETTLED boleto whose reopened title was then canceled by the payee''s bank or lapsed. A value outside the list is refused with 400 PBP-0001.'
            enum:
              - OPEN
              - PAID
              - CANCELLED
              - LAPSED
            examples:
              - OPEN
            type: string
          x-mint:
            post:
              - Under development
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListBoletosResponse'
          description: OK. A page of boletos of the organization.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: query.batchId
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter is malformed or out of range, for example `batchId` that is not a UUID or an enum filter with an unknown value.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Date range inverted'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: from must be before or equal to to
                    code: PBP-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `from` is after `to`.
        '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. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the request filters on `type=HYBRID`. Hybrid boletos (boleto with Pix) are not available. Do not retry.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: List boletos
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-boletos
    post:
      description: |-
        Issues one `TRADITIONAL` boleto through the provider the tenant routes `BOLETO_ISSUANCE` to.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - The final beneficiary (sacador avalista) is always the holder of the issuing account, read from the account's registration. Do not send `guarantor`: the response returns it.
        - The payer cannot be the holder of the issuing account.
        - `discounts` takes 1 to 3 bands of one type. Limit dates go in increasing order, each before the due date. An empty `discounts` is `400 PBP-0001`. `discount` with `discounts` is `422 PBP-0006`.
        - `fine.startDate` and `interest.startDate` fall after the due date and on or before the payment deadline. Without them, fine and interest start the day after the due date.
        - When the deadline is the due date (for example, 0 days set for the tenant), a `fine` or `interest` without a start date is refused with `422 PBP-0006`.
        - `documentNumber` (seu número) has 1 to 15 printable ASCII characters. It does not have to be unique. A longer value is refused, never cut.
        - `paymentDeadline` is on or after the due date. Without it, the provider's default applies (see the table below). The response shows the deadline in effect.
        - No date may fall after 9999-12-31, a default deadline included.
        - A term the provider does not register is refused with `422 PBP-0701`.
        - An `ourNumber` (nosso número) already held by an active boleto of the same provider account is refused with `422 PBP-0108` before the provider is called.
        - A number held by a title this service cannot see (another deployment or tenant on the same provider account) is accepted, then refused by the provider: the boleto moves to `FAILED`. If that title is this same emission, the boleto is bound to it. If the provider cannot tell whose title it is, the boleto stays `PENDING`.
        - Checks run in this order, and none issues anything: authentication, `Idempotency-Key`, body schema (empty required members, markup), type `HYBRID` (`501`), the account (`404 PBP-0005`), BTG accounting routes (`422 PBP-0128`, `503 PBP-0301`), the final beneficiary (`503 PBP-0118`, `400 PBP-0116`, `422 PBP-0117`, `422 PBP-0119`), the provider account (`422 PBP-0017`, `422 PBP-0014`, `503 PBP-0015`), Lerian (PCR) term rules (`422 PBP-0006`), then the nosso número (`422 PBP-0108`).

        **Responses and retries**

        - `201`: the provider accepted the boleto. The body has `providerId`. With BTG it also has `barcode` and `digitableLine`. With Lerian (PCR) they appear once the registration is confirmed and the boleto is `CREATED`.
        - `202`: the emission was sent, and the provider's answer is not confirmed yet. The boleto is `PENDING`. Read it with `GET /v1/boletos/{id}`.
        - After a `202`, do not send the boleto under a new `Idempotency-Key`: the provider may have issued it. Use a new key only when the boleto reads `FAILED`.
        - The response, `GET /v1/boletos/{id}`, `GET /v1/boletos` and the `BOLETO_CREATED` notification show the terms as recorded.
        - A provider refusal that proves no title was issued leaves the boleto `FAILED` and sends `BOLETO_FAILED`.
        - A provider refusal with a code of its declared refusal catalog comes with that code and its registered status (`409` or `422`), the catalog's `detail` and, when given, `providerReason`.
        - A code outside the catalog is answered `500`: the boleto is `FAILED` and `BOLETO_FAILED` is sent. A retry under the same `Idempotency-Key` sends the emission again and, refused again, records another `FAILED` boleto.
        - A retry under the same `Idempotency-Key` returns the stored `201` or `202`. After a refusal that issued nothing (for example `PBP-0116`, `PBP-0117`, `PBP-0119`, `PBP-0014`, `PBP-0017`, `PBP-0128` or a `503`), it runs the request again.
        - A resend of a `202` under the same key returns the same `202` even after the boleto is completed: read the boleto by id.
        - After the stored answer expires, the same key returns the boleto recorded under it (`201`, or `202` while it is `PENDING`), whatever its dates are now, and sends nothing again. Any changed member is `422 PBP-0013`. If the provider that recorded it is no longer installed, the answer is `503 PBP-0704`.

        **Provider differences**

        | | Lerian (PCR) | BTG |
        |---|---|---|
        | Status | Under development. Can change before it is released. | Available |
        | Nosso número | Up to 16 digits | Up to 11 digits |
        | Default deadline | Days of the collections agreement | Days set for the tenant, or 30 |
        | Maximum deadline | None | 365 days after the due date |
        | Instructions | Refused with 422 PBP-0701 (BOLETO_INSTRUCTIONS) | Accepted |
        | Term checks | This service's rules, then the collections rules, before anything is recorded (422 PBP-0006) | This service's rules (422 PBP-0006), then the bank |
        | Accounting routes | Not checked | Must be complete |

        **Planned changes**

        - Lerian (PCR): today a refusal when the title is registered, such as an account without a collections agreement while automatic enablement is off, is `422 PBP-0014`. Each refusal will get its own code instead:
          - `PBP-0801`: a capability the first version does not offer (product type, species, portfolio, or an institution without its own number code).
          - `PBP-0821`: an informed nosso número longer than 16 digits (here refused first with `400 PBP-0001`).
          - `PBP-0831`: the account has no collections agreement and automatic enablement is off. Enable the account, or turn automatic enablement on in the collections settings.
          - `PBP-0832`: an issuance rule is broken. Only this code carries `providerReason`, the rule's stable identifier, never a request value: `MISSING_DATE`, `DUE_DATE_TOO_FAR`, `DUE_DATE_BEFORE_FACTOR_RANGE`, `PAYMENT_DEADLINE_BEFORE_DUE`, `AMOUNT_NOT_POSITIVE`, `AMOUNT_PRECISION`, `AMOUNT_TOO_LARGE_FOR_BARCODE`, `PROJECTED_TOTAL_OUT_OF_RANGE`, `NEGATIVE_VALUE`, `VALUE_TOO_LARGE`, `PERCENTAGE_PRECISION`, `EXEMPT_CODE_WITH_VALUE`, `CALCULATION_MODEL_UNKNOWN`, `CALCULATION_MODEL_DISCONTINUED`, `INTEREST_CODE_UNKNOWN`, `INTEREST_CODE_NOT_IN_MODEL_01`, `INTEREST_VALUE_NOT_POSITIVE`, `INTEREST_VALUE_OUT_OF_RANGE`, `INTEREST_DATE_NOT_AFTER_DUE`, `INTEREST_DATE_AFTER_DEADLINE`, `INTEREST_DATE_WITH_EXEMPT_INTEREST`, `DAILY_RATE_NOT_REPRESENTABLE`, `FINE_CODE_UNKNOWN`, `FINE_VALUE_OUT_OF_RANGE`, `FINE_DATE_NOT_AFTER_DUE`, `FINE_DATE_AFTER_DEADLINE`, `FINE_DATE_WITH_EXEMPT_FINE`, `DISCOUNT_CODE_UNKNOWN`, `DISCOUNT_VALUE_OUT_OF_RANGE`, `DISCOUNT_DATE_NOT_BEFORE_DUE`, `DISCOUNT_DATES_NOT_INCREASING`, `DISCOUNT_DATE_WITH_EXEMPT_DISCOUNT`, `TOO_MANY_DISCOUNT_BANDS`, `MIXED_DISCOUNT_CODES`, `REBATE_NOT_BELOW_AMOUNT`, `DISCOUNT_AND_REBATE_NOT_BELOW_AMOUNT`, `DOCUMENT_NUMBER_TOO_LONG`, `DOCUMENT_NUMBER_INVALID_CHARACTER`, `OUR_NUMBER_EMPTY`, `OUR_NUMBER_NOT_DIGITS`, `FINAL_BENEFICIARY_MISSING`, `PARTY_DOCUMENT_INVALID`, `PARTY_NAME_INVALID`, `PARTY_ADDRESS_INVALID`.
        - `PBP-0108`: today it names the holder whatever its organization, and reading a holder of another organization returns `404`. The holder will be named only when it belongs to the `X-Organization-Id` organization.
      operationId: createBoleto
      parameters:
        - description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBoletoRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateBoletoResponse'
          description: 'Created. The provider accepted the boleto: the body has its `providerId`. The boleto stays `PENDING` until the provider confirms the registration. With BTG the body also has `barcode` and `digitableLine`. With Lerian (PCR) they appear once the registration is confirmed and the boleto is `CREATED`: read it with `GET /v1/boletos/{id}`.'
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateBoletoResponse'
          description: 'Accepted. The emission was sent, and the provider''s answer is not confirmed yet. The boleto is `PENDING`, without `providerId`, `barcode` or `digitableLine`. Read it with `GET /v1/boletos/{id}`. Do not resend it under a new `Idempotency-Key`: the provider may have issued it. A resend under the same key returns this same `202`, even after the boleto is completed. Use a new key only after the boleto reads `FAILED`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: unexpected property
                        location: body.guarantor
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
                PBP-0116:
                  summary: 'PBP-0116: Account without a registered holder'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0116
                    title: FINAL_BENEFICIARY_DATA_MISSING
                    status: 400
                    detail: The account this boleto would be issued against has no registered owner on file, so the boleto's final beneficiary cannot be established. Register the account's owner, or use an account that has one.
                    code: PBP-0116
          description: |-
            Bad Request.

            - `PBP-0001`: the body does not match the schema. Examples: `guarantor` sent, a fourth discount band, an empty `discounts`, `documentNumber` longer than 15 characters or outside printable ASCII. The `errors` member names the field.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0116`: the issuing account has no registered holder, or the registration is incomplete. Complete the holder's registration.

            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 permission to issue boletos.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Account not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: account not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the issuing account does not exist in this organization.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
            - Provider refusal: a code of the provider's declared refusal catalog registered as `409` comes here, with the catalog's `detail` and `providerReason` when given.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Term breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: discount and discounts cannot be sent together
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0014:
                  summary: 'PBP-0014: Provider refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0014
                    title: PROVIDER_REJECTED
                    status: 422
                    detail: banking provider rejected the boleto emission request
                    code: PBP-0014
                PBP-0017:
                  summary: 'PBP-0017: Provider not set up'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: the provider account for this tenant is not fully configured
                    code: PBP-0017
                PBP-0108:
                  summary: 'PBP-0108: ourNumber in use'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0108
                    title: DUPLICATE_OUR_NUMBER
                    status: 422
                    detail: ourNumber is held by boleto 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d; read it before you inform another number
                    code: PBP-0108
                    ourNumberHolderBoletoId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
                PBP-0117:
                  summary: 'PBP-0117: Holder cannot be final beneficiary'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0117
                    title: FINAL_BENEFICIARY_DATA_INVALID
                    status: 422
                    detail: The registered owner of the account this boleto would be issued against is recorded in a way that cannot be used as the boleto's final beneficiary. Correct the account owner's registration; resubmitting this request unchanged will not resolve it.
                    code: PBP-0117
                PBP-0119:
                  summary: 'PBP-0119: Payer is the account holder'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0119
                    title: FINAL_BENEFICIARY_SAME_AS_PAYER
                    status: 422
                    detail: the payer is the holder of the issuing account
                    code: PBP-0119
                PBP-0128:
                  summary: 'PBP-0128: Accounting routes incomplete (BTG)'
                  value:
                    title: ACCOUNTING_ROUTES_NOT_READY
                    status: 422
                    code: PBP-0128
                    detail: "boleto issuance refused: this organization's Payments accounting routes cannot carry the boleto's settlement credit (accounting_routes_incomplete); read GET /v1/admin/accounting-routes/preflight for this organization and ledger"
                    type: https://errors.lerian.studio/v1/PBP-0128
                PBP-0700:
                  summary: 'PBP-0700: No provider route'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0700
                    title: PROVIDER_ROUTE_NOT_CONFIGURED
                    status: 422
                    detail: no provider is configured for BOLETO_ISSUANCE
                    code: PBP-0700
                PBP-0701:
                  summary: 'PBP-0701: Capability not declared'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: BOLETO_INSTRUCTIONS
                PBP-0801:
                  summary: 'PBP-0801: Planned: capability not offered'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Provider Refusal
                    status: 422
                    detail: The provider refused the request (PBP-0801)
                    code: PBP-0801
                PBP-0821:
                  summary: 'PBP-0821: Planned: nosso número too long'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0821
                    title: Provider Refusal
                    status: 422
                    detail: The provider refused the request (PBP-0821)
                    code: PBP-0821
                PBP-0831:
                  summary: 'PBP-0831: Planned: account without agreement'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0831
                    title: Provider Refusal
                    status: 422
                    detail: The provider refused the request (PBP-0831)
                    code: PBP-0831
                PBP-0832:
                  summary: 'PBP-0832: Planned: issuance rule broken'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0832
                    title: Provider Refusal
                    status: 422
                    detail: The provider refused the request (PBP-0832)
                    code: PBP-0832
                    providerReason: PAYMENT_DEADLINE_BEFORE_DUE
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a term breaks an issuance rule, for example type `QR_CODE`, a date outside its range, `discount` with `discounts`, or a `fine` or `interest` without a start date when the deadline is the due date. Lerian (PCR) also applies its collections rules before anything is recorded. The `detail` names the member.
            - `PBP-0013`: the `Idempotency-Key` belongs to a different boleto, or to an emission that failed. Send under a new key.
            - `PBP-0014`: the provider refused. On the issuance itself it proved no title was issued: the boleto is recorded `FAILED` and `BOLETO_FAILED` is sent, with any provider. On the lookup of the issuing account nothing is recorded. A retry under the same `Idempotency-Key` runs the request again. Lerian (PCR) answers this code today for an account without a collections agreement while automatic enablement is off.
            - `PBP-0017`: the provider is not connected to the tenant, refused the tenant's credential, or the issuing account cannot be determined. The same on every boleto type, with or without `ourNumber`. Retrying unchanged does not help: fix the provider connection first.
            - `PBP-0108`: the `ourNumber` is held by an active boleto of the same provider account. `ourNumberHolderBoletoId` names it when it can be read. If the holder is an earlier emission still awaiting the provider, do not use another number: it can still become a live boleto. If the provider already answered it, read it first: it can be an earlier emission of the same charge. If the holder is a hybrid boleto, no id is given; do not issue the charge again, and use another number only for a different charge. Planned: the holder is named only when it belongs to the `X-Organization-Id` organization.
            - `PBP-0117`: the account holder cannot be a final beneficiary. Correct the holder's registration.
            - `PBP-0119`: the payer is the holder of the issuing account.
            - `PBP-0128` (BTG): the organization's accounting routes are incomplete, ambiguous or malformed, or absent on a ledger that validates them. The `detail` names the reason as `GET /v1/admin/accounting-routes/preflight` does. Run that read for the organization and ledger. A retry under the same key runs again.
            - `PBP-0700`: the tenant has no provider for `BOLETO_ISSUANCE`.
            - `PBP-0701`: the provider does not declare a capability the request needs. Nothing is written and the provider is not called. `capability` is one of `OPERATION_BOLETO_ISSUANCE`, `BOLETO_TYPE_TRADITIONAL`, `CLIENT_SUPPLIED_OUR_NUMBER`, `BOLETO_DOCUMENT_NUMBER`, `BOLETO_CHARGE_START_DATE`, `BOLETO_INSTRUCTIONS`, `BOLETO_DISCOUNT_BANDS` or `BOLETO_PAYMENT_DEADLINE`.
            - `PBP-0801`: Planned, Lerian (PCR): a capability the first version does not offer. Replaces `PBP-0014` for this refusal.
            - `PBP-0821`: Planned, Lerian (PCR): an informed nosso número longer than 16 digits. On this operation `400 PBP-0001` refuses it first.
            - `PBP-0831`: Planned, Lerian (PCR): the account has no collections agreement and automatic enablement is off. Enable the account, or turn automatic enablement on in the collections settings.
            - `PBP-0832`: Planned, Lerian (PCR): an issuance rule is broken. Only this code carries `providerReason`, the rule's stable identifier (values in Planned changes above).
            - Provider refusal: a code of the provider's declared refusal catalog registered as `422` comes with that code, the catalog's `detail` and `providerReason` when given.

            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.
            - Provider refusal with a code outside its declared refusal catalog: the boleto is `FAILED` and `BOLETO_FAILED` is sent. A retry under the same key sends the emission again and, refused again, records another `FAILED` boleto.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: type `HYBRID`. Hybrid boletos (boleto with Pix) are not available. Do not retry.
        '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
                PBP-0015:
                  summary: 'PBP-0015: Provider did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: PROVIDER_UNAVAILABLE
                    status: 503
                    detail: internal error
                    code: PBP-0015
                PBP-0118:
                  summary: 'PBP-0118: Holder registration unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0118
                    title: FINAL_BENEFICIARY_UNAVAILABLE
                    status: 503
                    detail: internal error
                    code: PBP-0118
                PBP-0301:
                  summary: 'PBP-0301: Accounting routes unavailable (BTG)'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0301
                    title: Ledger Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0301
                PBP-0704:
                  summary: 'PBP-0704: Provider not installed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. Nothing was issued. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
            - `PBP-0015`: the provider did not answer the account lookup.
            - `PBP-0118`: the holder's registration could not be read.
            - `PBP-0301` (BTG): the accounting routes or the ledger settings could not be read.
            - `PBP-0704`: the provider is not installed or not connected for the tenant.
      security:
        - BearerAuth: []
      summary: Issue a single boleto
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/issue-a-single-boleto
  /v1/boletos/batches:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the boleto batches of the `X-Organization-Id` organization, most recent first. Each batch comes with its outcome and counts, without its items.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Read one batch with `GET /v1/boletos/batches/{batch_id}` to see its items.
        - The outcome, the counts, `closed` and `finished` are derived from the items on every read.
        - The parameters follow the same rules as `GET /v1/boletos`.
        - No batch in the window returns an empty page: `items` is `[]` and `total` is 0.
      operationId: listBoletoBatches
      parameters:
        - description: 'Organization whose batches are listed. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only batches of this organization are listed and counted.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Organization whose batches are listed. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only batches of this organization are listed and counted.'
            type: string
        - description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-10-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-10-31'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Items per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListBoletoBatchesResponse'
          description: OK. A page of batches, most recent first. An empty page has `items` as `[]`, never null.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected number to be at least 1
                        location: query.limit
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `page`, `limit`, `from` or `to` is malformed or out of range, or `from` or `to` names a day that does not exist.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Date range inverted'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: from must be before or equal to to
                    code: PBP-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `from` is after `to`.
        '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. Contact support.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: List boleto batches
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-boleto-batches
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Issues 1 to 25 `TRADITIONAL` boletos in one request, one per item. All items use one collection account (`midazAccountId`) and one ledger (`ledgerId`) of the `X-Organization-Id` organization.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The response is `202` with the batch and the status of each item. No item has a barcode yet.
        - Each item is issued on its own, asynchronously. Follow it with `GET /v1/boletos/batches/{batch_id}` or with status change notifications set at `/v1/admin/webhooks`.
        - Do not send `guarantor`, `ledgerId` or `midazAccountId` inside an item.
        - Each item gets a payment deadline: its due date plus the days set for the provider at `/v1/admin/providers/{provider_type}/payment-deadline`, or the provider's default. It shows in `paymentDeadline` on each item and on the item's boleto.
        - An item whose fine or interest would start after its deadline is refused as an item problem. Days set above the provider's maximum are a `PBP-0006` on `paymentDeadline` of every item, though no item sends that member. Both refuse the batch with `422 PBP-0123`.
        - One item problem refuses the whole batch. Every problem comes in `itemErrors`, with the position and field.
        - The body limit is 256 KiB.
        - A retry under the same `Idempotency-Key` and body issues nothing: it returns the stored answer or the batch the key names.
        - The key is bound to the organization. While the stored answer lives, the same key under another organization is `422 PBP-0013`. After it expires, the same key under another organization creates a new batch.
        - After a refusal for a different body, organization or a fully failed batch, send under a new key.
        - Refusals before anything is recorded come in this order: auth, `PBP-0012`, `PBP-0010`, `PBP-0001`, `PBP-0025`, `PBP-0026`, `PBP-0122`, `PBP-0005`, `PBP-0116`, `PBP-0117`, `PBP-0123`, `PBP-0017`.
        - When the provider settles through this service (today BTG), incomplete accounting routes refuse the batch before anything is recorded. Check them with `GET /v1/admin/accounting-routes/preflight`.

        **Planned changes**

        - `PBP-0108`: today it names the boleto that holds the nosso número whatever its organization, and reading one of another organization returns `404`. It will name the holder only when it belongs to the `X-Organization-Id` organization.
      operationId: createBoletoBatch
      parameters:
        - description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBoletoBatchRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoBatchResponse'
          description: |-
            Accepted. The batch is recorded and its items are sent for issuance. Each item has its position, its boleto and its status. An item can be recorded `FAILED` with `PBP-0108` when its `ourNumber` is already in use. Do not resend the batch under a new `Idempotency-Key`.

            - Planned: `PBP-0108` names the holder boleto only when it belongs to the same organization.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: unexpected property
                        location: body.items[0].guarantor
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
                PBP-0026:
                  summary: 'PBP-0026: Ledger missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0026
                    title: Bad Request
                    status: 400
                    detail: ledgerId is required and must be a UUID
                    code: PBP-0026
                PBP-0116:
                  summary: 'PBP-0116: Account without a registered holder'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0116
                    title: FINAL_BENEFICIARY_DATA_MISSING
                    status: 400
                    detail: The account this boleto would be issued against has no registered owner on file, so the boleto's final beneficiary cannot be established. Register the account's owner, or use an account that has one.
                    code: PBP-0116
          description: |-
            Bad Request.

            - `PBP-0001`: the body does not match the schema, for example `items` missing, an item without `type`, or `guarantor`, `ledgerId` or `midazAccountId` inside an item. Also a blank `midazAccountId`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0026`: `ledgerId` is missing or is not a UUID.
            - `PBP-0116`: the account has no registered holder, or the registration is incomplete. Complete the holder's registration.

            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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Account not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: account not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the account does not exist, or is not under the organization and the ledger.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/BatchSizeProblem'
                  - $ref: '#/components/schemas/BatchInvalidItemsProblem'
                  - $ref: '#/components/schemas/Detail'
              examples:
                PBP-0122:
                  summary: 'PBP-0122: Batch size out of range'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0122
                    title: BATCH_SIZE_OUT_OF_RANGE
                    status: 422
                    detail: a batch carries from 1 to 25 boletos; this request carries 26
                    code: PBP-0122
                    maxItems: 25
                    receivedItems: 26
                PBP-0123:
                  summary: 'PBP-0123: Invalid items'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0123
                    title: BATCH_INVALID_ITEMS
                    status: 422
                    detail: one or more items are invalid; nothing was issued
                    code: PBP-0123
                    itemErrors:
                      - position: 1
                        field: type
                        code: PBP-0006
                        message: type HYBRID is not supported for batch issuance
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0017:
                  summary: 'PBP-0017: Provider not set up'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: the provider account for this tenant is not fully configured
                    code: PBP-0017
                PBP-0117:
                  summary: 'PBP-0117: Holder cannot be final beneficiary'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0117
                    title: FINAL_BENEFICIARY_DATA_INVALID
                    status: 422
                    detail: The registered owner of the account this boleto would be issued against is recorded in a way that cannot be used as the boleto's final beneficiary. Correct the account owner's registration; resubmitting this request unchanged will not resolve it.
                    code: PBP-0117
                PBP-0128:
                  summary: 'PBP-0128: Accounting routes incomplete (BTG)'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0128
                    title: ACCOUNTING_ROUTES_NOT_READY
                    status: 422
                    detail: "boleto issuance refused: this organization's Payments accounting routes cannot carry the boleto's settlement credit (accounting_routes_incomplete); read GET /v1/admin/accounting-routes/preflight for this organization and ledger"
                    code: PBP-0128
                PBP-0700:
                  summary: 'PBP-0700: No provider route'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0700
                    title: PROVIDER_ROUTE_NOT_CONFIGURED
                    status: 422
                    detail: no provider is configured for BOLETO_ISSUANCE
                    code: PBP-0700
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: BOLETO_BATCH
          description: |-
            Unprocessable Entity.

            - `PBP-0122`: the batch has fewer than 1 or more than 25 items. See `maxItems` and `receivedItems`.
            - `PBP-0123`: one or more items break a rule. Nothing is issued. `itemErrors` lists every problem with its position, field and code, for example `PBP-0006` for a term or a fine or interest start after the deadline.
            - `PBP-0013`: the `Idempotency-Key` was used with a different body or another organization, or every item of its batch failed. Send under a new key.
            - `PBP-0017`: an item has `ourNumber` and this instance cannot reserve it.
            - `PBP-0117`: the account holder cannot be a final beneficiary. Correct the holder's registration.
            - `PBP-0128`: the organization's accounting routes are incomplete, ambiguous or malformed, or absent on a ledger that validates accounting routes. The `detail` names the reason. Run `GET /v1/admin/accounting-routes/preflight`.
            - `PBP-0700`: the tenant has no provider for `BOLETO_ISSUANCE`.
            - `PBP-0701`: the provider does not declare a capability the batch needs. Nothing is written and the provider is not called. `capability` is one of `OPERATION_BOLETO_ISSUANCE`, `BOLETO_BATCH`, `CLIENT_SUPPLIED_OUR_NUMBER`, `BOLETO_DOCUMENT_NUMBER`, `BOLETO_CHARGE_START_DATE` or `BOLETO_INSTRUCTIONS`.

            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
                PBP-0301:
                  summary: 'PBP-0301: Ledger unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0301
                    title: Ledger Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0301
                PBP-0704:
                  summary: 'PBP-0704: Provider not installed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. Nothing was issued. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
            - `PBP-0301`: the accounting routes or the ledger settings could not be read.
            - `PBP-0704`: the provider is not installed or not connected for the tenant.
      security:
        - BearerAuth: []
      summary: Issue a batch of boletos
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/issue-a-batch-of-boletos
  /v1/boletos/batches/{batch_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Reads one boleto batch of the `X-Organization-Id` organization: its outcome, its counts and every item, by ascending position.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The outcome, the counts, `closed`, `finished` and each item's `overdue` are derived from the items on every read.
        - A batch that does not exist and a batch of another organization both return `404`, with the same body.
      operationId: getBoletoBatch
      parameters:
        - description: 'Organization the batch belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A batch of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Organization the batch belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A batch of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Batch identifier (UUID), the batchId the creation answered. A value that is not a UUID is refused with 400 PBP-0001.
          in: path
          name: batch_id
          required: true
          schema:
            description: Batch identifier (UUID), the batchId the creation answered. A value that is not a UUID is refused with 400 PBP-0001.
            examples:
              - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoBatchResponse'
          description: OK. The batch with its outcome, its counts and every item, as of the read.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: path.batch_id
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `batch_id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Batch not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto batch not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the batch does not exist, or belongs to another organization.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get a boleto batch
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-boleto-batch
  /v1/boletos/batches/{batch_id}/cancel:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Cancels the cancelable items of one boleto batch of the `X-Organization-Id` organization. Returns one result per item, by ascending position.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Only an item in `CREATED` that is registered at the provider is canceled. It goes through the same cancellation as `POST /v1/boletos/{id}/cancel`, with the request's `reason`.
        - Each canceled item sends one `BOLETO_CANCELED` notification.
        - Any other item returns `NOT_CANCELABLE` with `PBP-0103` and is not touched. Its status says why.
        - An item whose cancellation is refused or fails returns `CANCEL_FAILED` with that code and message. The other items are still canceled.
        - An item whose provider is not installed returns `CANCEL_FAILED` with `PBP-0704`.
        - An item the provider will confirm later returns `CANCELLATION_PENDING`, in `CREATED`, with its `cancellationId`. A new request returns it the same, without a new attempt.
        - Canceling only part of a batch is not an error: a batch that exists returns `200`.
        - A retry under the same `Idempotency-Key` returns the stored answer and runs nothing. After the record expires, the same key is answered from the items' current state: an item the first call canceled comes back `NOT_CANCELABLE` with status `CANCELED`.
        - To cancel one boleto of a batch, use `POST /v1/boletos/{id}/cancel`.
      operationId: cancelBoletoBatch
      parameters:
        - description: 'Organization the batch belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A batch of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Organization the batch belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A batch of another organization is answered 404, exactly as one that does not exist.'
            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.'
          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.'
            type: string
        - description: Batch identifier (UUID), the batchId the creation answered. A value that is not a UUID is refused with 400 PBP-0001.
          in: path
          name: batch_id
          required: true
          schema:
            description: Batch identifier (UUID), the batchId the creation answered. A value that is not a UUID is refused with 400 PBP-0001.
            examples:
              - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelBoletoBatchRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelBoletoBatchResponse'
          description: 'OK. One result per item: `CANCELED`, `CANCELLATION_PENDING`, `NOT_CANCELABLE` (`PBP-0103`) or `CANCEL_FAILED` (for example `PBP-0704`), with the boleto status after the attempt. Canceling only part of a batch is not an error.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected required property reason to be present
                        location: body.reason
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `batch_id` is not a UUID, the body does not match the schema, or `reason` is blank, longer than 500 characters or has markup.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Batch not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto batch not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the batch does not exist, or belongs to another organization.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: BOLETO_CANCEL
          description: |-
            Unprocessable Entity.

            - `PBP-0701`: the batch's provider does not declare `BOLETO_CANCEL`. The `capability` member names it. Nothing is written and the provider is not called.
        '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 processed. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Cancel a boleto batch
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/cancel-a-boleto-batch
  /v1/boletos/installments:
    post:
      description: |-
        Creates a series of 2 to 36 independent boletos, one per installment. The response is immediate: the series and its installments are recorded `PENDING`, then registered at the provider one at a time.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Send `totalAmount` to split it evenly, with the remainder on the last installment. Or send each amount in `installmentAmounts`.
        - Installment k falls due on `firstDueDate` plus (k-1) times `intervalDays` days. `intervalDays` is 1 to 365, with no business-day adjustment.
        - `fine.startDate`, `interest.startDate`, `paymentDeadline` and the `discounts` limit dates are set for the first installment. Each installment adds the same days to its own due date.
        - Example: `firstDueDate` 2030-01-10, `intervalDays` 30 and `paymentDeadline` 2030-01-25 give due dates 2030-01-10, 2030-02-09 and 2030-03-11, payable until 2030-01-25, 2030-02-24 and 2030-03-26.
        - `discount.limitDate` is the same date on every installment, before `firstDueDate`. For a discount that follows each installment, send `discounts`.
        - `documentNumbers` gives each installment its own `documentNumber`, in order. A single `documentNumber` is the same on every installment.
        - `ourNumbers` gives one nosso número per installment. A number already held by an active boleto on the same provider account refuses the series before the provider is called.
        - Do not send `guarantor`: the final beneficiary is the account holder, read once per series.
        - The account in `midazAccountId` must belong to the `X-Organization-Id` organization and to `ledgerId`.
        - The term rules are the same as `POST /v1/boletos`, judged on each installment's own dates.
        - `GET /v1/boletos/{id}` and the `BOLETO_CREATED` notification show each installment's own dates.
        - A new series returns status `CREATED` and `closed` false. Follow it at `GET /v1/boletos/installments/{series_id}`, and each installment at `GET /v1/boletos/{id}`.
        - Nothing is recorded when a request is refused. A refusal releases the `Idempotency-Key`, so a retry under the same key runs again.
        - A retry under the same key returns the series in its current state with `201`. After `PBP-0013`, send under a new key.
        - After the stored answer expires, the same key returns the series it names with `201`, whatever its dates are now. Start dates are compared by day and `documentNumbers` item by item; a resend that leaves out the original `ourNumbers` still returns `201`.
        - Only a new series is refused for a first due date (`PBP-0102`) or a discount limit date (`PBP-0006`) before today.
        - Refusals come in this order: auth; `Idempotency-Key` (`PBP-0012`, `PBP-0007`, `PBP-0013`); schema `PBP-0001`; `PBP-0025`, `PBP-0026`; body rules (`PBP-0006`, `PBP-0102`); `ourNumbers` (`PBP-0102`, `PBP-0701`, `PBP-0017`, `PBP-0001`); the stored series; the account (`PBP-0005`, `PBP-0106`, `PBP-0301`); the final beneficiary (`PBP-0118`, `PBP-0116`, `PBP-0117`, `PBP-0119`); the numbering account (`PBP-0017`, `PBP-0014`, `PBP-0015`); last `PBP-0108`.
        - When the provider settles through this service (today BTG), incomplete accounting routes refuse the series. Check them with `GET /v1/admin/accounting-routes/preflight`.

        **Provider differences**

        | | Lerian (PCR) | BTG |
        |---|---|---|
        | Default payment deadline | Days of the collections agreement | Days set for the tenant, or the provider default |
        | Maximum payment deadline | None | Provider maximum after the due date |
        | Accounting routes | Not checked | Must be complete |

        **Planned changes**

        - `PBP-0108`: today it names the boleto that holds the nosso número whatever its organization, and reading one of another organization returns `404`. It will name the holder only when it belongs to the `X-Organization-Id` organization.
      operationId: createBoletoInstallments
      parameters:
        - description: 'Midaz organization the account and every installment live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the account and every installment live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateInstallmentsRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateInstallmentsResponse'
          description: Created. The series is recorded with its installments in `PENDING`. A retry under the same key returns the series in its current state.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: unexpected property
                        location: body.guarantor
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
                PBP-0026:
                  summary: 'PBP-0026: Ledger missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0026
                    title: Bad Request
                    status: 400
                    detail: ledgerId is required and must be a UUID
                    code: PBP-0026
                PBP-0116:
                  summary: 'PBP-0116: Account without a registered holder'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0116
                    title: FINAL_BENEFICIARY_DATA_MISSING
                    status: 400
                    detail: The account this boleto would be issued against has no registered owner on file, so the boleto's final beneficiary cannot be established. Register the account's owner, or use an account that has one.
                    code: PBP-0116
          description: |-
            Bad Request.

            - `PBP-0001`: the body does not match the schema, `guarantor` is sent, `installments` or `intervalDays` is zero or less, an `ourNumbers` or `documentNumbers` item is invalid, or a date or amount cannot be read. The member is named, for example `ourNumbers[2]`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0026`: `ledgerId` is missing or is not a UUID.
            - `PBP-0116`: the account holder's registration is incomplete. Complete it.

            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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Account not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: account not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the account does not exist, or belongs to another organization or ledger.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0102:
                  summary: 'PBP-0102: Invalid series'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0102
                    title: INSTALLMENT_VALIDATION_ERROR
                    status: 422
                    detail: installments must be between 2 and 36
                    code: PBP-0102
                PBP-0006:
                  summary: 'PBP-0006: Term breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: discount and discounts cannot be sent together
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0014:
                  summary: 'PBP-0014: Provider refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0014
                    title: PROVIDER_REJECTED
                    status: 422
                    detail: banking provider rejected the boleto emission request
                    code: PBP-0014
                PBP-0017:
                  summary: 'PBP-0017: Provider not set up'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: the provider account for this tenant is not fully configured
                    code: PBP-0017
                PBP-0106:
                  summary: 'PBP-0106: Account validation not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0106
                    title: BOLETO_VALIDATOR_NOT_CONFIGURED
                    status: 422
                    detail: Account validation is not configured for this environment. Configure the Midaz ledger connection before issuing boletos.
                    code: PBP-0106
                PBP-0108:
                  summary: 'PBP-0108: ourNumber in use'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0108
                    title: DUPLICATE_OUR_NUMBER
                    status: 422
                    detail: ourNumber is held by boleto 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d; read it before you inform another number
                    code: PBP-0108
                    ourNumberHolderBoletoId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
                    installmentNumber: 2
                PBP-0117:
                  summary: 'PBP-0117: Holder cannot be final beneficiary'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0117
                    title: FINAL_BENEFICIARY_DATA_INVALID
                    status: 422
                    detail: The registered owner of the account this boleto would be issued against is recorded in a way that cannot be used as the boleto's final beneficiary. Correct the account owner's registration; resubmitting this request unchanged will not resolve it.
                    code: PBP-0117
                PBP-0119:
                  summary: 'PBP-0119: Payer is the account holder'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0119
                    title: FINAL_BENEFICIARY_SAME_AS_PAYER
                    status: 422
                    detail: the payer is the holder of the issuing account
                    code: PBP-0119
                PBP-0128:
                  summary: 'PBP-0128: Accounting routes incomplete (BTG)'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0128
                    title: ACCOUNTING_ROUTES_NOT_READY
                    status: 422
                    detail: "boleto issuance refused: this organization's Payments accounting routes cannot carry the boleto's settlement credit (accounting_routes_incomplete); read GET /v1/admin/accounting-routes/preflight for this organization and ledger"
                    code: PBP-0128
                PBP-0700:
                  summary: 'PBP-0700: No provider route'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0700
                    title: PROVIDER_ROUTE_NOT_CONFIGURED
                    status: 422
                    detail: no provider is configured for BOLETO_ISSUANCE
                    code: PBP-0700
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: CLIENT_SUPPLIED_OUR_NUMBER
          description: |-
            Unprocessable Entity.

            - `PBP-0102`: the series is invalid. Examples: a payer document with a bad check digit, `intervalDays` above 365, or `installments` outside 2 to 36. Also a list of the wrong length, an amount below 0.01 or with more than two decimal places, or amounts that do not add up to `totalAmount`. Also a repeated nosso número (see `duplicateInstallmentNumbers`) or a first due date in the past.
            - `PBP-0006`: a term breaks a rule: type `QR_CODE` or `HYBRID`, a refused fine, interest or discount, or an installment due after 9999-12-31. The `detail` names the member.
            - `PBP-0013`: the `Idempotency-Key` was used with a different body or another organization, or every installment of its series failed. Send under a new key.
            - `PBP-0014`: the provider refused the lookup of the account the numbers are reserved in.
            - `PBP-0017`: `ourNumbers` is sent and there is no provider to judge them, or the provider has no numbering account for `midazAccountId` (no account discovery, or the account is not yet enabled at the provider).
            - `PBP-0106`: account validation is not configured on this instance.
            - `PBP-0108`: a nosso número is already held by an active boleto on the same provider account. See `installmentNumber` and `ourNumberHolderBoletoId`, given only when the holder can be read and is not a hybrid boleto. Planned: the holder is named only when it belongs to the same organization.
            - `PBP-0117`: the account holder cannot be a final beneficiary. Correct the holder's registration.
            - `PBP-0119`: the payer is the holder of the issuing account.
            - `PBP-0128`: (BTG) the organization's accounting routes are incomplete, ambiguous or malformed. Run `GET /v1/admin/accounting-routes/preflight`.
            - `PBP-0700`: the tenant has no provider for `BOLETO_ISSUANCE`.
            - `PBP-0701`: the provider does not declare a capability the series needs. Nothing is written and the provider is not called. `capability` is one of `OPERATION_BOLETO_ISSUANCE`, `BOLETO_INSTALLMENTS`, `CLIENT_SUPPLIED_OUR_NUMBER`, `BOLETO_DOCUMENT_NUMBER`, `BOLETO_CHARGE_START_DATE`, `BOLETO_DISCOUNT_BANDS` or `BOLETO_PAYMENT_DEADLINE`.

            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. A `500` while the series is recorded releases the key, so a retry under the same key runs again; a failed commit keeps the key until the stored answer expires.
        '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
                PBP-0015:
                  summary: 'PBP-0015: Provider did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: PROVIDER_UNAVAILABLE
                    status: 503
                    detail: internal error
                    code: PBP-0015
                PBP-0118:
                  summary: 'PBP-0118: Holder registration unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0118
                    title: FINAL_BENEFICIARY_UNAVAILABLE
                    status: 503
                    detail: internal error
                    code: PBP-0118
                PBP-0301:
                  summary: 'PBP-0301: Ledger unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0301
                    title: Ledger Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0301
                PBP-0704:
                  summary: 'PBP-0704: Provider not installed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. Nothing was recorded. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
            - `PBP-0015`: the provider did not answer the lookup of the account the numbers are reserved in.
            - `PBP-0118`: the account holder's registration could not be read, or reading it is not configured.
            - `PBP-0301`: the ledger credential, the accounting routes or the ledger settings could not be read.
            - `PBP-0704`: the provider is not installed or not connected for the tenant.
      security:
        - BearerAuth: []
      summary: Issue installment boletos
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/issue-installment-boletos
  /v1/boletos/installments/{series_id}:
    get:
      description: |-
        Returns an installment series and all its installments, in `installmentNumber` order.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - `status` is the emission outcome of the series, derived from its installments on every read.
        - `CREATED`: some installment has no emission outcome yet. `COMPLETED`: all have one and none is `FAILED`. `PARTIAL_FAILURE`: some, not all, are `FAILED`. `FAILED`: all are.
        - A `FAILED` installment says why in `errorMessage`.
        - The outcome is not final. An installment the provider accepted can still end `FAILED`, so `COMPLETED` can become `PARTIAL_FAILURE` or `FAILED`.
        - `closed` is true when every installment is `SETTLED`, `CANCELED`, `INACTIVATED`, `REVERSED` or `FAILED`. It can return to false when the provider reverts a cancellation. Wait for `closed` true for the final outcome.
        - A series of another organization returns `404`, the same as one that does not exist.
      operationId: getInstallmentSeries
      parameters:
        - description: 'Midaz organization the installments were written with. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A series of another organization is answered 404, as a missing one.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the installments were written with. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A series of another organization is answered 404, as a missing one.'
            type: string
        - description: Installment series identifier (UUID).
          in: path
          name: series_id
          required: true
          schema:
            description: Installment series identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetInstallmentsResponse'
          description: OK. The series and its installments.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: path.series_id
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `series_id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Series not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: installment series not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the series does not exist, or its installments belong to another organization.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get installment series
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-installment-series
  /v1/boletos/{id}:
    get:
      description: |-
        Returns one boleto by its ID, with full detail.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - A boleto of another organization returns `404`, the same as one that does not exist.
        - A hybrid boleto (type `HYBRID`) is not shown.

        **Planned changes**

        - The response gains `settlement` and `baseSituation`. Status codes, parameters and the rest of the body do not change.
      operationId: getBoleto
      parameters:
        - description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetBoletoResponse'
          description: OK. The boleto.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: path.id
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist, or belongs to another organization.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the boleto is a hybrid boleto (boleto with Pix), which is not available. The boleto is not shown. Do not retry.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get boleto by ID
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-boleto-by-id
  /v1/boletos/{id}/amendments:
    get:
      description: |-
        Lists the amendment requests of a boleto, newest first, paginated.

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

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

        **How it works**

        - A boleto of another organization returns `404`, the same as one that does not exist.
        - A hybrid boleto (boleto with Pix) is not shown.
      operationId: listBoletoAmendments
      parameters:
        - description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            maximum: 1000000
            minimum: 1
            type: integer
        - description: Items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Items per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListBoletoAmendmentsResponse'
          description: OK. A page of the boleto's amendment requests, newest first.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: path.id
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a UUID, or `page` or `limit` is out of range.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist, or belongs to another organization.
        '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. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the boleto is a hybrid boleto (boleto with Pix), which is not available. The boleto is not shown. Do not retry.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: List the amendment requests of a boleto
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-amendment-requests-of-a-boleto
    post:
      description: |-
        Requests a change to the terms of a registered boleto. The digitable line and the barcode never change.

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

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

        **How it works**

        - Send only the members that change, each with its final value: `dueDate`, `amount`, `discounts`, `fine`, `interest`, `paymentDeadline` and `documentNumber`.
        - `discounts` replaces the whole list. An empty list removes every band.
        - `fine: null` and `interest: null` exempt the boleto from that charge. `documentNumber: null` removes it. Each needs its own provider capability.
        - Lerian (PCR) does not amend `documentNumber` and does not exempt fine or interest today: those requests are refused with `422 PBP-0701` (`BOLETO_AMEND_DOCUMENT_NUMBER`, `BOLETO_AMEND_FINE_EXEMPTION`, `BOLETO_AMEND_INTEREST_EXEMPTION`).
        - BTG does not amend boletos today: every request is refused with `422 PBP-0701` (`BOLETO_AMEND`).
        - The resulting terms follow the issuance rules and are checked before anything is sent to the provider.
        - Refused: a due date before today, a deadline or a fine or interest start moved before today, or a due date moved past the deadline in force without a new deadline.
        - `201` with status `APPLIED`: the provider applied it in its answer. `202` with status `PENDING`: the provider's outcome is awaited.
        - Both return a `Location` header for the request. The body is a receipt; read the current state from `Location`.
        - A provider refusal closes the request as `REJECTED`. The answer carries `amendmentId` and `Location`.
        - Refusals before anything is sent record no request and carry no `amendmentId`.
        - A resend under the same `Idempotency-Key` returns the same receipt. Once the record expires, it returns `200` with the request as it is now.
        - Member order, trailing zeros and spacing do not count when the content is compared. Use one key per intended amendment.
      operationId: requestBoletoAmendment
      parameters:
        - description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: 'Client-supplied idempotency key, a UUID, one per intended amendment. Required: a request without it, with a value that is not a UUID, or with the nil UUID is refused with 400 PBP-0012.'
          in: header
          name: Idempotency-Key
          required: true
          schema:
            description: 'Client-supplied idempotency key, a UUID, one per intended amendment. Required: a request without it, with a value that is not a UUID, or with the nil UUID is refused with 400 PBP-0012.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoAmendmentRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoAmendmentResponse'
          description: 'OK. A resend under the same `Idempotency-Key` after its record expired: the recorded request as it is now.'
          headers:
            Location:
              schema:
                description: URL of the amendment request.
                type: string
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoAmendmentResponse'
          description: 'Created. The provider applied the request: status `APPLIED`. The body is a receipt at that moment.'
          headers:
            Location:
              schema:
                description: URL of the amendment request.
                type: string
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoAmendmentResponse'
          description: Accepted. The request is `PENDING` until the provider answers. Read its current state from `Location`.
          headers:
            Location:
              schema:
                description: URL of the amendment request.
                type: string
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string, got null
                        location: body.dueDate
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: the body does not match the schema, or `dueDate`, `amount`, `discounts` or `paymentDeadline` is null.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist, or belongs to another organization.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0130:
                  summary: 'PBP-0130: Amendment already pending'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0130
                    title: Amendment In Progress
                    status: 409
                    detail: boleto already has an amendment awaiting the provider's confirmation
                    code: PBP-0130
                    pendingAmendmentId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
                PBP-0133:
                  summary: 'PBP-0133: Cancellation pending'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0133
                    title: Cancellation Pending
                    status: 409
                    detail: boleto has a cancellation awaiting the provider's answer
                    code: PBP-0133
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
            - `PBP-0130`: another amendment of this boleto is awaiting the provider. `pendingAmendmentId` names it.
            - `PBP-0133`: a cancellation of this boleto is awaiting the provider.
            - Provider refusal: the provider's own code registered as `409`, with `providerReason` when given. The request is `REJECTED` and `Location` names it.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Term breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: dueDate must not be before today
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: the Idempotency-Key was already used for another amendment request; use a new key
                    code: PBP-0013
                PBP-0131:
                  summary: 'PBP-0131: Boleto not amendable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0131
                    title: Boleto Not Amendable
                    status: 422
                    detail: boleto cannot be amended in status SETTLED, only CREATED boletos can be amended
                    code: PBP-0131
                PBP-0132:
                  summary: 'PBP-0132: Member not amendable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0132
                    title: Amendment Field Not Allowed
                    status: 422
                    detail: the amendment changes no member
                    code: PBP-0132
                PBP-0135:
                  summary: 'PBP-0135: Terms already in force'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0135
                    title: Amendment Changes Nothing
                    status: 422
                    detail: the amendment asks for the terms in force; nothing was recorded
                    code: PBP-0135
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: BOLETO_AMEND_DUE_DATE
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a resulting term breaks an issuance rule. The `detail` names the member.
            - `PBP-0013`: the `Idempotency-Key` was used with other content. Send under a new key.
            - `PBP-0131`: the boleto is not registered and open.
            - `PBP-0132`: the body is empty, or has a member no amendment changes. The `detail` names it.
            - `PBP-0135`: the resulting terms are the terms in force. Lerian (PCR): a `MONTHLY_PERCENTAGE` interest equal to 30 times a `DAILY_PERCENTAGE` is the same term.
            - `PBP-0701`: the provider does not declare a capability the amendment needs: `BOLETO_AMEND`, `BOLETO_AMEND_DUE_DATE`, `BOLETO_AMEND_AMOUNT`, `BOLETO_AMEND_DISCOUNTS`, `BOLETO_AMEND_FINE`, `BOLETO_AMEND_INTEREST`, `BOLETO_AMEND_PAYMENT_DEADLINE`, `BOLETO_AMEND_DOCUMENT_NUMBER`, `BOLETO_AMEND_FINE_EXEMPTION` or `BOLETO_AMEND_INTEREST_EXEMPTION`. The `capability` member names it. Nothing is written.
            - Provider refusal: the provider's own code registered as `422`, with `providerReason` when given. The request is `REJECTED` and `Location` names it.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          headers:
            Location:
              description: URL of the amendment request. Only on a refusal by the provider, which recorded the request.
              schema:
                format: uri-reference
                type: string
        '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 a provider refusal with a code outside its declared catalog. Contact support. Do not resend under a new key.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the boleto is a hybrid boleto (boleto with Pix), which is not available. No request is recorded. Do not retry.
        '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
                PBP-0704:
                  summary: 'PBP-0704: Provider not installed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. Nothing was processed. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
            - `PBP-0704`: the provider recorded on the boleto is not installed.
      security:
        - BearerAuth: []
      summary: Request an amendment of a registered boleto
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/request-an-amendment-of-a-registered-boleto
  /v1/boletos/{id}/amendments/{amendmentId}:
    get:
      description: |-
        Reads one amendment request of a boleto: its state, the members it asked for, the terms in force once applied and, when refused, the refusal.

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

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

        **How it works**

        - A boleto of another organization returns `404`, the same as one that does not exist.
        - A hybrid boleto (boleto with Pix) is not shown.
      operationId: getBoletoAmendment
      parameters:
        - description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
        - description: Amendment request identifier (UUID).
          in: path
          name: amendmentId
          required: true
          schema:
            description: Amendment request identifier (UUID).
            examples:
              - 0192f2a4-7c1e-7d3a-9b2c-5e6f7a8b9c0d
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoAmendmentResponse'
          description: OK. The amendment request.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: path.amendmentId
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `id` or `amendmentId` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
                PBP-0134:
                  summary: 'PBP-0134: Amendment not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0134
                    title: Amendment Not Found
                    status: 404
                    detail: amendment not found for this boleto
                    code: PBP-0134
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist, or belongs to another organization.
            - `PBP-0134`: the boleto has no amendment request with this id.

            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. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the boleto is a hybrid boleto (boleto with Pix), which is not available. The boleto is not shown. Do not retry.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get an amendment request of a boleto
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-an-amendment-request-of-a-boleto
  /v1/boletos/{id}/cancel:
    post:
      description: |-
        Cancels a boleto in `CREATED` status. No ledger entry is recorded: issuance reserves no balance, so there is nothing to reverse.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Every attempt is recorded before the provider is called. Its id comes back as `cancellationId`.
        - A provider that confirms in the call returns `200` with the boleto `CANCELED`.
        - A provider that confirms later returns `202` with `cancellationId` and `pendingCancellation`. The boleto stays `CREATED` until `BOLETO_CANCELED` or `BOLETO_CANCEL_FAILED` is notified.
        - While that attempt is pending, a new cancellation under any `Idempotency-Key` returns the same `202`, without a new attempt.
        - Every confirmed cancellation sends one `BOLETO_CANCELED` notification. A later write-off by the provider sends nothing more.
        - An amendment awaiting the provider is closed as `SUPERSEDED` when the cancellation is confirmed or accepted.
        - A boleto of another organization returns `404`, the same as one that does not exist.
        - When the provider refuses with a code from its declared refusal catalog, the response carries that code, its status and `providerReason` when given.
      operationId: cancelBoleto
      parameters:
        - description: 'Midaz organization the boleto to cancel belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto to cancel belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
            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.'
          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.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelBoletoRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelBoletoResponse'
          description: 'OK. The provider confirmed the cancellation: the boleto is `CANCELED`. The body carries `cancellationId`.'
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelBoletoPendingResponse'
          description: 'Accepted. The provider confirms the cancellation later. The boleto stays `CREATED`, and `pendingCancellation` names the attempt. Wait for `BOLETO_CANCELED` or `BOLETO_CANCEL_FAILED`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected required property reason to be present
                        location: body.reason
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a UUID, the body does not match the schema, or `reason` is blank, longer than 500 characters or has markup.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist, or belongs to another organization.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0133:
                  summary: 'PBP-0133: Cancellation pending'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0133
                    title: Cancellation Pending
                    status: 409
                    detail: a cancellation of this boleto is awaiting the provider's answer
                    code: PBP-0133
          description: |-
            Conflict.

            - `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. This code lasts at most five minutes after the earlier request arrived. After that, the same key returns the earlier answer, `500 PBP-0002` when it cannot be replayed, or runs the request when no answer was kept.
            - `PBP-0133`: an earlier cancellation attempt is awaiting the provider's answer.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0103:
                  summary: 'PBP-0103: Boleto not cancelable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0103
                    title: BOLETO_NOT_CANCELABLE
                    status: 422
                    detail: boleto cannot be canceled in status SETTLED, only CREATED boletos can be canceled
                    code: PBP-0103
                PBP-0107:
                  summary: 'PBP-0107: Not registered at provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0107
                    title: BOLETO_NOT_REGISTERED_AT_PROVIDER
                    status: 422
                    detail: the provider has no register of this boleto
                    code: PBP-0107
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: BOLETO_CANCEL
          description: |-
            Unprocessable Entity.

            - `PBP-0103`: the boleto is not `CREATED`, or has no provider id.
            - `PBP-0107`: the provider has no register of the boleto. This is not a final refusal: retry later.
            - `PBP-0701`: the boleto's provider does not declare `BOLETO_CANCEL`. The `capability` member names it. Nothing is written and the provider is not called.
            - Provider refusal: the provider's own code, with `providerReason` when given.

            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 a provider refusal with a code outside its declared catalog. Contact support. Do not resend under a new key.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the boleto is a hybrid boleto (boleto with Pix), which is not available. No cancellation is performed and the boleto is not changed, whatever its status. Do not retry.
        '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
                PBP-0704:
                  summary: 'PBP-0704: Provider not installed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. Nothing was processed. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
            - `PBP-0704`: the provider recorded on the boleto is not installed.
      security:
        - BearerAuth: []
      summary: Cancel an issued boleto
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/cancel-an-issued-boleto
  /v1/boletos/{id}/pdf:
    get:
      description: |-
        Returns the FEBRABAN PDF of an issued boleto, fetched from the provider on demand.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - While the provider has not registered the boleto, the response is `503` with a `Retry-After` header. Retry after that time.
        - A `QR_CODE` boleto has no PDF: it renders as a Pix QR code. The provider is not asked.
        - A boleto without `providerId` is answered without asking the provider: `503` while it is `PENDING`, `422` in any other status.
        - A boleto of another organization returns `404`, the same as one that does not exist.
        - A hybrid boleto (boleto with Pix) is not available. No PDF is fetched.

        **Provider differences**

        | | Lerian (PCR) | BTG |
        |---|---|---|
        | PDF available | Only once the boleto is registered | Once the provider has the boleto |
        | Pending boleto | 503 with Retry-After, with or without provider id | 503 with Retry-After |
        | Extra setup | Collections connection with institution name and bank check digit | None |
      operationId: getBoletoPDF
      parameters:
        - description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the boleto belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A boleto of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Boleto identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Boleto identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/pdf:
              schema:
                contentMediaType: application/octet-stream
                format: binary
                type: string
          description: OK. The FEBRABAN PDF, as raw bytes (`application/pdf`).
          headers:
            Content-Disposition:
              schema:
                description: attachment; filename="boleto-<id>.pdf"
                type: string
            Content-Type:
              schema:
                description: Always application/pdf.
                type: string
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: expected string to be RFC 4122 uuid
                        location: path.id
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Boleto not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: boleto not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the boleto does not exist, or belongs to another organization.
        '408':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Request Timeout. The client canceled the request or its deadline passed before the PDF was fetched. The body has no `code`. Send the request again.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Boleto without PDF'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: boleto has no PDF
                    code: PBP-0006
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: BOLETO_PDF
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: the collections connection is not configured
                    code: PBP-0800
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the boleto has no PDF: it is `QR_CODE`, whatever its status, or it has no `providerId` and is not `PENDING`, or its title ended without registration.
            - `PBP-0701`: the boleto's provider does not declare `BOLETO_PDF`. The `capability` member names it. The provider is not called.
            - `PBP-0800`: Lerian (PCR): the collections connection (`PUT /v1/collections/connection`) is missing, or has no `institutionName` or `bankCodeCheckDigit`. Configure it; retrying does not help.
            - Lerian (PCR): any other refusal of the provider comes with its own code and status.

            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, including a Lerian (PCR) PDF that cannot be drawn from the registered title. Contact support.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0127:
                  summary: 'PBP-0127: Hybrid boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0127
                    title: Hybrid Boleto Not Available
                    status: 501
                    detail: Hybrid boletos (boleto with Pix) are not available on this service.
                    code: PBP-0127
          description: |-
            Not Implemented.

            - `PBP-0127`: the boleto is a hybrid boleto (boleto with Pix), which is not available. No PDF is fetched. Do not retry.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0105:
                  summary: 'PBP-0105: PDF not ready yet'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0105
                    title: Service Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0105
                PBP-0704:
                  summary: 'PBP-0704: Provider not installed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
                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.

            - `PBP-0105`: the provider has not finished registering the boleto. Retry after the time in `Retry-After`.
            - `PBP-0704`: the provider recorded on the boleto is not installed.
            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Retry the request.
      security:
        - BearerAuth: []
      summary: Download boleto PDF
      tags:
        - Boletos
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/download-boleto-pdf
  /v1/cnab/agreements:
    post:
      description: |-
        Links one Lerian (PCR) collections agreement to CNAB 240 Lerian files.

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

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

        **How it works**

        - The file's agreement code (G007) is the collections agreement's 7-digit code. The bank code (G001) is the `bankCode` of the tenant's PCR connection.
        - Portfolio and species come from the collections agreement. Do not send them.
        - The collections agreement must be `ACTIVE`, of the Lerian (PCR) provider, and of the account and ledger you send.
        - The tenant must have a PCR connection.
        - A collections agreement has at most one CNAB agreement.
        - Without `returnCutTimes`, the return is cut once a day at 07:00, Brasília time.
        - Both NSAs start at 0.
        - The body takes no personal data.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      operationId: createCnabAgreement
      parameters:
        - description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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 is refused with 400 PBP-0012. The same key under another organization is refused with 422 PBP-0013.'
          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 is refused with 400 PBP-0012. The same key under another organization is refused with 422 PBP-0013.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCnabAgreementRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabAgreement'
          description: Created. The CNAB agreement, `ACTIVE`. A retry under the same `Idempotency-Key` returns this same `201`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request. Nothing was written.

            - `PBP-0001`: the body does not match the schema.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0909:
                  summary: 'PBP-0909: Agreement already linked'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0909
                    title: CNAB Agreement Already Exists
                    status: 409
                    detail: CNAB Agreement Already Exists
                    code: PBP-0909
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0909`: the collections agreement already has a CNAB agreement. Nothing was written.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait. This answer lasts at most five minutes after the earlier request arrived. After that, the key returns the stored answer, `500` `PBP-0002` when it cannot be replayed, or runs the request when no answer was kept. Do not switch keys: the earlier request can still take effect.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
                PBP-0910:
                  summary: 'PBP-0910: Collections agreement not usable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0910
                    title: CNAB Agreement Invalid
                    status: 422
                    detail: CNAB Agreement Invalid
                    code: PBP-0910
                    reason: COLLECTIONS_AGREEMENT_NOT_ACTIVE
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
            - `PBP-0910`: the collections agreement cannot back a CNAB agreement. The `reason` member says why: `COLLECTIONS_AGREEMENT_NOT_FOUND`, `COLLECTIONS_AGREEMENT_NOT_ACTIVE`, `ACCOUNT_MISMATCH`, `PROVIDER_NOT_SUPPORTED`, `PCR_CONNECTION_MISSING` or `CUT_TIMES_INVALID`.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body or under another organization. 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.

            - `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. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database, its CNAB switch or its collections agreements.
      security:
        - BearerAuth: []
      summary: Create a CNAB agreement
      tags:
        - CNAB Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/create-a-cnab-agreement
    get:
      description: |-
        Lists the CNAB agreements of the organization in `X-Organization-Id`, newest first.

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

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

        **How it works**

        - The order is `createdAt`, then `id`.
        - A page holds up to `limit` agreements. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor works only for the query that returned it, for the same tenant and organization. Any other cursor is refused with `PBP-0001`.
      operationId: listCnabAgreements
      parameters:
        - description: 'Midaz organization the CNAB agreements belong to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the CNAB agreements belong to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 50
            description: Most items per page.
            examples:
              - 50
            format: int64
            maximum: 200
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabAgreementList'
          description: OK. One page of CNAB agreements.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: a query parameter does not match the schema, or the cursor is not one this query returned to the same tenant and organization.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database, its CNAB switch or its collections agreements.
      security:
        - BearerAuth: []
      summary: List the CNAB agreements
      tags:
        - CNAB Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-cnab-agreements
  /v1/cnab/agreements/{agreement_id}:
    get:
      description: |-
        Returns one CNAB agreement of the organization in `X-Organization-Id`, with its last NSAs and the next scheduled cut.

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

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

        **How it works**

        - An agreement of another organization gets `404`, the same as one that does not exist.
      operationId: getCnabAgreement
      parameters:
        - description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. An agreement of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. An agreement of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Identifier of the CNAB agreement.
          in: path
          name: agreement_id
          required: true
          schema:
            description: Identifier of the CNAB agreement.
            examples:
              - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b61
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabAgreement'
          description: OK. The CNAB agreement.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: `agreement_id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0901:
                  summary: 'PBP-0901: CNAB agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0901
                    title: CNAB Agreement Not Found
                    status: 404
                    detail: CNAB Agreement Not Found
                    code: PBP-0901
          description: |-
            Not Found.

            - `PBP-0901`: no CNAB agreement with this id in the organization. An agreement of another organization gets the same answer.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database, its CNAB switch or its collections agreements.
      security:
        - BearerAuth: []
      summary: Get a CNAB agreement
      tags:
        - CNAB Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-cnab-agreement
    patch:
      description: |-
        Changes the return cut times, the status, or both, of a CNAB agreement.

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

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

        **How it works**

        - Only the fields you send change. The collections agreement, the account, the ledger and the codes never change.
        - Send the `version` you last read. Any other version is refused with `PBP-0912`.
        - `INACTIVE` refuses new remittances. Returns keep coming for the titles that already entered.
        - `ACTIVE` reactivates the agreement. The collections agreement must still be `ACTIVE`.
        - A change of cut times recomputes `nextCutAt`.
        - There is no delete.
        - An agreement of another organization gets `404`, the same as one that does not exist.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      operationId: updateCnabAgreement
      parameters:
        - description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. An agreement of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. An agreement of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Identifier of the CNAB agreement.
          in: path
          name: agreement_id
          required: true
          schema:
            description: Identifier of the CNAB agreement.
            examples:
              - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b61
            format: uuid
            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 is refused with 400 PBP-0012. The same key under another organization is refused with 422 PBP-0013.'
          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 is refused with 400 PBP-0012. The same key under another organization is refused with 422 PBP-0013.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCnabAgreementRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabAgreement'
          description: OK. The agreement after the change. `version` goes up by one when the cut times or the status change. A change that leaves them as they are writes nothing and keeps the same `version`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body or `agreement_id` does not match the schema.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0901:
                  summary: 'PBP-0901: CNAB agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0901
                    title: CNAB Agreement Not Found
                    status: 404
                    detail: CNAB Agreement Not Found
                    code: PBP-0901
          description: |-
            Not Found.

            - `PBP-0901`: no CNAB agreement with this id in the organization. An agreement of another organization gets the same answer.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0912:
                  summary: 'PBP-0912: Stale version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0912
                    title: CNAB Agreement Version Conflict
                    status: 409
                    detail: CNAB Agreement Version Conflict
                    code: PBP-0912
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0912`: `version` is not the current one. Nothing was written. Read the agreement again.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait. This answer lasts at most five minutes after the earlier request arrived. After that, the key returns the stored answer, `500` `PBP-0002` when it cannot be replayed, or runs the request when no answer was kept. Do not switch keys: the earlier request can still take effect.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
                PBP-0910:
                  summary: 'PBP-0910: Cut times or reactivation refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0910
                    title: CNAB Agreement Invalid
                    status: 422
                    detail: CNAB Agreement Invalid
                    code: PBP-0910
                    reason: CUT_TIMES_INVALID
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
            - `PBP-0910`: the `reason` member is `CUT_TIMES_INVALID` (a repeated time) or `COLLECTIONS_AGREEMENT_NOT_ACTIVE` (reactivation of an agreement whose collections agreement is no longer `ACTIVE`).
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body or under another organization. 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.

            - `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. Retry under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database, its CNAB switch or its collections agreements.
      security:
        - BearerAuth: []
      summary: Update a CNAB agreement
      tags:
        - CNAB Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/update-a-cnab-agreement
  /v1/cnab/remittances:
    post:
      description: |-
        Receives one whole CNAB 240 Lerian remittance file as the raw body and answers with a receipt. The title lines run afterwards, in the background.

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

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

        **How it works**

        - Send the file as `text/plain` or `application/octet-stream`, up to 4 MiB.
        - No `Idempotency-Key` is read. The file is the key: the agreement (G007) and NSA (G018) of the file header, and the SHA-256 of the normalized content.
        - Checks run in this order: authentication, permission, headers, `Content-Type`, the resend check, then the acceptance checks.
        - The resend check comes first. The same file sent again returns `200` with the first receipt, as it stands now, and does nothing. This holds even if CNAB 240 was turned off or the agreement deactivated since. A resend after a timeout is safe.
        - The same NSA with other content is refused with `PBP-0907`.
        - Only a new remittance goes through the acceptance checks: CNAB 240 enabled, file structure, agreement in the header, agreement `ACTIVE`, PCR connection, then the NSA. A refusal stores nothing and does not consume the NSA.
        - A new NSA returns `202` with a new receipt.
        - An NSA that skips numbers, or is below the last accepted one, is accepted with an alert in the receipt (`NSA_GAP`, `NSA_OUT_OF_ORDER`) and `expectedNsa`.
        - Each title (segment P and the Q, R, S and Y-53 that follow it) is validated whole. A rejected title does not stop the others. It is listed with up to 5 C047 reason codes.
        - Follow the remittance with `GET /v1/cnab/remittances/{remittance_id}` and its lines. The outcome of each title at the base comes in the return file.
        - The receipt and the lines never carry a payer's name, tax id or address.

        **Dry run**

        - With `dryRun=true`, the same checks run, except the resend check and the NSA checks. There is no `409` and no NSA alert.
        - Then every title line is validated. The answer is `200` with status `DRY_RUN` and the outcome of each line in `lines`.
        - Nothing is stored and no NSA is consumed. The receipt has no id and cannot be read back.
      operationId: submitCnabRemittance
      parameters:
        - description: 'Midaz organization the CNAB agreement of the file belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the CNAB agreement of the file belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            type: string
        - description: true validates the file and every line and answers 200 with status DRY_RUN, storing nothing and consuming no NSA.
          explode: false
          in: query
          name: dryRun
          schema:
            default: false
            description: true validates the file and every line and answers 200 with status DRY_RUN, storing nothing and consuming no NSA.
            type: boolean
      requestBody:
        content:
          application/octet-stream:
            schema:
              contentMediaType: application/octet-stream
              format: binary
              type: string
          text/plain:
            schema:
              maxLength: 4194304
              type: string
        description: 'Content-Type text/plain (any charset parameter, e.g. text/plain; charset=iso-8859-1) or application/octet-stream; anything else is refused with 415 PBP-0908. The whole remittance file, at most 4 MiB (4,194,304 bytes): records of 240 positions, ending in CRLF or LF, in ASCII, Latin-1 or UTF-8. File header, one or more collection batches (batch header, P/Q[/R][/S][/Y-53] segments per title, batch trailer), file trailer. The body is read raw, with a limit, and is not handed to the schema validator.'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabRemittanceReceipt'
          description: 'OK. Two cases, told apart by `status`. `DRY_RUN`: the validation result, with `lines`. Nothing was stored. Any other status: the same file (same agreement, NSA and content) was received before. This is the first receipt as it stands now, and nothing new was done.'
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabRemittanceReceipt'
          description: 'Accepted. A new remittance: the file was validated and stored encrypted. Its lines run in the background. The status is `VALIDATED`, or `COMPLETED` when every line was rejected at validation.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request. Nothing was read or stored.

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

            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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0907:
                  summary: 'PBP-0907: NSA used with other content'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0907
                    title: CNAB NSA Conflict
                    status: 409
                    detail: CNAB NSA Conflict
                    code: PBP-0907
                    existingRemittanceId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
          description: |-
            Conflict.

            - `PBP-0907`: the agreement already has a remittance with this NSA and other content. `existingRemittanceId` names it. Nothing was stored. Send the new content under the next NSA.
        '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 4 MiB. The HTTP edge refuses it before it is read. Nothing was stored. Split the file into files with consecutive NSAs.
        '415':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0908:
                  summary: 'PBP-0908: Wrong Content-Type'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0908
                    title: CNAB Unsupported Media Type
                    status: 415
                    detail: CNAB Unsupported Media Type
                    code: PBP-0908
          description: |-
            Unsupported Media Type.

            - `PBP-0908`: `Content-Type` is neither `text/plain` nor `application/octet-stream`. Nothing was read.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
                PBP-0905:
                  summary: 'PBP-0905: Structural defect'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0905
                    title: CNAB File Malformed
                    status: 422
                    detail: CNAB File Malformed
                    code: PBP-0905
                    defects:
                      - record: 1
                        field:
                        code: MISSING
                        message: the file has no record
                PBP-0906:
                  summary: 'PBP-0906: Header agreement mismatch'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0906
                    title: CNAB File Agreement Mismatch
                    status: 422
                    detail: CNAB File Agreement Mismatch
                    code: PBP-0906
                PBP-0911:
                  summary: 'PBP-0911: Agreement inactive'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0911
                    title: CNAB Agreement Inactive
                    status: 422
                    detail: CNAB Agreement Inactive
                    code: PBP-0911
                PBP-0910:
                  summary: 'PBP-0910: No PCR connection'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0910
                    title: CNAB Agreement Invalid
                    status: 422
                    detail: CNAB Agreement Invalid
                    code: PBP-0910
                    reason: PCR_CONNECTION_MISSING
          description: |-
            Unprocessable Entity. The whole file was refused. Nothing was stored, and the NSA was not consumed. A resend of a file already accepted never gets these codes: it gets `200` with its receipt.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked only for a new remittance, after the resend check. The `layout` member names the layout (`CNAB_240`).
            - `PBP-0905`: the file has a structural defect. `defects` lists up to 100 of them, with record number and field.
            - `PBP-0906`: the header names no CNAB agreement of the organization, or its bank code or company tax id differ.
            - `PBP-0911`: the CNAB agreement is `INACTIVE`.
            - `PBP-0910`: the `reason` member is `PCR_CONNECTION_MISSING`: the tenant has no PCR connection.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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 stored. Send the same file again: if the first attempt did commit, the resend returns `200` with its receipt. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's storage, its CNAB switch or the CNAB file keys.
      security:
        - BearerAuth: []
      summary: Send a CNAB 240 Lerian remittance file
      tags:
        - CNAB Remittances
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/send-a-cnab-240-lerian-remittance-file
    get:
      description: |-
        Lists the remittance receipts of the organization in `X-Organization-Id`, newest first, without their lines.

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

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

        **How it works**

        - The order is `receivedAt`, then `id`.
        - A page holds up to `limit` receipts. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor works only for the query that returned it, filters included. Any other cursor is refused with `PBP-0001`.
        - `receivedFrom` and `receivedTo` take a date (`YYYY-MM-DD`, a whole UTC day) or an RFC 3339 date-time with offset (an exact instant). Encode a positive offset as `%2B`.
        - Dry runs are never stored and never listed.
      operationId: listCnabRemittances
      parameters:
        - description: 'Midaz organization the remittances belong to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the remittances belong to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            type: string
        - description: Only the remittances of this CNAB agreement; one of another organization lists nothing.
          explode: false
          in: query
          name: agreementId
          schema:
            description: Only the remittances of this CNAB agreement; one of another organization lists nothing.
            format: uuid
            type: string
        - description: Only the remittances in this status.
          explode: false
          in: query
          name: status
          schema:
            description: Only the remittances in this status.
            enum:
              - VALIDATED
              - PROCESSING
              - COMPLETED
            type: string
        - description: Lower bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: receivedFrom
          schema:
            description: Lower bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Upper bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset is used as the exact instant. receivedFrom after receivedTo is refused with 422 PBP-0006.
          explode: false
          in: query
          name: receivedTo
          schema:
            description: Upper bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset is used as the exact instant. receivedFrom after receivedTo is refused with 422 PBP-0006.
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 50
            description: Most items per page.
            examples:
              - 50
            format: int64
            maximum: 200
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabRemittanceList'
          description: OK. One page of remittance receipts.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: a query parameter does not match the schema, or the cursor is not one this query returned to the same tenant, organization and filters.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
                PBP-0006:
                  summary: 'PBP-0006: Inverted date range'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: receivedFrom must be before or equal to receivedTo
                    code: PBP-0006
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
            - `PBP-0006`: `receivedFrom` is after `receivedTo`.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database or its CNAB switch.
      security:
        - BearerAuth: []
      summary: List the remittances
      tags:
        - CNAB Remittances
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-remittances
  /v1/cnab/remittances/{remittance_id}:
    get:
      description: |-
        Returns the receipt of one remittance as it stands now.

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

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

        **How it works**

        - The receipt has the status (`VALIDATED`, `PROCESSING`, `COMPLETED`), counts per line status, NSA alerts and informational notices.
        - The remittance is `COMPLETED` when every line is `EXECUTED` or `REJECTED`.
        - A line waiting on a transient provider failure is retried without limit. It keeps the remittance `PROCESSING`.
        - Receipts are never purged. The raw file is.
        - A remittance of another organization gets `404`, the same as one that does not exist.
      operationId: getCnabRemittance
      parameters:
        - description: 'Midaz organization the remittance belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A remittance of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the remittance belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A remittance of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Identifier of the remittance.
          in: path
          name: remittance_id
          required: true
          schema:
            description: Identifier of the remittance.
            examples:
              - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b70
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabRemittanceReceipt'
          description: OK. The remittance receipt.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: `remittance_id` is not a UUID.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0902:
                  summary: 'PBP-0902: Remittance not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0902
                    title: CNAB Remittance Not Found
                    status: 404
                    detail: CNAB Remittance Not Found
                    code: PBP-0902
          description: |-
            Not Found.

            - `PBP-0902`: no remittance with this id in the organization. A remittance of another organization gets the same answer.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database or its CNAB switch.
      security:
        - BearerAuth: []
      summary: Get a remittance receipt
      tags:
        - CNAB Remittances
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-remittance-receipt
  /v1/cnab/remittances/{remittance_id}/lines:
    get:
      description: |-
        Lists the title lines of one remittance in file order: batch number, then record sequence.

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

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

        **How it works**

        - Each line has the movement, nosso número, document number (C011), company title id (G072), status and up to 5 C047 reasons.
        - A line never carries a payer's name, tax id or address.
        - Paging works as in `GET /v1/cnab/remittances`, but in file order. A cursor works only for the same tenant, organization, remittance and `status`.
        - A remittance of another organization gets `404`, the same as one that does not exist.
      operationId: listCnabRemittanceLines
      parameters:
        - description: 'Midaz organization the remittance belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A remittance of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the remittance belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A remittance of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Identifier of the remittance.
          in: path
          name: remittance_id
          required: true
          schema:
            description: Identifier of the remittance.
            examples:
              - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b70
            format: uuid
            type: string
        - description: Only the lines in this status.
          explode: false
          in: query
          name: status
          schema:
            description: Only the lines in this status.
            enum:
              - WAITING
              - READY
              - IN_FLIGHT
              - EXECUTED
              - REJECTED
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 50
            description: Most items per page.
            examples:
              - 50
            format: int64
            maximum: 200
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabRemittanceLineList'
          description: OK. One page of remittance lines.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: `remittance_id` or a query parameter does not match the schema, or the cursor is not one this query returned to the same tenant, organization, remittance and `status`.
            - `PBP-0025`: `X-Organization-Id` is missing or 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0902:
                  summary: 'PBP-0902: Remittance not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0902
                    title: CNAB Remittance Not Found
                    status: 404
                    detail: CNAB Remittance Not Found
                    code: PBP-0902
          description: |-
            Not Found.

            - `PBP-0902`: no remittance with this id in the organization. A remittance of another organization gets the same answer.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
          description: |-
            Unprocessable Entity. Nothing was read or written.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. Checked before any other business rule. The `layout` member names the layout that is off (`CNAB_240`).
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database or its CNAB switch.
      security:
        - BearerAuth: []
      summary: List the lines of a remittance
      tags:
        - CNAB Remittances
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-lines-of-a-remittance
  /v1/cnab/returns:
    post:
      description: |-
        Generates the return of one CNAB agreement now, with every journal movement not yet reported, in the order they happened.

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

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

        **How it works**

        - The agreement may be `ACTIVE` or `INACTIVE`.
        - A new return takes the agreement's next return NSA, with no gaps. The `CNAB_RETURN_AVAILABLE` notice is queued in the same transaction.
        - A return file holds at most 49,999 movements in a single batch: the record sequence (G038) has 5 digits, and each movement takes a T and a U segment.
        - With more movements, this request generates only the first file, with `moreReturnsInCut` true. The scheduled cut generates the next files in its next cycles, within about a minute. Each has its own consecutive NSA and notice. `GET /v1/cnab/returns` lists them as they are generated.
        - With nothing to report, the answer is `204`: no file, no NSA consumed, no notice.
        - An on-demand cut within a minute of the agreement's latest on-demand return is refused with `PBP-0914`. A cut answered `204` generates no return and does not count, and scheduled cuts do not count either. Each on-demand return takes an NSA of the agreement's range, which never comes back.
        - A retry under the same `Idempotency-Key` replays the first answer (`201` with the same return, or `204`), even if movements arrived since. To cut again, use a new key.
        - Scheduled cuts at the agreement's cut times keep running.
        - An agreement of another organization gets `404`, the same as one that does not exist.
      operationId: cutCnabReturn
      parameters:
        - description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. An agreement of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the CNAB agreement belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. An agreement of another organization is answered 404, exactly as one that does not exist.'
            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 is refused with 400 PBP-0012. The same key under another organization is refused with 422 PBP-0013.'
          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 is refused with 400 PBP-0012. The same key under another organization is refused with 422 PBP-0013.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CutCnabReturnRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabReturn'
          description: Created. The return generated by this cut. With movements for more than one file, the first one, with `moreReturnsInCut` true.
        '204':
          description: No Content. Nothing to report. No file was generated and no NSA was consumed.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body does not match the schema.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0901:
                  summary: 'PBP-0901: CNAB agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0901
                    title: CNAB Agreement Not Found
                    status: 404
                    detail: CNAB Agreement Not Found
                    code: PBP-0901
          description: |-
            Not Found.

            - `PBP-0901`: no CNAB agreement with this id in the organization. An agreement of another organization gets the same answer.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0913:
                  summary: 'PBP-0913: Cut already running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0913
                    title: CNAB Return Cut In Progress
                    status: 409
                    detail: CNAB Return Cut In Progress
                    code: PBP-0913
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0913`: another cut or a remittance receipt of the same agreement is running. Nothing was written. Retry later.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait. This answer lasts at most five minutes after the earlier request arrived. After that, the key returns the stored answer, `500` `PBP-0002` when it cannot be replayed, or runs the request when no answer was kept. Do not switch keys: the earlier request can still take effect.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
          description: |-
            Unprocessable Entity.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. On-demand cuts are refused while it is off. The `layout` member names the layout (`CNAB_240`).
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body or under another organization. Send under a new key.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
        '429':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0914:
                  summary: 'PBP-0914: Cut asked too soon'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0914
                    title: CNAB Return Cut Too Soon
                    status: 429
                    detail: CNAB Return Cut Too Soon
                    code: PBP-0914
          description: |-
            Too Many Requests.

            - `PBP-0914`: the agreement's latest on-demand return was generated less than a minute ago. Nothing was written and no NSA was consumed. Retry after the seconds in `Retry-After`.
          headers:
            Retry-After:
              description: Seconds until the agreement accepts another on-demand cut.
              schema:
                minimum: 1
                type: integer
        '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.

            - `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. Send the same request again under the same `Idempotency-Key`. The `detail` is a fixed text.

            - `PBP-0008`: a dependency did not answer: authentication, the tenant's database, its CNAB switch, the registration or the CNAB file keys. Also returned when the agreement changed while the cut was being prepared.
      security:
        - BearerAuth: []
      summary: Cut a return file now
      tags:
        - CNAB Returns
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/cut-a-return-file-now
    get:
      operationId: listCnabReturns
      summary: List the returns
      description: |-
        Lists the returns of the organization in `X-Organization-Id`, newest first.

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

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

        **How it works**

        - The order is `generatedAt`, then `id`.
        - Paging works as in `GET /v1/cnab/agreements`.
        - `generatedFrom` and `generatedTo` take a date (`YYYY-MM-DD`, a whole UTC day) or an RFC 3339 date-time with offset (an exact instant). Encode a positive offset as `%2B`.
        - A return whose stored file was purged is still listed (`filePurged` true) and can still be downloaded.
      parameters:
        - $ref: '#/components/parameters/OrganizationId'
        - name: agreementId
          in: query
          description: Only the returns of this CNAB agreement.
          schema:
            type: string
            format: uuid
        - name: generatedFrom
          in: query
          description: Lower bound of generatedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset is used as the exact instant. A positive offset must be percent-encoded (%2B).
          schema:
            $ref: '#/components/schemas/DateOrInstantFilter'
        - name: generatedTo
          in: query
          description: Upper bound of generatedAt, inclusive. A calendar date is a UTC day and covers it to its last instant. generatedFrom after generatedTo is refused with 422 PBP-0006.
          schema:
            $ref: '#/components/schemas/DateOrInstantFilter'
        - $ref: '#/components/parameters/Cursor'
        - $ref: '#/components/parameters/Limit'
      responses:
        '200':
          description: OK. One page of returns.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabReturnList'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a query parameter does not match the schema, or `cursor` is not one this query returned: altered, from another tenant or organization, or from other filters. Request the first page again without `cursor`.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `cnab` read permission on the organization.
          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
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0900`: CNAB 240 is not enabled for the tenant. The `layout` member names the layout (`CNAB_240`).
            - `PBP-0006`: `generatedFrom` is after `generatedTo`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/CnabNotEnabledProblem'
                  - $ref: '#/components/schemas/Detail'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
                PBP-0006:
                  summary: 'PBP-0006: Inverted date range'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: generatedFrom must be before or equal to generatedTo
                    code: PBP-0006
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure. Contact support.
          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
        '503':
          description: |-
            Service Unavailable. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency is unavailable: authentication, the tenant's storage or the tenant's CNAB keys.
          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
      security:
        - BearerAuth: []
      tags:
        - CNAB Returns
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-returns
  /v1/cnab/returns/{return_id}:
    get:
      operationId: getCnabReturn
      summary: Get a return
      description: |-
        Returns the metadata of one return: agreement, NSA, trigger, movement count and hash. To get the file, use `GET /v1/cnab/returns/{return_id}/file`.

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

        <Warning>**Under development.** This endpoint can change before it is released.</Warning>
      parameters:
        - $ref: '#/components/parameters/OrganizationId'
        - $ref: '#/components/parameters/ReturnId'
      responses:
        '200':
          description: OK. The return metadata.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CnabReturn'
        '400':
          description: |-
            Bad Request.

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

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `cnab` read permission on the organization.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0903`: no return with this id in the organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0903:
                  summary: 'PBP-0903: Return not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0903
                    title: CNAB Return Not Found
                    status: 404
                    detail: CNAB Return Not Found
                    code: PBP-0903
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0900`: the layout in the `layout` member (`CNAB_240`) is not enabled for the tenant, the tenant has no Lerian (PCR) collections, or its collections are switched off. `layout` is always present. Ask Lerian operations.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/CnabNotEnabledProblem'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure. Contact support.
          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
        '503':
          description: |-
            Service Unavailable. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency is unavailable: authentication, the tenant's storage or the tenant's CNAB keys.
          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
      security:
        - BearerAuth: []
      tags:
        - CNAB Returns
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-return
  /v1/cnab/returns/{return_id}/file:
    get:
      operationId: downloadCnabReturnFile
      summary: Download a return file
      description: |-
        Downloads the CNAB 240 Lerian return file.

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

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

        **How it works**

        - Records have 240 positions, in uppercase ASCII without accents. Each ends in CRLF.
        - The file has a file header (G015 = 2), one collection batch (G028 = T, service 01, layout 060) with a T/U segment pair per movement, and the batch and file trailers.
        - Every download of the same return has the same NSA and the same content.
        - After the stored file is purged (`filePurged` true), the file is rebuilt from the movement journal. It is identical to the original, except the payer of titles that no longer exist.
        - This is the only CNAB answer with personal data: payer type, tax id and name in 23.3T to 25.3T, read from the boleto at generation. A rejection with no boleto has zeros and blanks there.
      parameters:
        - $ref: '#/components/parameters/OrganizationId'
        - $ref: '#/components/parameters/ReturnId'
      responses:
        '200':
          description: OK. The return file.
          headers:
            Content-Disposition:
              description: attachment, with a file name made of the agreement code and the 6-digit NSA.
              schema:
                type: string
                examples:
                  - attachment; filename="CNAB240_RET_1234567_000042.txt"
          content:
            text/plain:
              schema:
                type: string
                description: The return file, ASCII, CRLF line endings, every record 240 positions.
        '400':
          description: |-
            Bad Request.

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

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `cnab` read permission on the organization.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0903`: no return with this id in the organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0903:
                  summary: 'PBP-0903: Return not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0903
                    title: CNAB Return Not Found
                    status: 404
                    detail: CNAB Return Not Found
                    code: PBP-0903
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0900`: the layout in the `layout` member (`CNAB_240`) is not enabled for the tenant, the tenant has no Lerian (PCR) collections, or its collections are switched off. `layout` is always present. Ask Lerian operations.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/CnabNotEnabledProblem'
              examples:
                PBP-0900:
                  summary: 'PBP-0900: CNAB 240 not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0900
                    title: CNAB Not Enabled
                    status: 422
                    detail: CNAB 240 is not enabled for this tenant
                    code: PBP-0900
                    layout: CNAB_240
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure. Contact support. A stored file sealed with a key the platform no longer holds is rebuilt from the journal instead, never answered with this code. Content is never sent undecrypted.
          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
        '503':
          description: |-
            Service Unavailable. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency is unavailable: authentication, the tenant's storage or the tenant's CNAB keys.
          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
      security:
        - BearerAuth: []
      tags:
        - CNAB Returns
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/download-a-return-file
  /v1/collections/agreement-divergences:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the divergences between the tenant's collections agreements and the PCR's beneficiary base. The reconciliation with each beneficiary inventory the PCR publishes raises them.

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

        **How it works**

        - A divergence is never resolved on its own.
        - A divergence carries only agreement and situation attributes, never a document or a name.
        - Divergences are ordered oldest first, by `detectedAt` and then by `id`.
        - A page holds up to `limit` divergences. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor is valid only for the query that returned it. Send it with the same filters, as the same tenant. `limit` may change from one page to the next.
      operationId: listAgreementDivergences
      parameters:
        - description: 'Only the divergences related to accounts of this Midaz organization. It only filters: the permission covers all the tenant''s divergences.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the divergences related to accounts of this Midaz organization. It only filters: the permission covers all the tenant''s divergences.'
            format: uuid
            type: string
        - description: Only the divergences of this Midaz account.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the divergences of this Midaz account.
            format: uuid
            type: string
        - description: Only the divergences of this kind.
          explode: false
          in: query
          name: kind
          schema:
            description: Only the divergences of this kind.
            enum:
              - MISSING_IN_NUCLEA
              - MISSING_LOCALLY
              - ATTRIBUTE_MISMATCH
              - SITUATION_MISMATCH
            type: string
        - description: Only the divergences in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the divergences in this state.
            enum:
              - OPEN
              - RESOLVING
              - RESOLVED
            type: string
        - description: 'Only the MISSING_LOCALLY divergences not adopted for this reason: a holder with several ledger accounts, or with none.'
          explode: false
          in: query
          name: adoptionBlockReason
          schema:
            description: 'Only the MISSING_LOCALLY divergences not adopted for this reason: a holder with several ledger accounts, or with none.'
            enum:
              - AMBIGUOUS_ACCOUNT
              - NO_LEDGER_ACCOUNT
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most divergences per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most divergences per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgreementDivergenceList'
          description: OK. One page of divergences.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Cursor not valid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: cursor is not valid for this query
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `cursor` is not one this query returned: it was altered, or was returned to another tenant or with other filters. Request the first page again without `cursor`.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Query parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: List agreement divergences
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-agreement-divergences
  /v1/collections/agreement-divergences/{divergence_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one divergence between the tenant's collections agreements and the PCR's beneficiary base. It carries only agreement and situation attributes, never a document or a name.

        <Info>**Providers:** Lerian (PCR).</Info>
      operationId: getAgreementDivergence
      parameters:
        - description: Identifier of the divergence.
          in: path
          name: divergence_id
          required: true
          schema:
            description: Identifier of the divergence.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgreementDivergence'
          description: OK. The divergence.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Divergence not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no divergence with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: divergence_id must be a UUID
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `divergence_id` is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Get an agreement divergence
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-an-agreement-divergence
  /v1/collections/agreement-divergences/{divergence_id}/adopt:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Resolves a divergence by bringing collections in line with the PCR's beneficiary base. The divergence ends `RESOLVED` as `ADOPTED`.

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

        **How it works**

        - Every kind first needs collections configured and a valid PCR license, even the kinds that send nothing to the PCR. Otherwise the request is refused with `PBP-0800` or `PBP-0811` before the divergence is read.
        - `MISSING_LOCALLY` is an agreement registered at Núclea outside collections. Collections reads the base's beneficiary at the PCR, finds the holder by document and lists the holder's ledger accounts. The agreement becomes an `IMPORTED` agreement of the holder's account.
        - With one account, the agreement is adopted on it. If you send `accountId`, it must be that account.
        - With several accounts, `accountId` is required. Without it, the request is refused with `PBP-0824` and `AMBIGUOUS_ACCOUNT`.
        - With no account, the request is refused with `PBP-0824` and `NO_LEDGER_ACCOUNT`. Create the account in the ledger and adopt again, or exclude the relationship with `POST /v1/collections/agreement-divergences/{divergence_id}/correct`.
        - The adopted agreement gets a seven-position code from collections and keeps the base's code in `importedAgreementCode`.
        - It stays `PENDING_REGISTRATION` until Núclea accepts the beneficiary update (DDA0502) with the new code. A refusal leaves it `REGISTRATION_REJECTED`.
        - Titles already issued with the base's code stay valid. The answer is `ENQUEUED`.
        - An adopted agreement cannot take the Núclea key of another agreement of the same holder that Núclea holds or may hold: Núclea would merge the two. This is refused with `PBP-0806`.
        - `MISSING_IN_NUCLEA` closes the agreement the base no longer has.
        - `ATTRIBUTE_MISMATCH` takes the base's branch and account.
        - `SITUATION_MISMATCH` takes the holder's situation in the base. It blocks the agreements of a holder under review or unfit, and unblocks those of a fit holder.
        - These three kinds answer `APPLIED` and send nothing to the PCR.
        - The action is recorded in the audit trail as `ADOPT_AGREEMENT_DIVERGENCE`, with the reason.
      operationId: adoptAgreementDivergence
      parameters:
        - description: Identifier of the divergence.
          in: path
          name: divergence_id
          required: true
          schema:
            description: Identifier of the divergence.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdoptAgreementDivergenceRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The action is recorded in the audit trail. `outcome` is `ENQUEUED` for `MISSING_LOCALLY` and `APPLIED` for the other kinds.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Divergence not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no divergence with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0806:
                  summary: 'PBP-0806: Agreement already exists'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0806
                    title: Agreement Already Exists
                    status: 409
                    detail: Agreement Already Exists
                    code: PBP-0806
                    details:
                      agreementId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
                PBP-0803:
                  summary: 'PBP-0803: Agreement changed meanwhile'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0806`: the account already holds a live agreement of the product type. Or the adopted agreement would take the Núclea key (branch, account and product type) of another agreement of the holder. `details.agreementId` names that agreement.
            - `PBP-0803`: the agreement changed meanwhile. Read the divergence again.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Reason too short'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have 10 to 500 characters of UTF-8 text, without control characters other than tab and line breaks
                    code: PBP-0006
                PBP-0824:
                  summary: 'PBP-0824: Account required'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0824
                    title: Adoption Account Required
                    status: 422
                    detail: Adoption Account Required
                    code: PBP-0824
                    details:
                      adoptionBlockReason: AMBIGUOUS_ACCOUNT
                PBP-0825:
                  summary: "PBP-0825: Account not the holder's"
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0825
                    title: Account Not Of Beneficiary
                    status: 422
                    detail: Account Not Of Beneficiary
                    code: PBP-0825
                PBP-0808:
                  summary: 'PBP-0808: Account closed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0808
                    title: Account Not Eligible
                    status: 422
                    detail: Account Not Eligible
                    code: PBP-0808
                PBP-0801:
                  summary: 'PBP-0801: Product type not offered'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: product type other than 01 and 07
                    code: PBP-0801
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed now'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the divergence was not observed by the latest inventory
                    code: PBP-0802
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: missing the connection to the PCR
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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.

            - `PBP-0006`: the body or `divergence_id` does not match the schema, or the reason has fewer than 10 characters once trimmed.
            - `PBP-0824`: the holder has several ledger accounts and `accountId` is missing (`AMBIGUOUS_ACCOUNT`), or has none (`NO_LEDGER_ACCOUNT`). `details.adoptionBlockReason` says which. Send `accountId`, or create the account and adopt again.
            - `PBP-0825`: `accountId` is not one of the holder's accounts.
            - `PBP-0808`: the account is closed.
            - `PBP-0801`: the product type is outside 01 and 07, or the agreement template has no item of it.
            - `PBP-0802`: refused, and nothing changed. The divergence is not `OPEN`, or the agreement or the holder has an exchange with Núclea in flight. Or the latest completed inventory consumption, or the attempt that completed it, did not raise the divergence. Or another collections beneficiary already holds the base's beneficiary.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Set them with `PUT /v1/collections/connection` and `PUT /v1/collections/settings`.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the PCR license.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0810:
                  summary: 'PBP-0810: People registry unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0810
                    title: People Registry Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0810
                PBP-0816:
                  summary: 'PBP-0816: PCR unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0816
                    title: PCR Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0816
                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.

            - `PBP-0810`: the ledger's people registry did not answer. Nothing changed. Retry under the same `Idempotency-Key`.
            - `PBP-0816`: the PCR did not answer, or answered the beneficiary's document masked. Nothing changed. Retry under the same `Idempotency-Key`.
            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Adopt an agreement divergence
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/adopt-an-agreement-divergence
  /v1/collections/agreement-divergences/{divergence_id}/correct:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Resolves a divergence by sending to the PCR's beneficiary base what collections holds. The answer is `ENQUEUED`: the command follows to the PCR.

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

        **How it works**

        - Collections must be configured and the PCR license valid. Otherwise the request is refused with `PBP-0800` or `PBP-0811` before the divergence is read.
        - `MISSING_IN_NUCLEA` or `ATTRIBUTE_MISMATCH`: the agreement goes to Núclea again as collections has it, in a beneficiary update (DDA0502). The agreement is `PENDING_REGISTRATION` until the answer, and the divergence is `RESOLVED` as `CORRECTED`.
        - For `ATTRIBUTE_MISMATCH`, the same update also ends, under the same agreement code, the agreement at the branch, account and product type the base holds.
        - While the beneficiary has an exchange with Núclea in flight, an `ATTRIBUTE_MISMATCH` is refused with `PBP-0802`. Correct it after that exchange ends.
        - `MISSING_LOCALLY` is an agreement only the base has, whose relationship no collections beneficiary holds. It is corrected by excluding the relationship (DDA0503). The divergence stays `RESOLVING` until the exclusion's outcome.
        - `SITUATION_MISMATCH` is refused with `PBP-0802`. Only the institution changes the holder's own situation, with dual approval in the PCR administration interface.
        - The action is recorded in the audit trail as `CORRECT_AGREEMENT_DIVERGENCE`, with the reason.
      operationId: correctAgreementDivergence
      parameters:
        - description: Identifier of the divergence.
          in: path
          name: divergence_id
          required: true
          schema:
            description: Identifier of the divergence.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The action is recorded in the audit trail, with `outcome` `ENQUEUED`. The command follows to the PCR.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Divergence not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no divergence with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Agreement changed meanwhile'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: the agreement changed while it was being corrected. Read the divergence again.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Reason too short'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have 10 to 500 characters of UTF-8 text, without control characters other than tab and line breaks
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed now'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the holder's own situation is corrected only by the institution, with dual approval in the PCR administration interface
                    code: PBP-0802
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: missing the connection to the PCR
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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.

            - `PBP-0006`: the body or `divergence_id` does not match the schema, or the reason has fewer than 10 characters once trimmed.
            - `PBP-0802`: refused, and nothing changed. The divergence is not `OPEN`, or its agreement has an exchange with Núclea in flight (`details.currentState` has the state). Or the latest completed inventory consumption, or the attempt that completed it, did not raise the divergence. Or it is a `SITUATION_MISMATCH`, a `MISSING_LOCALLY` whose relationship a collections beneficiary holds, or an `ATTRIBUTE_MISMATCH` of a beneficiary with an exchange with Núclea in flight.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Set them with `PUT /v1/collections/connection` and `PUT /v1/collections/settings`.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the PCR license.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Correct the beneficiary base from collections
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/correct-the-beneficiary-base-from-collections
  /v1/collections/agreements:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the tenant's agreements, one per account and product type at Núclea, with their state and origin.

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

        **How it works**

        - No document or name is returned.
        - Agreements are ordered oldest first, by creation and then by an internal id.
        - A page holds up to `limit` agreements. `total` counts every agreement the filters match. A page past the last returns no agreement.
        - The list does not read numbering counters, so `numbering.nextValue` is null here. Read it with `GET /v1/collections/agreements/{agreement_id}`.
      operationId: listAgreements
      parameters:
        - description: 'Only the agreements of accounts of this Midaz organization. It only filters: the permission covers all the tenant''s agreements.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the agreements of accounts of this Midaz organization. It only filters: the permission covers all the tenant''s agreements.'
            format: uuid
            type: string
        - description: Only the agreements of this Midaz account.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the agreements of this Midaz account.
            format: uuid
            type: string
        - description: Only the agreements of this beneficiary.
          explode: false
          in: query
          name: beneficiaryId
          schema:
            description: Only the agreements of this beneficiary.
            format: uuid
            type: string
        - description: Only the agreements of this product type at Núclea, two digits.
          explode: false
          in: query
          name: productType
          schema:
            description: Only the agreements of this product type at Núclea, two digits.
            examples:
              - '01'
            pattern: ^[0-9]{2}$
            type: string
        - description: Only the agreements in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the agreements in this state.
            enum:
              - PENDING_REGISTRATION
              - ACTIVE
              - BLOCKED
              - CLOSING
              - CLOSED
              - CLOSURE_FAILED
              - REGISTRATION_REJECTED
            type: string
        - description: Page number, from 1. A page past the last answers no agreement.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, from 1. A page past the last answers no agreement.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Most agreements per page, 1 to 100.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most agreements per page, 1 to 100.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgreementPage'
          description: OK. One page of agreements.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Query parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema. Examples: `page` below 1, `limit` outside 1 to 100, an identifier that is not a UUID, a product type that is not two digits, or an unknown state.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: List the agreements
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-agreements
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Creates an agreement outside the default agreement template, on an account whose holder is already enabled for collections. The account and its ledger belong to the Midaz organization in `X-Organization-Id`.

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

        **How it works**

        - An account has at most one live agreement per product type.
        - An account linked to a pooled account has no agreement of its own.
        - Two agreements of one holder cannot share the same branch, account and product type at Núclea.
        - Each of these three cases is refused with `PBP-0806`.
        - Product types other than 01 and 07, portfolios other than 01 and species 31, 32 and 33 are refused with `PBP-0801`.
        - An accepted agreement answers `202` with state `PENDING_REGISTRATION`. Its inclusion goes to Núclea through the PCR, as an update of the holder's registration or with the holder's enablement still in progress.
        - An agreement without its branch at Núclea is not sent. `registrationBlockedReason` is `MISSING_BRANCH` until the branch is assigned. The assignment waits while another agreement of the holder holds the Núclea key that branch would give.
        - No notice is sent for the registration outcome. Read it with `GET /v1/collections/agreements/{agreement_id}`.
        - The creation is recorded in the collections audit trail with its `reason` and the identity that made it.
        - The same `Idempotency-Key` and body under another organization is a different request.
      operationId: createAgreement
      parameters:
        - description: 'Midaz organization of the account the body names. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization of the account the body names. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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. The same key and body under another organization is another request.'
          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. The same key and body under another organization is another request.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgreementRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agreement'
          description: 'Accepted. The agreement is `PENDING_REGISTRATION`. No notice is sent for the registration outcome: follow it with `GET /v1/collections/agreements/{agreement_id}`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                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: ledgerId missing'
                  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
                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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0026`: `ledgerId` is missing, blank or not a canonical UUID.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0806:
                  summary: 'PBP-0806: Agreement already exists'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0806
                    title: Agreement Already Exists
                    status: 409
                    detail: Agreement Already Exists
                    code: PBP-0806
                    details:
                      agreementId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
                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-0806`: the agreement cannot be created, and nothing was written. The account already holds a live agreement of the product type (`details.agreementId`), or a link to a pooled account it issues under (`details.linkId`). Or its branch would give it the Núclea key of another agreement of the holder, on another account, that is `PENDING_REGISTRATION` with its branch, `ACTIVE`, `BLOCKED`, `CLOSING` or `CLOSURE_FAILED` (`details.agreementId`). Núclea tells a holder's agreements apart, and merges them, by that key. The key is the branch (compared as an integer, so 0001 and 1 match), the account with its type or none, and the product type.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Value breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: AT_SETTLEMENT requires chargebackRiskAcknowledged
                    code: PBP-0006
                PBP-0801:
                  summary: 'PBP-0801: Product type not offered'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: product type other than 01 and 07
                    code: PBP-0801
                PBP-0808:
                  summary: 'PBP-0808: Account not eligible'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0808
                    title: Account Not Eligible
                    status: 422
                    detail: Account Not Eligible
                    code: PBP-0808
                PBP-0809:
                  summary: 'PBP-0809: Account without holder'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0809
                    title: Holder Data Incomplete
                    status: 422
                    detail: Holder Data Incomplete
                    code: PBP-0809
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: missing the connection to the PCR
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with another body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
          description: |-
            Unprocessable Entity. Refused, and nothing was written.

            - `PBP-0006`: the body does not match the schema, `accountId` is not a UUID, or a value breaks a rule. Examples: the nil UUID as `accountId`, a nosso número range whose start is above its end, `AT_SETTLEMENT` without `chargebackRiskAcknowledged: true`, or a reason shorter than 10 characters once trimmed.
            - `PBP-0801`: a product type, species or portfolio collections does not issue.
            - `PBP-0808`: the ledger does not have the account under the organization and ledger sent, the account is closed, or its holder is not enabled for collections (no enablement in progress or accepted). Enable the holder first.
            - `PBP-0809`: the account has no holder.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Set them with `PUT /v1/collections/connection` and `PUT /v1/collections/settings`.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the PCR license.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0810:
                  summary: 'PBP-0810: People registry unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0810
                    title: People Registry Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0810
                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.

            - `PBP-0810`: the ledger's people registry did not answer while the account and its holder were read. Nothing was written. Retry under the same `Idempotency-Key`.
            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Create an agreement outside the default template
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/create-an-agreement-outside-the-default-template
  /v1/collections/agreements/{agreement_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one of the tenant's agreements, with the next nosso número of its numbering counter in `numbering.nextValue`.

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

        **How it works**

        - No document or name is returned.
        - Read the agreement to learn the outcome of its registration. No notice is sent for it.
      operationId: getAgreement
      parameters:
        - description: Identifier of the agreement.
          in: path
          name: agreement_id
          required: true
          schema:
            description: Identifier of the agreement.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agreement'
          description: OK. The agreement.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no agreement with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: agreement_id must be a UUID
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `agreement_id` is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Get an agreement
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-an-agreement
    patch:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Changes the issuing rules of an `ACTIVE` agreement: portfolio, species, credit delay, release policy, payment deadline and nosso número range.

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

        **How it works**

        - Only the fields you send change.
        - The product type and the account never change. To change them, close the agreement and create another.
        - The change applies to boletos issued after it. Boletos already issued keep their rules.
        - None of these fields is in the agreement's registration at Núclea, so nothing is sent to the PCR.
        - Send the `version` you last read. Any other version is refused with `PBP-0803`.
        - An agreement in any state other than `ACTIVE` is refused with `PBP-0802`.
        - A new nosso número range must still hold the counter's next value.
        - Every change is recorded in the collections audit trail with its `reason`, the identity that made it and the agreement before and after.
      operationId: updateAgreement
      parameters:
        - description: Identifier of the agreement.
          in: path
          name: agreement_id
          required: true
          schema:
            description: Identifier of the agreement.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAgreementRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agreement'
          description: OK. The agreement with the change applied.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no agreement with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Version is not current'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: `version` is not the current one. Nothing was written. Read the agreement again and send the change with the current `version`.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Range leaves out next value'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: numbering range must hold the counter's next value
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Agreement not active'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: Action Not Allowed In State
                    code: PBP-0802
                    details:
                      currentState: BLOCKED
                PBP-0801:
                  summary: 'PBP-0801: Species not offered'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: species with special rules
                    code: PBP-0801
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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. Refused, and nothing was written.

            - `PBP-0006`: the body or `agreement_id` does not match the schema, or a value breaks a rule. Examples: a nosso número range whose start is above its end, a range that leaves out the counter's next value, `AT_SETTLEMENT` without `chargebackRiskAcknowledged: true`, or a reason shorter than 10 characters once trimmed.
            - `PBP-0802`: the agreement is not `ACTIVE`. `details.currentState` has its state.
            - `PBP-0801`: a species or portfolio collections does not issue.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Change the issuing rules of an agreement
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/change-the-issuing-rules-of-an-agreement
  /v1/collections/agreements/{agreement_id}/close:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Closes one agreement with the client's `reason`. The account stops issuing under it. Boletos already registered do not change.

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

        **How it works**

        - `ACTIVE`, `BLOCKED`, `CLOSURE_FAILED` and `PENDING_REGISTRATION` agreements can be closed. Any other state is refused with `PBP-0802`.
        - An agreement Núclea holds, or may hold through a command in flight to the PCR, goes to `CLOSING` with `outcome` `ENQUEUED`. Its exclusion goes to Núclea through the PCR after the maintenance in flight on the holder is answered.
        - While the holder keeps another live agreement, an update of the holder's registration (DDA0502) ends only this agreement.
        - When this was the holder's last live agreement, the relationship is excluded (DDA0503). This is checked again before sending: if another agreement became live meanwhile, the relationship stays and only this agreement ends.
        - Núclea's answer moves the agreement to `CLOSED` or to `CLOSURE_FAILED`. A `CLOSURE_FAILED` agreement can be closed again.
        - An agreement never sent to Núclea is `CLOSED` at once, with `outcome` `APPLIED`.
        - Links of other accounts to this agreement, as their pooled account, do not change.
        - The close is recorded in the collections audit trail with its `reason`, the identity that made it and the agreement before and after.
      operationId: closeAgreement
      parameters:
        - description: Identifier of the agreement.
          in: path
          name: agreement_id
          required: true
          schema:
            description: Identifier of the agreement.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The action is recorded in the audit trail. `outcome` is `ENQUEUED` when the exclusion goes to Núclea, or `APPLIED` when the agreement closed at once.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no agreement with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.
        '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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Reason too short'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have 10 to 500 characters of UTF-8 text, without control characters other than tab and line breaks
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Agreement already closed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: Action Not Allowed In State
                    code: PBP-0802
                    details:
                      currentState: CLOSED
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: missing the connection to the PCR
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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. Refused, and nothing was written.

            - `PBP-0006`: the body or `agreement_id` does not match the schema, or the reason has fewer than 10 characters once trimmed.
            - `PBP-0802`: the agreement is `CLOSING`, `CLOSED` or `REGISTRATION_REJECTED` (`details.currentState` has the state). Or the agreement's beneficiary belongs to a PCR connection that is no longer the active one (no `details`).
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Set them with `PUT /v1/collections/connection` and `PUT /v1/collections/settings`.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the PCR license.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Close an agreement
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/close-an-agreement
  /v1/collections/agreements/{agreement_id}/force-close:
    post:
      operationId: forceCloseAgreement
      summary: Close an agreement manually
      description: |-
        Closes an agreement in `CLOSURE_FAILED` locally, without a new call to the PCR. Use it when the exclusion was already made another way, for example in the PCR administration interface.

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

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

        **How it works**

        - The agreement must be `CLOSURE_FAILED`. These agreements wait in the `AGREEMENT_CLOSURE_EXCEPTION` operation queue.
        - `reason` and `evidence` are required.
        - The next reconciliation with the beneficiary base confirms the closure or opens a divergence.
        - The action is recorded in the audit trail with its reason.
      tags:
        - Collections Agreements
      parameters:
        - $ref: '#/components/parameters/AgreementIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvidencedActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail with its reason. `outcome` tells whether the effect is already applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the request is malformed
                    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
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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 is required to access this resource.
                    code: PBP-0003
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections:operate` permission this operation requires.
          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: You do not have permission to access this resource.
                    code: PBP-0004
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no agreement with this id.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the agreement right now. Retry under the same `Idempotency-Key` after it finishes.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: Item Claimed By Worker
                    status: 409
                    detail: Item Claimed By Worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing `evidence` or a reason that is missing or too short.
            - `PBP-0802`: the agreement is not `CLOSURE_FAILED`. `details.currentState` has its state.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request under a new key.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Body does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Agreement not CLOSURE_FAILED'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: Action Not Allowed In State
                    code: PBP-0802
                    details:
                      currentState: ACTIVE
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/close-an-agreement-manually
  /v1/collections/agreements/{agreement_id}/reprocess-closure:
    post:
      operationId: reprocessAgreementClosure
      summary: Reprocess the refused closure of an agreement
      description: |-
        Sends again the closure of an agreement in `CLOSURE_FAILED`: the exclusion of the relationship, or the change of the holder's registration.

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

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

        **How it works**

        - The agreement must be `CLOSURE_FAILED`. These agreements wait in the `AGREEMENT_CLOSURE_EXCEPTION` operation queue.
        - `reason` is required.
        - The action is recorded in the audit trail with its reason.
      tags:
        - Collections Agreements
      parameters:
        - $ref: '#/components/parameters/AgreementIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail with its reason. `outcome` tells whether the effect is already applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the request is malformed
                    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
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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 is required to access this resource.
                    code: PBP-0003
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections:operate` permission this operation requires.
          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: You do not have permission to access this resource.
                    code: PBP-0004
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no agreement with this id.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Agreement not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the agreement right now. Retry under the same `Idempotency-Key` after it finishes.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: Item Claimed By Worker
                    status: 409
                    detail: Item Claimed By Worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a reason that is missing or too short.
            - `PBP-0802`: the agreement is not `CLOSURE_FAILED`. `details.currentState` has its state.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Set them with `PUT /v1/collections/connection` and `PUT /v1/collections/settings`.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the PCR license.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request under a new key.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Reason too short'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have 10 to 500 characters of UTF-8 text, without control characters other than tab and line breaks
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Agreement not CLOSURE_FAILED'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: Action Not Allowed In State
                    code: PBP-0802
                    details:
                      currentState: ACTIVE
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: missing the connection to the PCR
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/reprocess-the-refused-closure-of-an-agreement
  /v1/collections/audit-actions:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the tenant's collections audit trail: every operation and configuration action, append-only. Each action has its author, time, reason and evidence, and the module's fields before and after it.

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

        **How it works**

        - Actions are ordered oldest first, by `occurredAt` and then by `id`.
        - `from` and `to` take a calendar date, read as a UTC day, or an RFC 3339 date-time with offset. Percent-encode a positive offset (`%2B`).
        - `organizationId` only filters. The permission covers the tenant's whole trail.
        - A page holds up to `limit` actions. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor is valid only for the query that returned it. Send it with the same filters, as the same tenant. `limit` may change from one page to the next.
      operationId: listAuditActions
      parameters:
        - description: 'Only the actions related to accounts of this Midaz organization. It only filters: the permission covers the tenant''s whole trail.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the actions related to accounts of this Midaz organization. It only filters: the permission covers the tenant''s whole trail.'
            format: uuid
            type: string
        - description: 'Only the actions of this author: the subject of the token, or the name of the service''s worker.'
          explode: false
          in: query
          name: actorId
          schema:
            description: 'Only the actions of this author: the subject of the token, or the name of the service''s worker.'
            maxLength: 128
            type: string
        - description: Only the actions of this kind.
          explode: false
          in: query
          name: action
          schema:
            description: Only the actions of this kind.
            enum:
              - RELEASE_WRITE_OFF
              - CANCEL_SCHEDULED_RELEASE
              - UNHOLD_WRITE_OFF
              - REVERSE_WRITE_OFF
              - REPROCESS_CREDIT_ENTRY
              - REPROCESS_PCR_COMMAND
              - CLOSE_PCR_COMMAND
              - SETTLE_SUBMISSION_FAILURE
              - ASSOCIATE_PCR_NOTICE
              - DISCARD_PCR_NOTICE
              - APPLY_PCR_NOTICE
              - WRITE_OFF_LATE_REGISTRATION
              - ENABLE_ACCOUNT
              - CREATE_ENABLEMENT_BATCH
              - APPROVE_ENABLEMENT
              - REJECT_ENABLEMENT
              - DISABLE_BENEFICIARY
              - CORRECT_AGREEMENT_DIVERGENCE
              - ADOPT_AGREEMENT_DIVERGENCE
              - BULK_ADOPT_AGREEMENT_DIVERGENCES
              - CREATE_AGREEMENT
              - UPDATE_AGREEMENT
              - CLOSE_AGREEMENT
              - REPROCESS_AGREEMENT_CLOSURE
              - FORCE_CLOSE_AGREEMENT
              - LINK_POOLED_ACCOUNT
              - REMOVE_POOLED_ACCOUNT_LINK
              - PUT_PCR_CONNECTION
              - PUT_COLLECTIONS_SETTINGS
              - SYNC_PCR_SUBSCRIPTION
              - ROTATE_PCR_NOTICE_SECRET
              - REDELIVER_PCR_NOTICE
            type: string
        - description: Only the actions on this kind of resource.
          explode: false
          in: query
          name: targetType
          schema:
            description: Only the actions on this kind of resource.
            enum:
              - TITLE
              - WRITE_OFF
              - CREDIT_ENTRY
              - PCR_COMMAND
              - PCR_NOTICE
              - BENEFICIARY
              - ENABLEMENT_BATCH
              - AGREEMENT
              - AGREEMENT_DIVERGENCE
              - POOLED_ACCOUNT_LINK
              - PCR_CONNECTION
              - PCR_SUBSCRIPTION
              - PCR_WEBHOOK_DELIVERY
              - COLLECTIONS_SETTINGS
              - ACCOUNT
            type: string
        - description: Only the actions on this resource.
          explode: false
          in: query
          name: targetId
          schema:
            description: Only the actions on this resource.
            format: uuid
            type: string
        - description: Lower bound of occurredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Lower bound of occurredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Upper bound of occurredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Upper bound of occurredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most actions per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most actions per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditActionList'
          description: OK. One page of audit actions.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid filter or cursor'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: cursor is not valid for this query
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `actorId` is not printable UTF-8 text; `from` or `to` matches the pattern but names no real instant, such as 2026-02-30; or `cursor` is not one this query returned. For a bad cursor, request the first page again without `cursor`.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Query parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, or `from` is after `to`.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: List the collections audit trail
      tags:
        - Collections Audit
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-collections-audit-trail
  /v1/collections/audit-actions/{audit_action_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one action of the tenant's collections audit trail.

        <Info>**Providers:** Lerian (PCR).</Info>
      operationId: getAuditAction
      parameters:
        - description: Identifier of the audited action.
          in: path
          name: audit_action_id
          required: true
          schema:
            description: Identifier of the audited action.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a01
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditAction'
          description: OK. The audit action.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Action not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant's audit trail has no action with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: audit_action_id must be a UUID
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `audit_action_id` is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Get an audit trail action
      tags:
        - Collections Audit
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-an-audit-trail-action
  /v1/collections/beneficiaries:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the tenant's beneficiaries: the holders enabled, or being enabled, to issue through collections. Each one shows its enablement state and its situation in Núclea's beneficiary base.

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

        **How it works**

        - The response never carries a document or a name.
        - Beneficiaries come oldest first, by creation.
        - A page holds up to `limit` beneficiaries, from 1 to 100. `total` counts every beneficiary the filters match. A page past the last one is empty.
        - `organizationId` only filters. The permission covers all of the tenant's beneficiaries.
        - `accountId` matches beneficiaries with an agreement of that account, in any state.
      operationId: listBeneficiaries
      parameters:
        - description: 'Only the beneficiaries enabled from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s beneficiaries.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the beneficiaries enabled from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s beneficiaries.'
            format: uuid
            type: string
        - description: Only the beneficiary of this holder, the person in the platform's people registry.
          explode: false
          in: query
          name: holderId
          schema:
            description: Only the beneficiary of this holder, the person in the platform's people registry.
            format: uuid
            type: string
        - description: Only the beneficiaries with an agreement of this Midaz account, in any state.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the beneficiaries with an agreement of this Midaz account, in any state.
            format: uuid
            type: string
        - description: Only the beneficiaries whose enablement is in this state.
          explode: false
          in: query
          name: enablementState
          schema:
            description: Only the beneficiaries whose enablement is in this state.
            enum:
              - REQUESTED
              - CONSULTED
              - HELD_BY_ALERT
              - SUBMITTED
              - ACCEPTED
              - REJECTED
              - DISABLED
            type: string
        - description: Only the beneficiaries with this situation in the beneficiary base.
          explode: false
          in: query
          name: baseSituation
          schema:
            description: Only the beneficiaries with this situation in the beneficiary base.
            enum:
              - FIT
              - UNDER_REVIEW
              - UNFIT
            type: string
        - description: Page number, from 1. A page past the last answers no beneficiary.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, from 1. A page past the last answers no beneficiary.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Most beneficiaries per page, 1 to 100.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most beneficiaries per page, 1 to 100.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BeneficiaryPage'
          description: OK. A page of beneficiaries.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema. Examples: `page` below 1, `limit` outside 1 to 100, an id that is not a UUID, a state or situation outside its values.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: List beneficiaries
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-beneficiaries
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Enables the holder of a Midaz account to issue boletos through collections. The account belongs to the organization in `X-Organization-Id`.

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

        **How it works**

        - The holder is read from the ledger and the people registry through the account. Do not send a document or a name. The response carries none.
        - The account gets the tenant's default agreement template. To override it, send `agreements`: 1 to 8 agreements, one per product type.
        - The enablement runs in the background through commands to the PCR. The `202` returns the holder's beneficiary as it stands. Follow it with `getBeneficiary`.
        - A holder new to collections starts as `REQUESTED`. Its registration starts with a consultation of Núclea's beneficiary base.
        - A holder already enabled, or with an enablement in progress, takes the account's agreements into the same registration.
        - A holder rejected or disabled is enabled again from `REQUESTED`.
        - An account linked to a pooled account is never enabled. It issues under the pooled account's agreement.
        - `AT_SETTLEMENT` release policy requires `chargebackRiskAcknowledged: true`.
        - The enablement is recorded in the collections audit trail with its `reason` and the identity that made it.
        - No notice is sent for the outcome (accepted, refused or held by a market alert). Read it with `getBeneficiary`.
        - The organization is part of the request. The same key under another `X-Organization-Id` is refused with `PBP-0013` while the key is kept (48 hours by default).
      operationId: enableAccount
      parameters:
        - description: 'Midaz organization of the account the body names. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization of the account the body names. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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. The same key and body under another organization is another request.'
          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. The same key and body under another organization is another request.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnableAccountRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Beneficiary'
          description: Accepted. The enablement runs in the background. The body is the holder's beneficiary as it stands. Follow it with `getBeneficiary`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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 UUID
                    code: PBP-0025
                PBP-0026:
                  summary: 'PBP-0026: Ledger id missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0026
                    title: Bad Request
                    status: 400
                    detail: ledgerId is required and must be a UUID
                    code: PBP-0026
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Idempotency Key Required
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0026`: `ledgerId` is missing, blank or not a canonical UUID.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0807:
                  summary: 'PBP-0807: Enablement in progress or done'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0807
                    title: Enablement In Progress
                    status: 409
                    detail: Enablement In Progress
                    code: PBP-0807
                    details:
                      beneficiaryId: 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a66
                PBP-0806:
                  summary: 'PBP-0806: Account cannot take the agreement'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0806
                    title: Agreement Already Exists
                    status: 409
                    detail: Agreement Already Exists
                    code: PBP-0806
                    details:
                      linkId: 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a77
                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-0807`: the holder's beneficiary already holds, with this account, an agreement of a product type you asked for. The enablement is in progress or done. Follow it with `getBeneficiary` using `details.beneficiaryId`.
            - `PBP-0806`: the account cannot take the agreement. Nothing was written. It is linked to a pooled account (`details.linkId`). Or it already holds a live agreement of that product type (`details.agreementId`). Or an agreement's branch would give it the Núclea key of another agreement of the holder, on another account, that Núclea holds or may hold (`details.agreementId`). The key is branch (0001 and 1 are the same), account with its type or none, and product type.
            - `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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when 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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Body breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0808:
                  summary: 'PBP-0808: Account not eligible'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0808
                    title: Account Not Eligible
                    status: 422
                    detail: Account Not Eligible
                    code: PBP-0808
                PBP-0809:
                  summary: 'PBP-0809: Holder data incomplete'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0809
                    title: Holder Data Incomplete
                    status: 422
                    detail: Holder Data Incomplete
                    code: PBP-0809
                PBP-0801:
                  summary: 'PBP-0801: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: the agreement's product type is not issued by collections
                    code: PBP-0801
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: no active connection to the PCR or no default agreement template
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with another body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body breaks the schema or a rule. Examples: an own agreement list empty or above 8, two agreements of the same product type, the nil UUID as an id, a nosso número range whose start is above its end, `AT_SETTLEMENT` without `chargebackRiskAcknowledged: true`, a `reason` shorter than 10 characters once trimmed or longer than 500.
            - `PBP-0808`: the account does not exist in the ledger, is closed, or is not of the organization and ledger you named. Nothing was written.
            - `PBP-0809`: the holder lacks what Núclea requires: a valid document, a name, or a trade name for a legal person. Complete the holder's record and retry.
            - `PBP-0801`: an agreement has a species, product type or portfolio that collections does not issue.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Configure them first.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the license.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body or another organization while the key is kept (48 hours by default). Use a new key for a new request.

            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. The earlier request may have taken effect. 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
                PBP-0810:
                  summary: 'PBP-0810: People registry unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0810
                    title: People Registry Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0810
          description: |-
            Service Unavailable. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
            - `PBP-0810`: the people registry did not answer. Nothing was written. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Enable an account to issue
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/enable-an-account-to-issue
  /v1/collections/beneficiaries/{beneficiary_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one of the tenant's beneficiaries, with its enablement state and its situation in Núclea's beneficiary base.

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

        **How it works**

        - The response never carries a document or a name.
        - Use this read to learn the outcome of an enablement. No notice is sent for it.
      operationId: getBeneficiary
      parameters:
        - description: Identifier of the beneficiary.
          in: path
          name: beneficiary_id
          required: true
          schema:
            description: Identifier of the beneficiary.
            examples:
              - c56a4180-65aa-42ec-a945-5fd21dec0538
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Beneficiary'
          description: OK. The beneficiary.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Beneficiary not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: beneficiary not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no beneficiary with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `beneficiary_id` is not a UUID.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: Get a beneficiary
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-beneficiary
  /v1/collections/beneficiaries/{beneficiary_id}/approve:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Approves an enablement held by a market alert (`HELD_BY_ALERT`): another institution marked the holder unfit or under review. Send the operator's `reason`.

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

        **How it works**

        - The enablement goes on to its registration in the beneficiary base through the PCR.
        - When the registration is enqueued, `outcome` is `ENQUEUED` and `targetState` is `SUBMITTED`.
        - While its agreements wait for their branch, `outcome` is `APPLIED` and `targetState` is `CONSULTED`.
        - The approval is recorded in the collections audit trail with its `reason` and the identity that made it.
      operationId: approveEnablement
      parameters:
        - description: Identifier of the original beneficiary.
          in: path
          name: beneficiary_id
          required: true
          schema:
            description: Identifier of the original beneficiary.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The approval is recorded. `outcome` and `targetState` show where the enablement went.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Beneficiary not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: beneficiary not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no beneficiary with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Agreement changed meanwhile'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: an agreement of the beneficiary changed while the action ran. Nothing was written. Resend under 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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when 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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body or id'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: enablement is not held by an alert
                    code: PBP-0802
                    details:
                      currentState: SUBMITTED
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: no active connection to the PCR or no default agreement template
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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.

            - `PBP-0006`: the body or `beneficiary_id` does not match the schema, or `reason` is shorter than 10 characters once trimmed.
            - `PBP-0802`: the enablement is not `HELD_BY_ALERT`. The state is in `details.currentState`. It also answers, without `details`, when the beneficiary belongs to a PCR connection that is no longer the active one. Read the beneficiary again: the action may already be done.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Configure them first.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the license.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.

            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. The earlier request may have taken effect. 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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Approve an enablement held by a market alert
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/approve-an-enablement-held-by-a-market-alert
  /v1/collections/beneficiaries/{beneficiary_id}/disable:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Disables the holder (`DISABLED`) with the operator's `reason`. The holder no longer issues.

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

        **How it works**

        - Agreements that Núclea holds go to `CLOSING`. An agreement never sent to Núclea goes to `CLOSED`.
        - For a holder registered in the base, the relationship at Núclea is excluded (DDA0503) through the PCR. This happens now, or once the maintenance in flight is answered. `outcome` is `ENQUEUED`.
        - If Núclea refuses an exclusion, the agreement goes to `CLOSURE_FAILED`.
        - A holder never registered sends nothing. `outcome` is `APPLIED`.
        - Titles already registered do not change.
        - The disablement is recorded in the collections audit trail with its `reason` and the identity that made it.
      operationId: disableBeneficiary
      parameters:
        - description: Identifier of the original beneficiary.
          in: path
          name: beneficiary_id
          required: true
          schema:
            description: Identifier of the original beneficiary.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The disablement is recorded. `outcome` is `ENQUEUED` when an exclusion goes to Núclea, or `APPLIED` when nothing is sent.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Beneficiary not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: beneficiary not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no beneficiary with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Agreement changed meanwhile'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: an agreement of the beneficiary changed while the action ran. Nothing was written. Resend under 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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when 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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body or id'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: beneficiary is already disabled
                    code: PBP-0802
                    details:
                      currentState: DISABLED
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: no active connection to the PCR or no default agreement template
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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.

            - `PBP-0006`: the body or `beneficiary_id` does not match the schema, or `reason` is shorter than 10 characters once trimmed.
            - `PBP-0802`: the beneficiary is already `REJECTED` or `DISABLED`. The state is in `details.currentState`. It also answers, without `details`, when the beneficiary belongs to a PCR connection that is no longer the active one. Read the beneficiary again: the action may already be done.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Configure them first.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the license.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.

            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. The earlier request may have taken effect. 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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Disable a holder
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/disable-a-holder
  /v1/collections/beneficiaries/{beneficiary_id}/reject:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Rejects an enablement held by a market alert (`HELD_BY_ALERT`) with the operator's `reason`. The rejection is final.

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

        **How it works**

        - The beneficiary goes to `REJECTED`.
        - Agreements never registered at Núclea end as `REGISTRATION_REJECTED`. Their accounts are free for a new enablement.
        - An agreement that Núclea accepted goes to `BLOCKED`.
        - Titles waiting for the beneficiary fail.
        - Nothing is sent to the PCR. `outcome` is `APPLIED`.
        - The rejection is recorded in the collections audit trail with its `reason` and the identity that made it.
      operationId: rejectEnablement
      parameters:
        - description: Identifier of the original beneficiary.
          in: path
          name: beneficiary_id
          required: true
          schema:
            description: Identifier of the original beneficiary.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The rejection is applied. `outcome` is `APPLIED`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Beneficiary not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: beneficiary not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no beneficiary with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Agreement changed meanwhile'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: an agreement of the beneficiary changed while the action ran. Nothing was written. Resend under 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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when 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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body or id'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: enablement is not held by an alert
                    code: PBP-0802
                    details:
                      currentState: SUBMITTED
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: no active connection to the PCR or no default agreement template
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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.

            - `PBP-0006`: the body or `beneficiary_id` does not match the schema, or `reason` is shorter than 10 characters once trimmed.
            - `PBP-0802`: the enablement is not `HELD_BY_ALERT`. The state is in `details.currentState`. It also answers, without `details`, when the beneficiary belongs to a PCR connection that is no longer the active one. Read the beneficiary again: the action may already be done.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Configure them first.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the license.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.

            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. The earlier request may have taken effect. 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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Reject an enablement held by a market alert
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/reject-an-enablement-held-by-a-market-alert
  /v1/collections/connection:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns the tenant's connection to its institution's PCR.

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

        **How it works**

        - The answer has the address, the ISPB and the bank code, the state of the institution's PCR license and of the notice subscription, and `version`.
        - Send `version` back when you replace the connection.
        - The connection holds no PCR credential. No secret is ever returned.
      operationId: getPcrConnection
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrConnection'
          description: OK. The connection.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No connection yet'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no connection to the PCR yet. Create it with `PUT /v1/collections/connection`.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Get the connection to the PCR
      tags:
        - Collections Settings
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-the-connection-to-the-pcr
    put:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Creates or replaces the tenant's connection to its institution's PCR: the PCR address (`baseUrl`), the ISPB and the bank code (barcode positions 1 to 3).

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

        **How it works**

        - No credential or secret travels through this API. The platform provisions the service's PCR credential outside it.
        - `baseUrl` must match a PCR destination the platform allows the tenant, by scheme, host and port. Any other is refused with `PBP-0818`.
        - Bank code 000 is refused with `PBP-0006`. Bank code 988, an institution without its own number code, is refused with `PBP-0801`.
        - The bank code is part of every barcode the connection composes. Once a title of the connection has a composed barcode, even pending submission, a `bankCode` change is refused with `PBP-0802`. A title withdrawn before it was sent does not count.
        - The tenant has one connection. Omit `version` only to create it. To replace it, send the `version` you last read. Any other is refused with `PBP-0803`, and nothing is written.
        - Every change is recorded in the collections audit trail with its `reason` and the identity that made it.
      operationId: putPcrConnection
      parameters:
        - 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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PutPcrConnectionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrConnection'
          description: OK. The connection as stored.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Version is not current'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: the connection changed since it was read: `version` is not the current one, was omitted while the connection exists, or was sent before it exists. Nothing was written. Read the connection again and send the change with the current `version`.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Value breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: invalid bank code
                    code: PBP-0006
                PBP-0801:
                  summary: 'PBP-0801: Bank code 988 not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: institution without a number code is not supported
                    code: PBP-0801
                PBP-0818:
                  summary: 'PBP-0818: PCR address not allowed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0818
                    title: PCR Destination Not Allowed
                    status: 422
                    detail: PCR Destination Not Allowed
                    code: PBP-0818
                PBP-0802:
                  summary: 'PBP-0802: Bank code locked'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: bankCode cannot change after the first title of the connection got a composed barcode
                    code: PBP-0802
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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. Refused, and nothing was written.

            - `PBP-0006`: the body does not match the schema, or a value breaks a rule, such as bank code 000 or a reason shorter than 10 characters once trimmed.
            - `PBP-0801`: bank code 988, an institution without its own number code.
            - `PBP-0818`: `baseUrl` is outside the PCR destinations the platform allows the tenant. Ask the platform to add the PCR address and send again.
            - `PBP-0802`: `bankCode` changed after a title of the connection got a composed barcode.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Set the connection to the PCR
      tags:
        - Collections Settings
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/set-the-connection-to-the-pcr
  /v1/collections/connection/subscription/deliveries:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the notice deliveries the PCR recorded for the subscription of the tenant's connection, as the PCR reports them.

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

        **How it works**

        - Each delivery shows its state, its attempts and the last answer of the notice intake. The event body is not included.
        - A delivery whose notice collections already stored carries its `noticeId`. It needs no redelivery.
        - Use `state=FAILED` to find the notices the PCR gave up delivering. Ask for them again with `POST /v1/collections/connection/subscription/deliveries/{delivery_id}/redeliver`.
        - The list is read from the PCR on every request. Nothing is stored.
        - A page holds up to `limit` deliveries, in the PCR's order. `nextCursor` fetches the next page and is null on the last page.
        - `prevCursor` is always null. To go back, request the first page again.
        - A cursor works only for the query that returned it: same `state`, same tenant. Any other cursor is refused with `PBP-0001`. `limit` may change from one page to the next.
      operationId: listPcrWebhookDeliveries
      parameters:
        - description: Only the deliveries in this state at the PCR. FAILED finds the notices the PCR gave up delivering.
          explode: false
          in: query
          name: state
          schema:
            description: Only the deliveries in this state at the PCR. FAILED finds the notices the PCR gave up delivering.
            enum:
              - PENDING
              - DELIVERED
              - RETRYING
              - FAILED
            type: string
        - description: Opaque cursor returned in nextCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor. Left out, the first page.
            maxLength: 1100
            type: string
        - description: Most deliveries per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most deliveries per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrWebhookDeliveryList'
          description: OK. One page of deliveries.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `cursor` is not one this query returned: altered, from another tenant, or from another `state`. Request the first page again without `cursor`.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No PCR connection'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no connection to the PCR.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the connection has no notice subscription at the PCR
                    code: PBP-0802
                    details:
                      currentState: CREATE
                PBP-0815:
                  summary: 'PBP-0815: PCR refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0815
                    title: PCR Subscription Refused
                    status: 422
                    detail: PCR Subscription Refused
                    code: PBP-0815
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema.
            - `PBP-0802`: the connection has no notice subscription at the PCR yet. `details.currentState` has the subscription's `syncState` (`CREATE` while its creation is pending). Create it with `POST /v1/collections/connection/subscription/sync`.
            - `PBP-0815`: the PCR refused the list, including for the service's credential or its role, or because the subscription no longer exists at the PCR. `details.pcrCode` has the PCR's code when it gave one. Run `POST /v1/collections/connection/subscription/sync` again.
            - `PBP-0830`: collections is not enabled for the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0816:
                  summary: 'PBP-0816: PCR did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0816
                    title: PCR Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0816
                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. Retry the request. The `detail` is a fixed text.

            - `PBP-0816`: the PCR did not answer. Send the same request again once it is back.
            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: List the PCR's deliveries of notices
      tags:
        - Collections PCR Connection
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-pcrs-deliveries-of-notices
  /v1/collections/connection/subscription/deliveries/{delivery_id}/redeliver:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Asks the PCR to deliver again a notice whose delivery is `FAILED`. Send the operator's `reason`.

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

        **How it works**

        - The PCR redelivers with the same event id. A notice that arrives twice is stored once.
        - The redelivery is scheduled at the PCR. Follow it in `GET /v1/collections/connection/subscription/deliveries`.
        - The answer names the audit entry of the request, with `outcome` `ENQUEUED` and `targetState` `FAILED`, the state the PCR listed when asked.
        - The PCR has no read of one delivery. The service looks for it in the subscription's lists at the PCR: first among the first 2,000 `FAILED` deliveries, then among the first 2,000 of every state.
        - A delivery not found there gets `404`. One that is not `FAILED` gets `422` with its state in `details.currentState`. Neither asks the PCR to redeliver anything.
        - A connection without a notice subscription gets `422`.
        - `reason` has at least 10 characters once trimmed.
        - The PCR receives an idempotency key derived from your `Idempotency-Key`. The same request sent again asks the PCR once.
      operationId: redeliverPcrNotice
      parameters:
        - description: Identifier of the delivery at the PCR, as listPcrWebhookDeliveries lists it.
          in: path
          name: delivery_id
          required: true
          schema:
            description: Identifier of the delivery at the PCR, as listPcrWebhookDeliveries lists it.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a10
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The audit entry of the request, with `outcome` `ENQUEUED`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match 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: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Delivery not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no connection to the PCR, or the PCR has no delivery with this id for the connection's subscription.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait. This answer lasts at most five minutes after the earlier request arrived. After that, the key returns the stored answer, `500` `PBP-0002` when it cannot be replayed, or runs the request when no answer was kept. Do not switch keys: the earlier request can still take effect.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the delivery is not FAILED
                    code: PBP-0802
                    details:
                      currentState: DELIVERED
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0815:
                  summary: 'PBP-0815: PCR refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0815
                    title: PCR Subscription Refused
                    status: 422
                    detail: PCR Subscription Refused
                    code: PBP-0815
                    details:
                      pcrCode: PCR-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body or `delivery_id` does not match the schema, or `reason` has fewer than 10 characters once trimmed.
            - `PBP-0802`: the delivery is not `FAILED`, or the connection has no notice subscription at the PCR yet. Nothing was asked of the PCR. `details.currentState` has the state in the way: the delivery's state at the PCR or, without a subscription, the subscription's `syncState` (`CREATE` while its creation is pending).
            - `PBP-0830`: collections is not enabled for the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0815`: the PCR refused the redelivery, including for the service's credential or its role. `details.pcrCode` has the PCR's code when it gave one. `PCR-0006` on the retry of a `503` means the PCR locked the key for the earlier attempt: send the request again under a new `Idempotency-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. Also returned when the PCR answered the redelivery with a server error that did not lock its idempotency key (`X-Idempotency-Fenced: false`, or a `500` that does not say it locked it). The redelivery may have been scheduled. A retry under the same `Idempotency-Key` gets `500` `PBP-0002` without running. Check the delivery in `GET /v1/collections/connection/subscription/deliveries` and, while it is still `FAILED`, ask under a new `Idempotency-Key`.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0816:
                  summary: 'PBP-0816: PCR did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0816
                    title: PCR Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0816
                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. Send the same request again, under the same `Idempotency-Key`, once the dependency is back. The `detail` is a fixed text.

            - `PBP-0816`: the PCR did not answer during the lookup or the redelivery, answered the redelivery `503` without `X-Idempotency-Fenced`, or answered a server error after locking its key. The retry looks the delivery up again. One no longer `FAILED` gets `422` `PBP-0802` without asking the PCR. One still `FAILED` is asked under the same PCR key, so the PCR does not redeliver twice while it keeps that key. A key the PCR locked gets `422` `PBP-0815` with `PCR-0006`.
            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Redeliver a failed PCR notice
      tags:
        - Collections PCR Connection
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/redeliver-a-failed-pcr-notice
  /v1/collections/connection/subscription/secret-rotation:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Changes the secret the PCR signs the connection's notices with. A new secret is a new connection: `connectionToken` and `noticeEndpointUrl` change too.

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

        **How it works**

        - The rotation runs in five steps. (1) A new token and a PCR idempotency key are recorded as a pending rotation (`pendingOperation` `ROTATE`). (2) The PCR rotates the secret under that key and signs with the new one from then on. (3) The new token is recorded with the new secret as the current connection. The previous connection keeps authenticating notices until `previousConnectionValidUntil`. (4) The subscription's address at the PCR moves to the new token's. (5) The new token is promoted.
        - The answer is the subscription as stored afterwards. The secret is never returned or logged.
        - From step 3 on, a notice the PCR delivers to the previous token, signed with the new secret, is accepted. A notice refused before that, or after the window, comes back through the PCR's retries or `POST /v1/collections/connection/subscription/deliveries/{delivery_id}/redeliver`. A notice delivered twice is stored once.
        - Run `POST /v1/collections/connection/subscription/sync` first when the connection has no subscription, has a creation pending, or its address at the PCR is not the current token's (as a failure at step 4 leaves it). Otherwise the rotation is refused with `PBP-0802`. This keeps another failure at step 4 from leaving the PCR signing with a secret its address does not accept.
        - Exception: a rotation pending for more than 24 hours is replaced by the new one, whatever the address. Step 4 then moves the address.
        - Failures are recorded and answered as in `POST /v1/collections/connection/subscription/sync`.
        - Before step 3, a failed rotation stays pending. The same request under the same `Idempotency-Key`, or `POST /v1/collections/connection/subscription/sync`, finishes it with the same secret within 24 hours of `pendingSince`. A rotation pending longer is replaced by a new one.
        - A failure at step 4 returns `200` with the subscription as recorded: the new token current, `syncState` `SYNC_FAILED` with the problem in `lastSyncError`, and the previous address still at the PCR. `POST /v1/collections/connection/subscription/sync` moves it. The `Idempotency-Key` keeps that answer.
        - If the PCR no longer has the subscription, the rotation ends and the subscription is created again, with a new token and a new secret. If that creation fails after step 3, the new token stays current, the failure is answered as in `POST /v1/collections/connection/subscription/sync`, and no audit entry records the rotation. `POST /v1/collections/connection/subscription/sync` finishes the creation.
        - Every other rotation that reaches step 3 is recorded in the collections audit trail, with its `reason` and the identity that asked.
      operationId: rotatePcrNoticeSecret
      parameters:
        - 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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrNoticeSubscription'
          description: OK. The subscription as stored afterwards. After a failure at step 4, `syncState` is `SYNC_FAILED`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match 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: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No PCR connection'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no connection to the PCR. Create it with `PUT /v1/collections/connection`.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Connection changed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0803`: the connection changed while the request ran: a change of the connection, or another request about its subscription. Read the connection and send the request again. A creation or rotation left pending finishes with the same secret.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait. This answer lasts at most five minutes after the earlier request arrived. After that, the key returns the stored answer, `500` `PBP-0002` when it cannot be replayed, or runs the request when no answer was kept. Do not switch keys: the earlier request can still take effect.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the subscription's state does not allow the rotation
                    code: PBP-0802
                    details:
                      currentState: ROTATE
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0800:
                  summary: 'PBP-0800: No notice address'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: Collections Not Configured
                    code: PBP-0800
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0815:
                  summary: 'PBP-0815: PCR refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0815
                    title: PCR Subscription Refused
                    status: 422
                    detail: PCR Subscription Refused
                    code: PBP-0815
                    details:
                      pcrCode: PCR-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0802`: the subscription does not allow a rotation yet. Either the connection has no notice subscription, or its creation is pending, or its address at the PCR is not the current token's (as after a rotation whose address did not move). Run `POST /v1/collections/connection/subscription/sync` first. `details.currentState` has the state in the way: the `pendingOperation` (`CREATE` or `ROTATE`) while a change is pending, the `syncState` otherwise.
            - `PBP-0006`: the body does not match the schema, or `reason` has fewer than 10 characters once trimmed.
            - `PBP-0800`: the deployment has no public address configured for the notices.
            - `PBP-0830`: collections is not enabled for the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0815`: the PCR refused the rotation, including for the service's credential or its role. `details.pcrCode` has the PCR's code when it gave one. The refusal is recorded on the subscription. After `PCR-0006` to a pending rotation (a key the PCR no longer honours), a new rotation replaces it in the same request. If the PCR refuses that key too, the rotation stays pending for the next request.

            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.

            - `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-0816:
                  summary: 'PBP-0816: PCR did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0816
                    title: PCR Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0816
                PBP-0817:
                  summary: 'PBP-0817: Notice connection not recorded'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0817
                    title: Webhook Connection Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0817
                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. The failure is recorded on the subscription. Send the same request again under the same `Idempotency-Key`: within 24 hours of `pendingSince`, a pending creation or rotation finishes with the same secret. These answers come only before the host records a new connection. After that, a failure to move the address returns `200` with `syncState` `SYNC_FAILED`. One exception: if the PCR no longer has the subscription when a rotation moves its address, the new connection stays current and the subscription is created again. A failure of that creation is returned here. `POST /v1/collections/connection/subscription/sync` finishes the creation, and rotations are refused (`422` `PBP-0802`) until it does. The `detail` is a fixed text.

            - `PBP-0816`: the PCR did not answer.
            - `PBP-0817`: the host's record of notice connections did not record the new connection. Notices are received only by a multi-tenant deployment with collections enabled. Elsewhere the host records no notice connection: a synchronization gets this code, and a connection never synchronized has no subscription to rotate (`422` `PBP-0802`).
            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Rotate the PCR notice signing secret
      tags:
        - Collections PCR Connection
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/rotate-the-pcr-notice-signing-secret
  /v1/collections/connection/subscription/sync:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Makes the tenant's connection have one notice subscription at the PCR. It delivers to `noticeEndpointUrl`, the notice address of the current token, with the event types collections consumes and without personal data (`includePii` false).

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

        **How it works**

        - The answer is the subscription as stored afterwards. The signing secret is never returned or logged.
        - Without a subscription, or with one the PCR no longer has, the subscription is created. The PCR issues a new secret, recorded with a new connection token, so `connectionToken` and `noticeEndpointUrl` change as in a rotation.
        - A subscription that differs from what is expected (address, event types, personal data or state) is changed at the PCR. Examples: one paused at the PCR, or one left at the previous address by an interrupted rotation.
        - A subscription held in another state goes back to `ACTIVE`. It is recorded `DIVERGENT` if the PCR still holds it otherwise. One that matches is recorded `SYNCED`.
        - This endpoint never changes the secret of an existing subscription. Use `POST /v1/collections/connection/subscription/secret-rotation` for that.
        - A pending creation (`pendingOperation`) is finished by this request. A pending rotation is finished by this request or by repeating the rotation. Each keeps its own token and PCR idempotency key, so the PCR returns the secret it already issued, within 24 hours of `pendingSince`.
        - A creation pending for longer starts over. A rotation pending for longer is refused with `PBP-0802`. Only a new `POST /v1/collections/connection/subscription/secret-rotation` finishes it, as it finishes a rotation whose key the PCR refused (`PCR-0006`).
        - A failure of the PCR, or of the host's record of notice connections, is recorded on the subscription (`syncState` `SYNC_FAILED`, problem in `lastSyncError`). It is answered as that problem: `422` `PBP-0815`, `503` `PBP-0816` or `503` `PBP-0817`.
        - A rotation this request finishes, whose new connection the host recorded, returns `200` even when its address did not move, with `SYNC_FAILED` as recorded.
        - Every synchronization that succeeds, or that finishes a rotation, is recorded in the collections audit trail, with its `reason` and the identity that asked.
      operationId: syncPcrSubscription
      parameters:
        - 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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrNoticeSubscription'
          description: OK. The subscription as stored afterwards.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match 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: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No PCR connection'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no connection to the PCR. Create it with `PUT /v1/collections/connection`.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Connection changed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
          description: |-
            Conflict.

            - `PBP-0803`: the connection changed while the request ran: a change of the connection, or another request about its subscription. Read the connection and send the request again. A creation or rotation left pending finishes with the same secret.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait. This answer lasts at most five minutes after the earlier request arrived. After that, the key returns the stored answer, `500` `PBP-0002` when it cannot be replayed, or runs the request when no answer was kept. Do not switch keys: the earlier request can still take effect.

            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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0802:
                  summary: 'PBP-0802: Action not allowed in state'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: a rotation of the secret pending for 24 hours or more
                    code: PBP-0802
                    details:
                      currentState: ROTATE
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0800:
                  summary: 'PBP-0800: No notice address'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: Collections Not Configured
                    code: PBP-0800
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0815:
                  summary: 'PBP-0815: PCR refused'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0815
                    title: PCR Subscription Refused
                    status: 422
                    detail: PCR Subscription Refused
                    code: PBP-0815
                    details:
                      pcrCode: PCR-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0802`: the subscription's state does not allow it, such as a secret rotation pending for 24 hours or more, which only `POST /v1/collections/connection/subscription/secret-rotation` finishes. `details.currentState` has the state in the way: the `pendingOperation` (`CREATE` or `ROTATE`) while a change is pending, the `syncState` otherwise.
            - `PBP-0006`: the body does not match the schema, or `reason` has fewer than 10 characters once trimmed.
            - `PBP-0800`: the deployment has no public address configured for the notices.
            - `PBP-0830`: collections is not enabled for the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0815`: the PCR refused the subscription, including for the service's credential or its role. `details.pcrCode` has the PCR's code when it gave one. The refusal is recorded on the subscription. Check the `webhooks` scopes of the service's credential at the PCR, and send the request again. After `PCR-0006` to a pending rotation (a key the PCR no longer honours), the rotation stays pending, and only a new secret rotation finishes it.

            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.

            - `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-0816:
                  summary: 'PBP-0816: PCR did not answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0816
                    title: PCR Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0816
                PBP-0817:
                  summary: 'PBP-0817: Notice connection not recorded'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0817
                    title: Webhook Connection Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0817
                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. The failure is recorded on the subscription. Send the same request again under the same `Idempotency-Key`: within 24 hours of `pendingSince`, a pending creation or rotation finishes with the same secret. These answers come only before the host records a new connection. After that, a failure to move the address returns `200` with `syncState` `SYNC_FAILED`. One exception: if the PCR no longer has the subscription when a rotation moves its address, the new connection stays current and the subscription is created again. A failure of that creation is returned here. `POST /v1/collections/connection/subscription/sync` finishes the creation, and rotations are refused (`422` `PBP-0802`) until it does. The `detail` is a fixed text.

            - `PBP-0816`: the PCR did not answer.
            - `PBP-0817`: the host's record of notice connections did not record the new connection. Notices are received only by a multi-tenant deployment with collections enabled. Elsewhere the host records no notice connection: a synchronization gets this code, and a connection never synchronized has no subscription to rotate (`422` `PBP-0802`).
            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Sync the PCR notice subscription
      tags:
        - Collections PCR Connection
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/sync-the-pcr-notice-subscription
  /v1/collections/credit-entries:
    get:
      description: |-
        Lists the tenant's credit entries: the money each write-off's credit moves in the ledger. There is one entry per write-off and phase. Each entry shows its state with the ledger and, when it is not posted, why, as a closed code.

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

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

        **How it works**

        - Entries come oldest first, by `createdAt` and then by `id`.
        - A page holds up to `limit` entries. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - Send a cursor only with the query that returned it: same filters, same tenant. Any other cursor gets `400`. `limit` can change between pages.
        - `from` and `to` bound `createdAt`, inclusive. A date (YYYY-MM-DD) is a whole UTC day. A date-time with offset is an exact instant. Percent-encode a positive offset (`%2B`).
        - `organizationId` only filters. The permission covers all of the tenant's entries.
      operationId: listCreditEntries
      parameters:
        - description: 'Only the entries of titles issued from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s entries.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the entries of titles issued from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s entries.'
            format: uuid
            type: string
        - description: Only the entries of the write-offs of this collections title.
          explode: false
          in: query
          name: titleId
          schema:
            description: Only the entries of the write-offs of this collections title.
            format: uuid
            type: string
        - description: Only the entries of this write-off.
          explode: false
          in: query
          name: writeOffId
          schema:
            description: Only the entries of this write-off.
            format: uuid
            type: string
        - description: Only the entries of this phase.
          explode: false
          in: query
          name: phase
          schema:
            description: Only the entries of this phase.
            enum:
              - RELEASE
              - CHARGEBACK
            type: string
        - description: Only the entries in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the entries in this state.
            enum:
              - PENDING_CALL
              - POSTED
              - ABANDONED
            type: string
        - description: Lower bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Lower bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Upper bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Upper bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most credit entries per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most credit entries per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditEntryList'
          description: OK. A page of credit entries.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid cursor or date'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: invalid cursor
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `from` or `to` matches the pattern but is not a real instant (for example 2026-02-30), or `cursor` was not returned by this query. Request the first page again without `cursor`.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, or `from` is after `to`.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: List credit entries
      tags:
        - Collections Credit Entries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-credit-entries
  /v1/collections/credit-entries/{credit_entry_id}:
    get:
      description: |-
        Returns one of the tenant's credit entries, with its state with the ledger and, when it is not posted, why, as a closed code.

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

        <Warning>**Under development.** This endpoint can change before it is released.</Warning>
      operationId: getCreditEntry
      parameters:
        - description: Identifier of the credit entry.
          in: path
          name: credit_entry_id
          required: true
          schema:
            description: Identifier of the credit entry.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a41
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditEntry'
          description: OK. The credit entry.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Credit entry not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: credit entry not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no credit entry with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `credit_entry_id` is not a UUID.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: Get a credit entry
      tags:
        - Collections Credit Entries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-credit-entry
  /v1/collections/credit-entries/{credit_entry_id}/reprocess:
    post:
      operationId: reprocessCreditEntry
      summary: Present a stuck entry to the ledger again
      description: |-
        Presents again to the ledger a `PENDING_CALL` entry that collections could not post on its own. Use it after the operator solves a ledger refusal, such as balance or a blocked account (queue `STUCK_CREDIT_ENTRY`).

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

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

        **How it works**

        - It always uses the entry's original key, never a new one.
        - The key alone is not enough. The ledger keeps a key's idempotency only for a window after the first presentation. After it, the same key would post again.
        - `LEDGER_REFUSED` or `INSUFFICIENT_FUNDS`: the ledger refused and nothing was posted. The action opens a new presentation.
        - `LEDGER_NO_RESPONSE` (no answer, outside the idempotency window; collections no longer presents it on its own): the action queries the ledger by the key. If the transaction exists, the entry moves to `POSTED` with its id, without posting.
        - If the query finds nothing, the action is refused with `PBP-0802` and the item stays in the queue. A new presentation opens only when the host proves the earlier one had no effect.
        - A chargeback refused after the release (write-off in `CHARGEBACK_PENDING`): the new presentation takes the write-off to `CHARGED_BACK`. Only then does the client receive the charged-back notice.

        **Planned changes**

        - A write-off's credit will have only two entries, `RELEASE` and `CHARGEBACK`.
        - The ledger's presentation window for a key becomes a per-tenant setting, 167 hours by default, instead of 300 seconds.
        - `lastError` becomes a closed code, never the ledger's text.
      tags:
        - Collections Credit Entries
      parameters:
        - $ref: '#/components/parameters/CreditEntryIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` tells whether the effect is applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` `operate` permission.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no credit entry with this id. A resource of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Credit entry not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: credit entry not found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the target right now. Retry later under the same `Idempotency-Key`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Target claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the target is being processed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing or short `reason`.
            - `PBP-0802`: the entry is not `PENDING_CALL` (state in `details.currentState`; read it again, the action may already be done), or the ledger query found no transaction for an entry with no answer. In that case the item stays in the queue: an empty query does not prove that nothing was posted.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Ledger query found nothing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: transaction not found in the ledger
                    code: PBP-0802
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          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. The earlier request may have taken effect. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/present-a-stuck-entry-to-the-ledger-again
  /v1/collections/enablement-batches:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Enables up to 5,000 accounts for collections, in the background. The accounts belong to the organization in `X-Organization-Id`.

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

        **How it works**

        - Each item names the account and its ledger. It can carry the account's own agreement list (1 to 8 agreements) instead of the tenant's default agreement template.
        - The whole batch is checked before anything is written. An account named twice refuses the batch. The first item the rules refuse also refuses the batch, and `detail` names it at the end.
        - Split larger lists into several batches.
        - The `202` returns the batch as `PROCESSING`, with every item `pending`. Items are then processed one by one, each under the rules of a single enablement, with its own outcome.
        - Follow the batch with `getEnablementBatch` and each item with `listEnablementBatchItems`. No notice is sent for the outcome.
        - The creation is recorded in the collections audit trail with its `reason` and the identity that made it.
        - The batch keeps its `Idempotency-Key` until it is purged (90 days after it completes, by default). After the 48 hours the answer is stored, the same key and body in the same organization still return `202` with the same batch, and another body is still refused with `PBP-0013`.
        - Within 48 hours, the same key under another organization is refused with `PBP-0013`. After that, it creates a separate batch for that organization.
      operationId: createEnablementBatch
      parameters:
        - description: 'Midaz organization of the accounts the body names. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization of the accounts the body names. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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. The same key and body under another organization is another request. The batch keeps the key for as long as it is kept (until the technical purge, 90 days after it completes by default): past the 48 hours the answer is stored, the same key and body are still answered 202 with the batch they created, and another body is still refused with 422 PBP-0013.'
          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. The same key and body under another organization is another request. The batch keeps the key for as long as it is kept (until the technical purge, 90 days after it completes by default): past the 48 hours the answer is stored, the same key and body are still answered 202 with the batch they created, and another body is still refused with 422 PBP-0013.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnablementBatchRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnablementBatch'
          description: Accepted. The batch is `PROCESSING` and every item is `pending`. Follow it with `getEnablementBatch` and `listEnablementBatchItems`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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 UUID
                    code: PBP-0025
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Idempotency Key Required
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a canonical UUID.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when no answer was kept.
        '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. Split the accounts into smaller batches.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Item breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: 'nosso número range start is above its end: items[3].agreements[0]'
                    code: PBP-0006
                PBP-0813:
                  summary: 'PBP-0813: Account named twice'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0813
                    title: Batch Invalid
                    status: 422
                    detail: Batch Invalid
                    code: PBP-0813
                PBP-0801:
                  summary: 'PBP-0801: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: the agreement's product type is not issued by collections
                    code: PBP-0801
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: no active connection to the PCR or no default agreement template
                    code: PBP-0800
                PBP-0811:
                  summary: 'PBP-0811: PCR license invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0811
                    title: PCR License Invalid
                    status: 422
                    detail: PCR License Invalid
                    code: PBP-0811
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with another body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body breaks the schema or a rule. Examples: no item, more than 5,000 items, an own agreement list empty or above 8, the nil UUID as an id, a nosso número range whose start is above its end, `AT_SETTLEMENT` without `chargebackRiskAcknowledged: true`, a `reason` shorter than 10 characters once trimmed. An item refusal names the item at the end of `detail`, as `items[i]` or `items[i].agreements[j]`, counted from 0.
            - `PBP-0813`: the batch names an account more than once. Remove the repeated items.
            - `PBP-0801`: an agreement has a species, product type or portfolio that collections does not issue.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Configure them first.
            - `PBP-0811`: the PCR license of the connection is invalid. Regularize the license.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body (for as long as the batch is kept), or under another organization within 48 hours. After 48 hours, the same key under another organization creates a separate batch for that organization. Use a new key for a new batch.

            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. The earlier request may have taken effect. 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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Enable accounts in a batch
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/enable-accounts-in-a-batch
  /v1/collections/enablement-batches/{batch_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one of the tenant's batches, of either kind, with its items counted by outcome. A batch is an enablement of accounts (`createEnablementBatch`) or a bulk adoption of an inventory's divergences.

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

        **How it works**

        - `pending` counts the items still in progress: not processed yet, waiting for Núclea's answer, or held by a market alert.
        - Adoptions waiting for Núclea to accept the registration change (DDA0502) also count as `pending`.
        - Use this read, with `listEnablementBatchItems`, to learn the outcome of an enablement batch. No notice is sent for it.
      operationId: getEnablementBatch
      parameters:
        - description: Identifier of the batch.
          in: path
          name: batch_id
          required: true
          schema:
            description: Identifier of the batch.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a21
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnablementBatch'
          description: OK. The batch and its counts.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Batch not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: batch not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no batch with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `batch_id` is not a UUID.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: Get a batch's progress
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-batchs-progress
  /v1/collections/enablement-batches/{batch_id}/items:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the items of one of the tenant's batches with the outcome of each. An item shows the account it enables or the divergence it adopts, and the beneficiary and agreement it led to.

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

        **How it works**

        - A `FAILED` item carries the error that the single operation it stands for would have returned.
        - Items come in the batch's order, oldest first.
        - A page holds up to `limit` items. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - Send a cursor only with the query that returned it: same filters, same tenant, same batch. Any other cursor gets `400`. `limit` can change between pages.
        - `organizationId` only filters. The permission covers all of the tenant's batches.
      operationId: listEnablementBatchItems
      parameters:
        - description: Identifier of the batch.
          in: path
          name: batch_id
          required: true
          schema:
            description: Identifier of the batch.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a21
            format: uuid
            type: string
        - description: 'Only the items of accounts of this Midaz organization. It only filters: the permission covers all the tenant''s batches.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the items of accounts of this Midaz organization. It only filters: the permission covers all the tenant''s batches.'
            format: uuid
            type: string
        - description: Only the items with this outcome.
          explode: false
          in: query
          name: state
          schema:
            description: Only the items with this outcome.
            enum:
              - PENDING
              - ENABLED
              - ADOPTED
              - HELD_BY_ALERT
              - FAILED
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most items per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnablementBatchItemList'
          description: OK. A page of batch items.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid cursor or date'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: invalid cursor
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `cursor` was not returned by this query: it was altered, or it belongs to another tenant, batch or set of filters. Request the first page again without `cursor`.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Batch not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: batch not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no batch with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `batch_id` or a query parameter does not match the schema.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: List a batch's item outcomes
      tags:
        - Collections Beneficiaries
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-a-batchs-item-outcomes
  /v1/collections/inventory-runs:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the consumptions of the beneficiary inventories the institution's PCR published. Each consumption compares one inventory with the tenant's agreements and opens a divergence for each difference.

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

        **How it works**

        - Collections does not request an inventory. The institution runs it at the PCR.
        - Read the divergences with `GET /v1/collections/agreement-divergences`.
        - Consumptions are ordered most recent first, by `consumedAt` and then by `id`.
        - `lastConsumedAt` is when the most recent completed consumption ended, or null while none has completed. Use it to tell whether reconciliation is late.
        - A page holds up to `limit` consumptions. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor is valid only for the query that returned it. Send it with the same `state`, as the same tenant. `limit` may change from one page to the next.
      operationId: listInventoryRuns
      parameters:
        - description: Only the consumptions in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the consumptions in this state.
            enum:
              - PROCESSING
              - COMPLETED
              - FAILED
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most consumptions per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most consumptions per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InventoryRunList'
          description: OK. One page of consumptions.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Cursor not valid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: cursor is not valid for this query
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `cursor` is not one this query returned: it was altered, or was returned to another tenant or with other filters (`state`). Request the first page again without `cursor`.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Query parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: List beneficiary inventory consumptions
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-beneficiary-inventory-consumptions
  /v1/collections/inventory-runs/{inventory_run_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one consumption of a beneficiary inventory the institution's PCR published.

        <Info>**Providers:** Lerian (PCR).</Info>
      operationId: getInventoryRun
      parameters:
        - description: Identifier of the consumption.
          in: path
          name: inventory_run_id
          required: true
          schema:
            description: Identifier of the consumption.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a11
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InventoryRun'
          description: OK. The consumption.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Consumption not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no inventory consumption with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Id is not a UUID'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: inventory_run_id must be a UUID
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `inventory_run_id` is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Get a beneficiary inventory consumption
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-beneficiary-inventory-consumption
  /v1/collections/inventory-runs/{inventory_run_id}/bulk-adoption:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Second step of the bulk adoption. Creates a `BULK_ADOPTION` batch with one item per adoptable divergence of the inventory, for `productType` or for every type, and answers `202` with the batch.

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

        **How it works**

        - Call `GET /v1/collections/inventory-runs/{inventory_run_id}/bulk-adoption-preview` first. Send its `eligibleCount` as `expectedCount` and its `previewFingerprint`, with the same `productType`.
        - Both values are recomputed over the adoptable group as it is now. A different count, or the same count over other divergences or accounts, is refused with `PBP-0822`.
        - An inventory has one bulk adoption in progress at a time. Another is refused with `PBP-0823`.
        - A `productType` outside 01 and 07 is refused with `PBP-0801`.
        - The batch's divergences move to `RESOLVING`.
        - A batch holds at most 5,000 items. With more adoptable divergences, it takes the 5,000 oldest. The rest wait for the next bulk adoption, after this one ends.
        - Divergences of an ambiguous account or without an account are left out.
        - Items are processed in the background, each by the rule of the single adoption. Follow them with `GET /v1/collections/enablement-batches/{batch_id}` and `GET /v1/collections/enablement-batches/{batch_id}/items`.
        - The action is recorded in the audit trail as `BULK_ADOPT_AGREEMENT_DIVERGENCES`, with the reason.
      operationId: bulkAdoptInventoryRunDivergences
      parameters:
        - description: Identifier of the inventory consumption.
          in: path
          name: inventory_run_id
          required: true
          schema:
            description: Identifier of the inventory consumption.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkAdoptionRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnablementBatch'
          description: Accepted. The batch is created, and its items are processed in the background. Follow it with `GET /v1/collections/enablement-batches/{batch_id}`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Consumption not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no inventory consumption with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0822:
                  summary: 'PBP-0822: Preview no longer holds'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0822
                    title: Bulk Adoption Preview Stale
                    status: 409
                    detail: Bulk Adoption Preview Stale
                    code: PBP-0822
                    details:
                      eligibleCount: 1287
                PBP-0823:
                  summary: 'PBP-0823: Bulk adoption in progress'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0823
                    title: Bulk Adoption In Progress
                    status: 409
                    detail: Bulk Adoption In Progress
                    code: PBP-0823
                    details:
                      batchId: 0196a3c2-8f4e-7b1a-9c2d-3e4f5a6b7c8d
                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-0822`: the preview no longer holds: the adoptable group has another count, or other divergences or accounts. `details.eligibleCount` has the count eligible now. Preview again and confirm under a new `Idempotency-Key`.
            - `PBP-0823`: the inventory has a bulk adoption in progress. `details.batchId` names its batch. Follow it with `GET /v1/collections/enablement-batches/{batch_id}`.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Reason too short'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have 10 to 500 characters of UTF-8 text, without control characters other than tab and line breaks
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Consumption not completed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: Action Not Allowed In State
                    code: PBP-0802
                    details:
                      currentState: PROCESSING
                PBP-0801:
                  summary: 'PBP-0801: Product type not offered'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: product type other than 01 and 07
                    code: PBP-0801
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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. Refused, and no batch was created.

            - `PBP-0006`: the body or `inventory_run_id` does not match the schema, or the reason has fewer than 10 characters once trimmed.
            - `PBP-0802`: the inventory consumption is not `COMPLETED` (`details.currentState` has its state), or a later consumption completed after it. Only the latest `COMPLETED` consumption can be adopted in bulk.
            - `PBP-0801`: `productType` is outside 01 and 07.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Confirm a bulk adoption
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/confirm-a-bulk-adoption
  /v1/collections/inventory-runs/{inventory_run_id}/bulk-adoption-preview:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        First step of the bulk adoption. Shows, with no effect, what the confirmation would take now among the open `MISSING_LOCALLY` divergences of a `COMPLETED` inventory consumption, for `productType` or for every type.

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

        **How it works**

        - Divergences of product types 01 and 07 split into three groups, each counted in `groups`.
        - `ADOPTABLE`: the holder has a single ledger account, and the divergence is adopted on it.
        - `AMBIGUOUS_ACCOUNT`: the holder has several accounts. Adopt each divergence with `POST /v1/collections/agreement-divergences/{divergence_id}/adopt`, naming the account.
        - `NO_LEDGER_ACCOUNT`: the holder has no account.
        - A divergence of another product type, or of none, is in no group and stays in the queue. So is one raised only by an earlier `FAILED` attempt and not raised again by the attempt that completed the consumption.
        - Only the adoptable group enters the bulk adoption.
        - `eligibleCount` is the size of the adoptable group. Send it as `expectedCount` in the confirmation.
        - `previewFingerprint` covers the whole adoptable group. Send it as is in the confirmation. It is the SHA-256, in lower-case hex, of the UTF-8 text `<inventoryRunId>\n<productType or empty>\n` followed by one line `<divergenceId>:<accountId>\n` per adoptable divergence, in increasing `divergenceId` order.
        - `adoptCount` is how many the confirmation takes now: `eligibleCount` up to 5,000, oldest first.
        - `items` is a page of the group in `group` (`ADOPTABLE` when omitted), oldest first by `detectedAt` and then by `divergenceId`, without personal data.
        - `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor is valid only for the same inventory, `productType` and `group`, as the same tenant. `limit` may change from one page to the next.
        - Only the latest `COMPLETED` consumption can be adopted in bulk. Any other is refused with `PBP-0802`.
      operationId: previewBulkAdoption
      parameters:
        - description: Identifier of the inventory consumption.
          in: path
          name: inventory_run_id
          required: true
          schema:
            description: Identifier of the inventory consumption.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
            format: uuid
            type: string
        - description: Only the divergent agreements of this product type at Núclea, two digits, as the beneficiary base carries it. Left out, every type.
          explode: false
          in: query
          name: productType
          schema:
            description: Only the divergent agreements of this product type at Núclea, two digits, as the beneficiary base carries it. Left out, every type.
            examples:
              - '01'
            pattern: ^[0-9]{2}$
            type: string
        - description: Group of the page's items. Left out, ADOPTABLE. The counts always cover the three.
          explode: false
          in: query
          name: group
          schema:
            description: Group of the page's items. Left out, ADOPTABLE. The counts always cover the three.
            enum:
              - ADOPTABLE
              - AMBIGUOUS_ACCOUNT
              - NO_LEDGER_ACCOUNT
            examples:
              - ADOPTABLE
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most divergences per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most divergences per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkAdoptionPreview'
          description: OK. The preview, with the group counts and one page of items.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Cursor not valid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: cursor is not valid for this query
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `cursor` is not one this query returned: it was altered, or was returned to another tenant or with other filters (inventory, `productType` or `group`). Request the first page again without `cursor`.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Consumption not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no inventory consumption with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Consumption not completed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: Action Not Allowed In State
                    code: PBP-0802
                    details:
                      currentState: PROCESSING
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `inventory_run_id` or a query parameter does not match the schema.
            - `PBP-0802`: the inventory consumption is not `COMPLETED` (`details.currentState` has its state), or a later consumption completed after it. Only the latest `COMPLETED` consumption can be adopted in bulk.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Preview a bulk adoption
      tags:
        - Collections Agreements
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/preview-a-bulk-adoption
  /v1/collections/pcr-commands:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the tenant's commands to the PCR: every registration, change and write-off collections sends to the institution's PCR.

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

        **How it works**

        - Each command shows its idempotency key (kept across attempts), how many times it was sent, when the next attempt is due, and the last answer that did not accept it, classified.
        - The body sent to the PCR is never returned.
        - Oldest first, by `createdAt`, then `id`.
        - `organizationId` only filters. The permission covers all the tenant's commands.
        - `from` and `to` take a date (`YYYY-MM-DD`, a whole UTC day) or an RFC 3339 date-time with offset (an exact instant). Encode a positive offset as `%2B`.
        - A page holds up to `limit` commands. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor works only for the query that returned it: same filters, same tenant. Any other cursor is refused with `PBP-0001`. `limit` may change from one page to the next.
      operationId: listPcrCommands
      parameters:
        - description: 'Only the commands related to accounts of this Midaz organization. It only filters: the permission covers all the tenant''s commands.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the commands related to accounts of this Midaz organization. It only filters: the permission covers all the tenant''s commands.'
            format: uuid
            type: string
        - description: Only the commands of this collections title.
          explode: false
          in: query
          name: titleId
          schema:
            description: Only the commands of this collections title.
            format: uuid
            type: string
        - description: Only the commands on this kind of resource.
          explode: false
          in: query
          name: targetType
          schema:
            description: Only the commands on this kind of resource.
            enum:
              - TITLE
              - BENEFICIARY
              - AGREEMENT
              - RECEIVER_PAYMENT
              - AGREEMENT_DIVERGENCE
            type: string
        - description: 'Only the commands on this resource: a title, a beneficiary, an agreement, a boleto payment the institution received as the receiving institution, or a divergence between the PCR''s beneficiary base and the agreements.'
          explode: false
          in: query
          name: targetId
          schema:
            description: 'Only the commands on this resource: a title, a beneficiary, an agreement, a boleto payment the institution received as the receiving institution, or a divergence between the PCR''s beneficiary base and the agreements.'
            format: uuid
            type: string
        - description: Only the commands of this type.
          explode: false
          in: query
          name: type
          schema:
            description: Only the commands of this type.
            enum:
              - REGISTER_TITLE
              - AMEND_TITLE
              - WRITE_OFF_BY_DESTINATARIA
              - REGISTER_BENEFICIARY
              - UPDATE_BENEFICIARY
              - EXCLUDE_BENEFICIARY_RELATIONSHIP
              - RECEIVER_WRITE_OFF
              - CANCEL_RECEIVER_WRITE_OFF
              - QUERY_BENEFICIARY_BASE
            type: string
        - description: Only the commands in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the commands in this state.
            enum:
              - PENDING
              - SENT
              - UNCONFIRMED
              - ACCEPTED
              - REJECTED_FINAL
              - AWAITING_GRADE
              - ABANDONED
            type: string
        - description: Lower bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Lower bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Upper bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Upper bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most commands per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most commands per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrCommandList'
          description: OK. One page of commands.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `from` or `to` matches the pattern but names no real instant, such as 2026-02-30. Or `cursor` is not one this query returned: altered, from another tenant, or from other filters. Request the first page again without `cursor`.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, or `from` is after `to`.
            - `PBP-0830`: collections is not enabled for the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: List the commands to the PCR
      tags:
        - Collections PCR Commands
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-commands-to-the-pcr
  /v1/collections/pcr-commands/{command_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one of the tenant's commands to the PCR. The body sent to the PCR is never returned.

        <Info>**Providers:** Lerian (PCR).</Info>
      operationId: getPcrCommand
      parameters:
        - description: Identifier of the command to the PCR.
          in: path
          name: command_id
          required: true
          schema:
            description: Identifier of the command to the PCR.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a03
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrCommand'
          description: OK. The command.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Command not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no command to the PCR with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `command_id` is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get a command to the PCR
      tags:
        - Collections PCR Commands
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-command-to-the-pcr
  /v1/collections/pcr-commands/{command_id}/close:
    post:
      operationId: closePcrCommand
      summary: Close a stuck command
      description: |-
        Closes a stuck command to the PCR as `ABANDONED`. Send the operator's `reason`.

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

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

        **How it works**

        - Before closing, collections queries the PCR by `externalId`. If the boleto exists there, the command is adopted instead of closed (`outcome` `ENQUEUED`, `targetState` `ACCEPTED`). A registration that happened is never abandoned.
        - For a registration command, the title moves to `FAILED` with the reason. The client receives the failure notice (`BOLETO_FAILED`).
        - A command held for a collections defect (reason `PCR_COLLECTIONS_DEFECT`) closes with class `COLLECTIONS_DEFECT`.
        - A nosso número informed by the client is released. One generated by collections stays held by the title until the correction, which reuses it.
        - A registration command `UNCONFIRMED` (title in `SUBMISSION_FAILED`) is not closed here. Use `POST /v1/collections/titles/{title_id}/settle-submission-failure`, which queries the PCR at once.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      tags:
        - Collections PCR Commands
      parameters:
        - $ref: '#/components/parameters/CommandIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` says whether the effect is already applied or follows in the background, under a stable key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON. Send a JSON body. A body without `reason` fails the schema and gets `422` `PBP-0006`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` permission with action `operate`.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the command does not exist in the tenant. One of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Command not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0803`: a divergent version: the command changed while the request ran.
            - `PBP-0814`: the command is claimed by a worker.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0803:
                  summary: 'PBP-0803: Divergent version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: VERSION_MISMATCH
                    status: 409
                    detail: the target changed while the request ran
                    code: PBP-0803
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the item is claimed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the request does not match the schema, for example `reason` is missing or has fewer than 10 or more than 500 characters.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0802`: the command is a registration command `UNCONFIRMED` (title in `SUBMISSION_FAILED`). Use `POST /v1/collections/titles/{title_id}/settle-submission-failure`.
            - `PBP-0830`: collections is not enabled for the tenant.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request fails the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0802:
                  summary: 'PBP-0802: Command not closable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: a registration command UNCONFIRMED is settled, not closed
                    code: PBP-0802
                    details:
                      currentState: UNCONFIRMED
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/close-a-stuck-command
  /v1/collections/pcr-commands/{command_id}/reprocess:
    post:
      operationId: reprocessPcrCommand
      summary: Reprocess a stuck command
      description: |-
        Hands a stuck command to the PCR back to the resend. Send the operator's `reason`.

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

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

        **How it works**

        - A command can be reprocessed when it got no answer beyond the limit, or was refused for a reason of the institution (`0011`, `0012`).
        - It can also be reprocessed when it was refused for a configuration defect (`0031`, `channelHint` against the installation's policy). Reprocess it only after the configuration is fixed.
        - These commands sit in the queue `STUCK_PCR_COMMAND`.
        - The resend uses the same idempotency key of the command. After the 24 hours the PCR keeps the key, collections first queries by `externalId` and adopts the existing boleto. It never creates two registrations.
        - A command refused for good, for an error of the request, cannot be reprocessed.
        - After a `0014` (key in use) with a nosso número generated by collections, reprocessing is refused. A resend with the same number gives `0014` again, and the pending boleto keeps that number with no way to change it.
        - In that case, close the command with `POST /v1/collections/pcr-commands/{command_id}/close`. The title moves to `FAILED` with class `COLLECTIONS_DEFECT`, and the client receives `BOLETO_FAILED` and issues again. The new number comes with the new issuance. The number that collided stays held.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      tags:
        - Collections PCR Commands
      parameters:
        - $ref: '#/components/parameters/CommandIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` says whether the effect is already applied or follows in the background, under a stable key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON. Send a JSON body. A body without `reason` fails the schema and gets `422` `PBP-0006`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` permission with action `operate`.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the command does not exist in the tenant. One of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Command not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0829`: the command got `0014` (key in use) with a nosso número generated by collections. A resend would get `0014` again. Close it with `POST /v1/collections/pcr-commands/{command_id}/close`.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0803`: a divergent version: the command changed while the request ran.
            - `PBP-0814`: the command is claimed by a worker.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0829:
                  summary: 'PBP-0829: Reprocess would repeat 0014'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0829
                    title: OUR_NUMBER_KEY_IN_USE
                    status: 409
                    detail: the command cannot be reprocessed with the same generated nosso número
                    code: PBP-0829
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0803:
                  summary: 'PBP-0803: Divergent version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: VERSION_MISMATCH
                    status: 409
                    detail: the target changed while the request ran
                    code: PBP-0803
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the item is claimed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the request does not match the schema, for example `reason` is missing or has fewer than 10 or more than 500 characters.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0802`: the command was refused for good, for an error of the request.
            - `PBP-0830`: collections is not enabled for the tenant.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request fails the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0802:
                  summary: 'PBP-0802: Command refused for good'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: a command refused for good cannot be reprocessed
                    code: PBP-0802
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/reprocess-a-stuck-command
  /v1/collections/pcr-notices:
    get:
      description: |-
        Lists the tenant's notices received from the PCR: every event the PCR delivered to collections.

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

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

        **How it works**

        - Each notice is stored once per connection and event. It shows where its processing stands and what it was matched with.
        - The body received is never returned.
        - Oldest first, by `receivedAt`, then `id`.
        - `organizationId` keeps the notices matched with a title of that organization. It only filters: the permission covers all the tenant's notices.
        - `from` and `to` take a date (`YYYY-MM-DD`, a whole UTC day) or an RFC 3339 date-time with offset (an exact instant). Encode a positive offset as `%2B`.
        - A page holds up to `limit` notices. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor works only for the query that returned it: same filters, same tenant. Any other cursor is refused with `PBP-0001`. `limit` may change from one page to the next.
      operationId: listPcrNotices
      parameters:
        - description: 'Only the notices matched with a title of this Midaz organization. It only filters: the permission covers all the tenant''s notices.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the notices matched with a title of this Midaz organization. It only filters: the permission covers all the tenant''s notices.'
            format: uuid
            type: string
        - description: Only the notices in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the notices in this state.
            enum:
              - RECEIVED
              - APPLIED
              - PENDING_ASSOCIATION
              - CONFLICT
              - DISCARDED
            type: string
        - description: Only the notices of this PCR event type name.
          explode: false
          in: query
          name: type
          schema:
            description: Only the notices of this PCR event type name.
            examples:
              - boleto.writeoff_received
            maxLength: 64
            pattern: ^[a-z]+\.[a-z_]+$
            type: string
        - description: Only the notices matched with this collections title.
          explode: false
          in: query
          name: titleId
          schema:
            description: Only the notices matched with this collections title.
            format: uuid
            type: string
        - description: Lower bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Lower bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Upper bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Upper bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most notices per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most notices per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrNoticeList'
          description: OK. One page of notices.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `from` or `to` matches the pattern but names no real instant, such as 2026-02-30. Or `cursor` is not one this query returned: altered, from another tenant, or from other filters. Request the first page again without `cursor`.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, or `from` is after `to`.
            - `PBP-0830`: collections is not enabled for the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: List the notices received from the PCR
      tags:
        - Collections PCR Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-notices-received-from-the-pcr
  /v1/collections/pcr-notices/{notice_id}:
    get:
      description: |-
        Returns one of the tenant's notices received from the PCR. The body received is never returned.

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

        <Warning>**Under development.** This endpoint can change before it is released.</Warning>
      operationId: getPcrNotice
      parameters:
        - description: Identifier of the notice received from the PCR.
          in: path
          name: notice_id
          required: true
          schema:
            description: Identifier of the notice received from the PCR.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a30
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrNotice'
          description: OK. The notice.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Notice not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no notice received from the PCR with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `notice_id` is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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. The request was not processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get a notice received from the PCR
      tags:
        - Collections PCR Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-notice-received-from-the-pcr
  /v1/collections/pcr-notices/{notice_id}/apply:
    post:
      operationId: applyPcrNotice
      summary: Apply a notice in conflict
      description: |-
        Applies a notice in `CONFLICT` (queue `CONFLICTING_NOTICE`). The answer is the notice, already `APPLIED`.

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

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

        **How it works**

        - With reason `LATE_REGISTRATION` (a `boleto.registered` received after `POST /v1/collections/titles/{title_id}/settle-submission-failure`), the notice is applied as a usual `boleto.registered`. The title moves from `FAILED` to `REGISTERED`.
        - This is not the default way out. In the host, `FAILED` is final. The action needs the host to return the boleto from `FAILED` to `CREATED`, with its nosso número still free there.
        - Without that, or with the number already reused in the host, the notice stays in `CONFLICT`. Use `POST /v1/collections/pcr-notices/{notice_id}/write-off` instead.
        - The notice must be in `CONFLICT`.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      tags:
        - Collections PCR Notices
      parameters:
        - $ref: '#/components/parameters/NoticeIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The notice, `APPLIED`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcrNotice'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON. Send a JSON body. A body without `reason` fails the schema and gets `422` `PBP-0006`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` permission with action `operate`.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the notice does not exist in the tenant. One of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Notice not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0828`: the host cannot return the boleto from `FAILED` to `CREATED`, or its nosso número was already reused in the host. The notice stays in `CONFLICT`. Use `POST /v1/collections/pcr-notices/{notice_id}/write-off`.
            - `PBP-0827`: the nosso número already went to a correction.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0803`: a divergent version: the notice changed while the request ran.
            - `PBP-0814`: the notice is claimed by a worker.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0828:
                  summary: 'PBP-0828: Host cannot reopen the boleto'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0828
                    title: HOST_CANNOT_REOPEN_BOLETO
                    status: 409
                    detail: the host cannot return the boleto from FAILED to CREATED
                    code: PBP-0828
                PBP-0827:
                  summary: 'PBP-0827: Number went to a correction'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0827
                    title: OUR_NUMBER_PASSED_TO_CORRECTION
                    status: 409
                    detail: the nosso número already went to a correction
                    code: PBP-0827
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0803:
                  summary: 'PBP-0803: Divergent version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: VERSION_MISMATCH
                    status: 409
                    detail: the target changed while the request ran
                    code: PBP-0803
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the item is claimed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the request does not match the schema, for example `reason` is missing or has fewer than 10 or more than 500 characters.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0802`: the notice is not in `CONFLICT`.
            - `PBP-0830`: collections is not enabled for the tenant.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request fails the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0802:
                  summary: 'PBP-0802: Notice not in conflict'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the notice is not in CONFLICT
                    code: PBP-0802
                    details:
                      currentState: APPLIED
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/apply-a-notice-in-conflict
  /v1/collections/pcr-notices/{notice_id}/associate:
    post:
      operationId: associatePcrNotice
      summary: Associate a pending notice with a title
      description: |-
        Associates a notice in `PENDING_ASSOCIATION` (queue `UNMATCHED_NOTICE`) with a title of the tenant, then hands it to the usual processing.

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

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

        **How it works**

        - Send the `titleId` and the operator's `reason`.
        - The usual processing covers deduplication, registration order by `numSeqAtlzCadTit`, and credit.
        - The title must belong to the same connection.
        - The notice's PCR `boletoId` cannot be linked to another title.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      tags:
        - Collections PCR Notices
      parameters:
        - $ref: '#/components/parameters/NoticeIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AssociateNoticeRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` says whether the effect is already applied or follows in the background, under a stable key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON. Send a JSON body. A body without `reason` fails the schema and gets `422` `PBP-0006`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` permission with action `operate`.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the notice does not exist in the tenant. One of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Notice not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0803`: a divergent version: the notice changed while the request ran.
            - `PBP-0814`: the notice is claimed by a worker.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0803:
                  summary: 'PBP-0803: Divergent version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: VERSION_MISMATCH
                    status: 409
                    detail: the target changed while the request ran
                    code: PBP-0803
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the item is claimed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the request does not match the schema, for example `reason` is missing or has fewer than 10 or more than 500 characters.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0812`: the title is not of the notice's connection, or the notice's PCR `boletoId` is already linked to another title.
            - `PBP-0830`: collections is not enabled for the tenant.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request fails the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0812:
                  summary: 'PBP-0812: boletoId linked elsewhere'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0812
                    title: BOLETO_LINKED_TO_ANOTHER_TITLE
                    status: 422
                    detail: the PCR boletoId of the notice is linked to another title
                    code: PBP-0812
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/associate-a-pending-notice-with-a-title
  /v1/collections/pcr-notices/{notice_id}/discard:
    post:
      operationId: discardPcrNotice
      summary: Discard a pending notice with a reason
      description: |-
        Discards a notice in `PENDING_ASSOCIATION` or `CONFLICT`, with the operator's `reason`. Nothing is applied.

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

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

        **How it works**

        - The notice stays recorded, with state `DISCARDED` and the reason.
        - On `LATE_REGISTRATION`, discarding does not write the boleto off. It stays live and payable at Núclea. To write it off, use `POST /v1/collections/pcr-notices/{notice_id}/write-off`.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      tags:
        - Collections PCR Notices
      parameters:
        - $ref: '#/components/parameters/NoticeIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` says whether the effect is already applied or follows in the background, under a stable key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON. Send a JSON body. A body without `reason` fails the schema and gets `422` `PBP-0006`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` permission with action `operate`.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the notice does not exist in the tenant. One of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Notice not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0803`: a divergent version: the notice changed while the request ran.
            - `PBP-0814`: the notice is claimed by a worker.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0803:
                  summary: 'PBP-0803: Divergent version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: VERSION_MISMATCH
                    status: 409
                    detail: the target changed while the request ran
                    code: PBP-0803
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the item is claimed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the request does not match the schema, for example `reason` is missing or has fewer than 10 or more than 500 characters.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0830`: collections is not enabled for the tenant.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request fails the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/discard-a-pending-notice-with-a-reason
  /v1/collections/pcr-notices/{notice_id}/write-off:
    post:
      operationId: writeOffLateRegistration
      summary: Write off a late registration at Núclea
      description: |-
        Writes off at Núclea the boleto of a late registration. This is the default way out of a `CONFLICT` notice with reason `LATE_REGISTRATION`.

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

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

        **How it works**

        - At this point the title is `FAILED`, the client already received `BOLETO_FAILED`, and the boleto is live and payable at Núclea.
        - The action queues the command `WRITE_OFF_BY_DESTINATARIA`: a write-off requested by the beneficiary (DDA0108, type 5), by the PCR `boletoId` the title keeps.
        - The title stays `FAILED`, with no new notice to the client. The generated nosso número stays held.
        - The notice leaves `CONFLICT` as `DISCARDED`, with `stateReason` `WRITTEN_OFF_AT_NUCLEA`.
        - The confirmation (`boleto.written_off_by_destinataria`) moves the situation at the base to `CANCELLED`.
        - A refusal of the command follows the rules of the write-off by the Destinatária and goes to the queue `STUCK_PCR_COMMAND`.
        - The notice must be in `CONFLICT` with reason `LATE_REGISTRATION`.
        - The action is audited as `WRITE_OFF_LATE_REGISTRATION`.
        - A retry under the same `Idempotency-Key` returns the stored answer.
      tags:
        - Collections PCR Notices
      parameters:
        - $ref: '#/components/parameters/NoticeIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` says whether the effect is already applied or follows in the background, under a stable key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON. Send a JSON body. A body without `reason` fails the schema and gets `422` `PBP-0006`.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    code: PBP-0001
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` permission with action `operate`.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the notice does not exist in the tenant. One of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Notice not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0803`: a divergent version: the notice changed while the request ran.
            - `PBP-0814`: the notice is claimed by a worker.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0007:
                  summary: 'PBP-0007: Same key still running'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0007
                    title: Conflict
                    status: 409
                    detail: a request with this Idempotency-Key is still being processed
                    code: PBP-0007
                PBP-0803:
                  summary: 'PBP-0803: Divergent version'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: VERSION_MISMATCH
                    status: 409
                    detail: the target changed while the request ran
                    code: PBP-0803
                PBP-0814:
                  summary: 'PBP-0814: Claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the item is claimed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the request does not match the schema, for example `reason` is missing or has fewer than 10 or more than 500 characters.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body.
            - `PBP-0802`: the notice is not in `CONFLICT`, or its reason is not `LATE_REGISTRATION`.
            - `PBP-0830`: collections is not enabled for the tenant.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request fails the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: this Idempotency-Key was used for a different request
                    code: PBP-0013
                PBP-0802:
                  summary: 'PBP-0802: Notice not a late registration'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the notice is not a CONFLICT with reason LATE_REGISTRATION
                    code: PBP-0802
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          description: |-
            Internal Server Error.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/write-off-a-late-registration-at-nuclea
  /v1/collections/pooled-account-links:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the tenant's links of accounts to the agreement of a pooled account.

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

        **How it works**

        - Links come oldest first.
        - A page holds up to `limit` links. `total` counts every link the filters select.
        - `organizationId` only filters. The permission covers all of the tenant's links.
      operationId: listPooledAccountLinks
      parameters:
        - description: 'Only the links of accounts of this Midaz organization. It only filters: the permission covers all the tenant''s links.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the links of accounts of this Midaz organization. It only filters: the permission covers all the tenant''s links.'
            format: uuid
            type: string
        - description: Only the links of this Midaz account.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the links of this Midaz account.
            format: uuid
            type: string
        - description: Only the links to this agreement.
          explode: false
          in: query
          name: agreementId
          schema:
            description: Only the links to this agreement.
            format: uuid
            type: string
        - description: Only the links in this state.
          explode: false
          in: query
          name: state
          schema:
            description: Only the links in this state.
            enum:
              - ACTIVE
              - REMOVED
            type: string
        - description: Number of the page, from 1.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Number of the page, from 1.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Most links per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most links per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PooledAccountLinkPage'
          description: OK. A page of links.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: List pooled account links
      tags:
        - Collections Pooled Accounts
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-pooled-account-links
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Links an account to the agreement of a pooled account. The account then issues under that agreement.

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

        **How it works**

        - The pooled account's holder stays the beneficiary. The account's holder is the final beneficiary, derived by the platform.
        - No agreement is created and nothing is registered at Núclea.
        - The agreement must be `ACTIVE` and belong to a pooled account: product type 07 (Terceiro Habilitado), on another account.
        - An account has at most one `ACTIVE` link and no agreement of its own.
      operationId: linkPooledAccount
      parameters:
        - description: 'Midaz organization of the account named in the body. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization of the account named in the body. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LinkPooledAccountRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PooledAccountLink'
          description: Created. The account is linked to the pooled account.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  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: Idempotency-Key header is required and must be a UUID
                    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 UUID
                    code: PBP-0025
                PBP-0026:
                  summary: 'PBP-0026: Ledger id missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0026
                    title: Bad Request
                    status: 400
                    detail: ledgerId is required and must be a UUID
                    code: PBP-0026
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `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`: `ledgerId` is missing, blank or 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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0806:
                  summary: 'PBP-0806: Account already linked'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0806
                    title: Agreement Already Exists
                    status: 409
                    detail: Agreement Already Exists
                    code: PBP-0806
                    details:
                      linkId: 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a77
                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-0806`: the account cannot take the link. It is already linked to a pooled account (`details.linkId`), or it has an agreement of its own (`details.agreementId`). An account issues under its own agreement or under one link, never both.
            - `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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when 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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0805:
                  summary: 'PBP-0805: Agreement not usable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0805
                    title: Agreement Not Usable
                    status: 422
                    detail: Agreement Not Usable
                    code: PBP-0805
                PBP-0808:
                  summary: 'PBP-0808: Account not eligible'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0808
                    title: Account Not Eligible
                    status: 422
                    detail: Account Not Eligible
                    code: PBP-0808
                PBP-0809:
                  summary: 'PBP-0809: Holder data incomplete'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0809
                    title: Holder Data Incomplete
                    status: 422
                    detail: Holder Data Incomplete
                    code: PBP-0809
                PBP-0800:
                  summary: 'PBP-0800: Collections not configured'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0800
                    title: Collections Not Configured
                    status: 422
                    detail: no active connection to the PCR or no default agreement template
                    code: PBP-0800
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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.

            - `PBP-0006`: the body does not match the schema, or `reason` is shorter than 10 characters once trimmed.
            - `PBP-0805`: the agreement cannot be used. It does not exist, is not `ACTIVE`, is not a pooled account's agreement, belongs to the account itself, or is of another organization or ledger than the account. Nothing was written.
            - `PBP-0808`: the account does not exist in the organization and ledger you named, or is closed.
            - `PBP-0809`: the account has no holder.
            - `PBP-0800`: collections is not configured: there is no active connection to the PCR or no default agreement template. Configure them first.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.

            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. The earlier request may have taken effect. 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
                PBP-0810:
                  summary: 'PBP-0810: People registry unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0810
                    title: People Registry Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0810
          description: |-
            Service Unavailable. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
            - `PBP-0810`: the people registry did not answer while the account was read. Nothing was written. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Link an account to a pooled account
      tags:
        - Collections Pooled Accounts
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/link-an-account-to-a-pooled-account
  /v1/collections/pooled-account-links/{link_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one of the tenant's links of an account to a pooled account.

        <Info>**Providers:** Lerian (PCR).</Info>
      operationId: getPooledAccountLink
      parameters:
        - description: Identifier of the pooled account link.
          in: path
          name: link_id
          required: true
          schema:
            description: Identifier of the pooled account link.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a40
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PooledAccountLink'
          description: OK. The link.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Link not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: pooled account link not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no pooled account link with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `link_id` is not a UUID.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: Get a pooled account link
      tags:
        - Collections Pooled Accounts
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-pooled-account-link
  /v1/collections/pooled-account-links/{link_id}/remove:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Removes the link of an account to a pooled account. The account no longer issues under the pooled account's agreement.

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

        **How it works**

        - Nothing changes at Núclea, where nothing was registered.
        - Titles already registered do not change.
        - A removed link does not come back. To issue under a pooled account again, create a new link.
      operationId: removePooledAccountLink
      parameters:
        - description: Identifier of the pooled account link.
          in: path
          name: link_id
          required: true
          schema:
            description: Identifier of the pooled account link.
            examples:
              - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a40
            format: uuid
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
          description: OK. The link is removed.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or not JSON'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Link not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: pooled account link not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no pooled account link with this id.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-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 `PBP-0007` for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, returns 500 `PBP-0002` when that answer cannot be replayed, or runs the request when no answer was kept.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body or id'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Link already removed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: link is already removed
                    code: PBP-0802
                    details:
                      currentState: REMOVED
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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.

            - `PBP-0006`: the body or `link_id` does not match the schema, or `reason` is shorter than 10 characters once trimmed.
            - `PBP-0802`: the link is already `REMOVED`. The state is in `details.currentState`.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.

            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. The earlier request may have taken effect. 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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Remove a pooled account link
      tags:
        - Collections Pooled Accounts
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/remove-a-pooled-account-link
  /v1/collections/queues:
    get:
      description: |-
        Summarizes each of the tenant's operation queues: how many items it holds, when its oldest item entered, and how many items reached the queue's age limit.

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

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

        **How it works**

        - A queue is a read over states collections already keeps, not a list of its own. A case is in its queue while its state keeps it there.
        - Every delivered queue is returned once, empty ones included, in a fixed order.
        - `organizationId` only filters. The permission covers every queue of the tenant. Items without an organization are left out by this filter.
      operationId: listQueues
      parameters:
        - description: 'Only the items of this Midaz organization. It only filters: the permission covers every queue of the tenant, and an item without an organization is left out by this filter.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the items of this Midaz organization. It only filters: the permission covers every queue of the tenant, and an item without an organization is left out by this filter.'
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueueSummaryList'
          description: OK. One summary per queue.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Query parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, such as an `organizationId` that is not a UUID.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: List the operation queues
      tags:
        - Collections Operation Queues
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-operation-queues
  /v1/collections/queues/{queue}/items:
    get:
      description: |-
        Lists the items of one of the tenant's operation queues. Each item is a case that waits for an operator.

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

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

        **How it works**

        - An item has its target, the title and the boleto when the target has a title, and the account, organization and holder when the target has them.
        - It also has the amount, the reason, when it entered the queue and the operations that act on it.
        - A queue is a read over states collections already keeps, not a list of its own. A case stays in its queue, under the same item id, while its state keeps it there.
        - Items are ordered oldest first, by `enteredAt` and then by `targetId`.
        - `enteredFrom` and `enteredTo` take a calendar date, read as a UTC day, or an RFC 3339 date-time with offset. Percent-encode a positive offset (`%2B`).
        - The organization, account and holder filters leave out items without that value. A `reasonCode` of another queue returns an empty page.
        - A page holds up to `limit` items. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - A cursor is valid only for the query that returned it. Send it for the same queue, with the same filters, as the same tenant. `limit` may change from one page to the next.
      operationId: listQueueItems
      parameters:
        - description: Operation queue. A queue that is not one of the delivered queues is refused by the schema.
          in: path
          name: queue
          required: true
          schema:
            description: Operation queue. A queue that is not one of the delivered queues is refused by the schema.
            enum:
              - STR_RELEASE_PENDING
              - NOT_SETTLED_IN_CYCLE
              - STUCK_PCR_COMMAND
              - STUCK_CREDIT_ENTRY
              - UNMATCHED_NOTICE
              - CONFLICTING_NOTICE
              - BENEFICIARY_REJECTED
              - ENABLEMENT_HELD_BY_ALERT
              - AGREEMENT_CLOSURE_EXCEPTION
              - AGREEMENT_DIVERGENCE
            examples:
              - AGREEMENT_DIVERGENCE
            type: string
        - description: 'Only the items of this Midaz organization. It only filters: the permission covers every queue of the tenant, and an item without an organization is left out by this filter.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the items of this Midaz organization. It only filters: the permission covers every queue of the tenant, and an item without an organization is left out by this filter.'
            format: uuid
            type: string
        - description: Only the items of this Midaz account. An item without an account is left out by this filter.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the items of this Midaz account. An item without an account is left out by this filter.
            format: uuid
            type: string
        - description: Only the items of this holder, the person in the platform's people registry. An item without a holder is left out by this filter.
          explode: false
          in: query
          name: holderId
          schema:
            description: Only the items of this holder, the person in the platform's people registry. An item without a holder is left out by this filter.
            format: uuid
            type: string
        - description: Only the items of this reason. A reason of another queue answers an empty page.
          explode: false
          in: query
          name: reasonCode
          schema:
            description: Only the items of this reason. A reason of another queue answers an empty page.
            enum:
              - STR_CREDIT_NOT_CONFIRMED
              - NOT_SETTLED_IN_CYCLE
              - SETTLEMENT_OVERDUE
              - PCR_NO_RESPONSE
              - PCR_INSTITUTION_REFUSAL
              - PCR_COLLECTIONS_DEFECT
              - SUBMISSION_UNCONFIRMED
              - LEDGER_REFUSED
              - INSUFFICIENT_FUNDS
              - LEDGER_NO_RESPONSE
              - NOTICE_NOT_CORRELATED
              - LATE_REGISTRATION
              - BENEFICIARY_REJECTED
              - BENEFICIARY_UNFIT
              - RELATIONSHIP_EXCLUSION_REFUSED
              - MARKET_ALERT_UNFIT
              - MARKET_ALERT_UNDER_REVIEW
              - MARKET_ALERT_FIT
              - AGREEMENT_CLOSURE_REFUSED
              - MISSING_IN_NUCLEA
              - MISSING_LOCALLY
              - ATTRIBUTE_MISMATCH
              - SITUATION_MISMATCH
            type: string
        - description: Lower bound of enteredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: enteredFrom
          schema:
            description: Lower bound of enteredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Upper bound of enteredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: enteredTo
          schema:
            description: Upper bound of enteredAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most items per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueueItemList'
          description: OK. One page of queue items.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid date or cursor'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: cursor is not valid for this query
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `enteredFrom` or `enteredTo` matches the pattern but names no real instant, such as 2026-02-30; or `cursor` is not one this query returned. For a bad cursor, request the first page again without `cursor`.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Parameter invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a parameter does not match the schema, including a `queue` that is not a delivered queue, or `enteredFrom` is after `enteredTo`.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.

            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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: List the items of an operation queue
      tags:
        - Collections Operation Queues
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-items-of-an-operation-queue
  /v1/collections/settings:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns the tenant's collections business settings: the default agreement template, the automatic enablement and the retention periods.

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

        **How it works**

        - Send `version` back when you replace the settings.
        - `ready` tells whether the tenant's PCR connection and agreement template are in place.
      operationId: getCollectionsSettings
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionsSettings'
          description: OK. The settings.
        '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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: No settings yet'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Not Found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no collections settings yet. Create them with `PUT /v1/collections/settings`.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry.
      security:
        - BearerAuth: []
      summary: Get the collections business settings
      tags:
        - Collections Settings
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-the-collections-business-settings
    put:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Creates or replaces the tenant's collections business settings: the default agreement template, the automatic enablement on a holder's first boleto and the retention periods.

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

        **How it works**

        - Each template item sets the product type, portfolio, species, credit delay, release policy, payment deadline and nosso número range of an agreement.
        - Species 31, 32 and 33, product types other than 01 and 07 and portfolios other than 01 are refused with `PBP-0801`.
        - Existing agreements do not change. The template applies to the enablements that follow.
        - A replacement is whole: an optional member left out takes its default, not the value stored before.
        - Omit `version` only to create the settings. To replace them, send the `version` you last read. Any other is refused with `PBP-0803`, and nothing is written.
        - Every change is recorded in the collections audit trail with its `reason` and the identity that made it.
      operationId: putCollectionsSettings
      parameters:
        - 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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PutCollectionsSettingsRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionsSettings'
          description: OK. The settings as stored.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Body missing or invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: the body is missing or is not valid JSON
                    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
          description: |-
            Bad Request.

            - `PBP-0001`: the body is missing or is not valid JSON.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil 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 is required to access this resource.
                    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: You do not have permission to access this resource.
                    code: PBP-0004
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0803:
                  summary: 'PBP-0803: Version is not current'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0803
                    title: Version Mismatch
                    status: 409
                    detail: Version Mismatch
                    code: PBP-0803
                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-0803`: the settings changed since they were read: `version` is not the current one, was omitted while the settings exist, or was sent before they exist. Nothing was written. Read the settings again and send the change with the current `version`.
            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a few seconds. The key answers this code for at most 5 minutes after the earlier request arrived. After that, the same key returns the stored answer, 500 `PBP-0002` if it cannot be replayed, or runs the request if no answer was kept. Do not switch keys: the earlier request can still take effect.

            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: The request payload is too large.
                    code: PBP-0010
          description: |-
            Payload Too Large.

            - `PBP-0010`: the body is larger than the size limit.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Value breaks a rule'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: numbering range start is above its end
                    code: PBP-0006
                PBP-0801:
                  summary: 'PBP-0801: Species not offered'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0801
                    title: Capability Not Supported
                    status: 422
                    detail: species with special rules
                    code: PBP-0801
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
                PBP-0013:
                  summary: 'PBP-0013: Key used with 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. Refused, and nothing was written.

            - `PBP-0006`: the body does not match the schema, or a value breaks a rule. Examples: a nosso número range whose start is above its end, two items of one product type, `AT_SETTLEMENT` without `chargebackRiskAcknowledged: true`, or a reason shorter than 10 characters once trimmed.
            - `PBP-0801`: a species, product type or portfolio collections does not issue.
            - `PBP-0830`: collections is not enabled for the tenant. Retrying does not change the answer. Ask Lerian to add the collections module to the tenant.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Send a new request 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.

            - `PBP-0002`: an unexpected failure, or the stored answer of this key cannot be replayed. Contact support. Do not resend under a new key: the earlier request may have taken effect.
        '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.

            - `PBP-0008`: a dependency the request needs, authentication or the tenant's storage, is temporarily unavailable. The request was not processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Set the collections business settings
      tags:
        - Collections Settings
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/set-the-collections-business-settings
  /v1/collections/titles:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the tenant's collections titles: each boleto that collections issues at the institution's PCR. Each title shows its four state axes: registration, situation at the base, credit and block.

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

        **How it works**

        - The response never carries payer or beneficiary data.
        - The barcode and the digitable line appear only while the title is `REGISTERED`.
        - Titles come oldest first, by `createdAt` and then by `id`.
        - `boletoId` is the host's boleto, also sent to the PCR as `externalId`.
        - A page holds up to `limit` titles. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - Send a cursor only with the query that returned it: same filters, same tenant. Any other cursor gets `400`. `limit` can change between pages.
        - `from` and `to` bound `createdAt`, inclusive. A date (YYYY-MM-DD) is a whole UTC day. A date-time with offset is an exact instant. Percent-encode a positive offset (`%2B`).
        - `organizationId` only filters. The permission covers all of the tenant's titles.
      operationId: listTitles
      parameters:
        - description: 'Only the titles issued from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s titles.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the titles issued from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s titles.'
            format: uuid
            type: string
        - description: Only the titles issued from this Midaz account.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the titles issued from this Midaz account.
            format: uuid
            type: string
        - description: Only the titles issued under this agreement.
          explode: false
          in: query
          name: agreementId
          schema:
            description: Only the titles issued under this agreement.
            format: uuid
            type: string
        - description: Only the title of this boleto of the host, which is also the externalId sent to the PCR.
          explode: false
          in: query
          name: boletoId
          schema:
            description: Only the title of this boleto of the host, which is also the externalId sent to the PCR.
            format: uuid
            type: string
        - description: Only the titles in this registration state.
          explode: false
          in: query
          name: registrationState
          schema:
            description: Only the titles in this registration state.
            enum:
              - AWAITING_BENEFICIARY
              - PENDING_SUBMISSION
              - SUBMITTED
              - SUBMISSION_FAILED
              - REGISTERED
              - FAILED
              - WITHDRAWN
            type: string
        - description: Only the titles in this situation at the base.
          explode: false
          in: query
          name: baseSituation
          schema:
            description: Only the titles in this situation at the base.
            enum:
              - OPEN
              - PAID
              - CANCELLED
              - LAPSED
            type: string
        - description: Only the titles in this credit state.
          explode: false
          in: query
          name: creditState
          schema:
            description: Only the titles in this credit state.
            enum:
              - NONE
              - TO_RELEASE
              - RELEASED
              - REVERSED
              - CHARGEBACK_PENDING
              - CHARGED_BACK
            type: string
        - description: Only the titles in this block state.
          explode: false
          in: query
          name: blockState
          schema:
            description: Only the titles in this block state.
            enum:
              - UNBLOCKED
              - BLOCKED
            type: string
        - description: Lower bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Lower bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Upper bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Upper bound of createdAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most titles per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most titles per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TitleList'
          description: OK. A page of titles.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid cursor or date'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: invalid cursor
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `from` or `to` matches the pattern but is not a real instant (for example 2026-02-30), or `cursor` was not returned by this query. Request the first page again without `cursor`.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, or `from` is after `to`.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: List collections titles
      tags:
        - Collections Titles
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-collections-titles
  /v1/collections/titles/{title_id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one of the tenant's collections titles. It shows the four state axes, the version of the registration at the PCR, and why the registration failed, when it did.

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

        **How it works**

        - The response never carries payer or beneficiary data.
        - The barcode and the digitable line appear only while the title is `REGISTERED`.
      operationId: getTitle
      parameters:
        - description: Identifier of the collections title.
          in: path
          name: title_id
          required: true
          schema:
            description: Identifier of the collections title.
            examples:
              - 7c9e6679-7425-40de-944b-e07fc1f90ae7
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Title'
          description: OK. The title.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Title not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: title not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no title with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `title_id` is not a UUID.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: Get a collections title
      tags:
        - Collections Titles
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-collections-title
  /v1/collections/titles/{title_id}/settle-submission-failure:
    post:
      operationId: settleSubmissionFailure
      summary: Settle a submission failure
      description: |-
        Settles a submission failure that the PCR did not close. The PCR does not move `SUBMISSION_FAILED` to `REJECTED` or `WITHDRAWN`: a late refusal keeps the boleto failed, with the code. It does not report the closing by event or field either. So the action queries the PCR at once.

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

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

        **How it works**

        - If the boleto is `REGISTERED` at the PCR, collections adopts it: `outcome` is `ENQUEUED` and `targetState` is `REGISTERED`, as in `closePcrCommand`.
        - If it is still `SUBMISSION_FAILED` and the failure has reached the minimum age, the title moves to `FAILED`. The minimum age is an operational setting in hours, 24 by default. The title gets class `TRANSIENT` and a null `pcrCode`. Its message says the rail did not answer and the operator closed the failure.
        - The client then receives the failure notice (`BOLETO_FAILED`). The registration command left `UNCONFIRMED` is closed (queue `STUCK_PCR_COMMAND`, reason `SUBMISSION_UNCONFIRMED`).
        - Before the minimum age, or for a title outside `SUBMISSION_FAILED`, the action is refused with `PBP-0826`.
        - The nosso número follows the rule of `closePcrCommand`. A number the client informed is released. A number collections generated stays held by the title until the correction, which reuses it.
        - A `boleto.registered` that arrives after the settling is not applied silently. The notice stays `CONFLICT`, reason `LATE_REGISTRATION`, in queue `CONFLICTING_NOTICE`.
        - The default way out is `writeOffLateRegistration`: a write-off at Núclea, and the title stays `FAILED`. `applyPcrNotice` takes the title to `REGISTERED` only where the host can return a failed boleto to created.
      tags:
        - Collections Titles
      parameters:
        - $ref: '#/components/parameters/TitleIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` tells whether the effect is applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` `operate` permission.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no title with this id. A resource of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Title not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: title not found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the target right now. Retry later under the same `Idempotency-Key`.
            - `PBP-0826`: the title is not in `SUBMISSION_FAILED` (the failure was already closed, or a late `boleto.registered` took it to `REGISTERED`), or the failure is younger than the minimum age. The state is in `details.currentState`. Read the title. Below the minimum age, wait.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Target claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the target is being processed by a worker
                    code: PBP-0814
                PBP-0826:
                  summary: 'PBP-0826: Failure not pending'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0826
                    title: SUBMISSION_FAILURE_NOT_PENDING
                    status: 409
                    detail: the title is not in SUBMISSION_FAILED or the failure is below the minimum age
                    code: PBP-0826
                    details:
                      currentState: REGISTERED
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing or short `reason`.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          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. The earlier request may have taken effect. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/settle-a-submission-failure
  /v1/collections/write-offs:
    get:
      description: |-
        Lists the tenant's write-offs: each write-off of a collections title that the PCR notified. Each one shows its route, its settlement, its credit state and whether its release is held.

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

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

        **How it works**

        - The response never carries payer data.
        - Write-offs come oldest first, by `receivedAt` and then by `id`.
        - A page holds up to `limit` write-offs. `nextCursor` fetches the next page and `prevCursor` the previous one. Each is null when there is no such page.
        - Send a cursor only with the query that returned it: same filters, same tenant. Any other cursor gets `400`. `limit` can change between pages.
        - `from` and `to` bound `receivedAt`, inclusive. A date (YYYY-MM-DD) is a whole UTC day. A date-time with offset is an exact instant. Percent-encode a positive offset (`%2B`).
        - `organizationId` only filters. The permission covers all of the tenant's write-offs.
      operationId: listWriteOffs
      parameters:
        - description: 'Only the write-offs of titles issued from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s write-offs.'
          explode: false
          in: query
          name: organizationId
          schema:
            description: 'Only the write-offs of titles issued from accounts of this Midaz organization. It only filters: the permission covers all the tenant''s write-offs.'
            format: uuid
            type: string
        - description: Only the write-offs of this collections title.
          explode: false
          in: query
          name: titleId
          schema:
            description: Only the write-offs of this collections title.
            format: uuid
            type: string
        - description: Only the write-offs of titles issued from this Midaz account.
          explode: false
          in: query
          name: accountId
          schema:
            description: Only the write-offs of titles issued from this Midaz account.
            format: uuid
            type: string
        - description: Only the write-offs that settle by this route.
          explode: false
          in: query
          name: route
          schema:
            description: Only the write-offs that settle by this route.
            enum:
              - CMP
              - STR
              - INTRABANK
              - PIX
              - NONE
            type: string
        - description: Only the write-offs in this credit state.
          explode: false
          in: query
          name: creditState
          schema:
            description: Only the write-offs in this credit state.
            enum:
              - NONE
              - TO_RELEASE
              - RELEASED
              - REVERSED
              - CHARGEBACK_PENDING
              - CHARGED_BACK
            type: string
        - description: Only the write-offs whose credit release is held (true) or is not (false). Left out, both.
          explode: false
          in: query
          name: held
          schema:
            description: Only the write-offs whose credit release is held (true) or is not (false). Left out, both.
            enum:
              - 'true'
              - 'false'
            type: string
        - description: Lower bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Lower bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-11-01T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Upper bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Upper bound of receivedAt, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-11-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-11-30'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
            type: string
        - description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
          explode: false
          in: query
          name: cursor
          schema:
            description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
            maxLength: 512
            type: string
        - description: Most write-offs per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Most write-offs per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WriteOffList'
          description: OK. A page of write-offs.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Invalid cursor or date'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: invalid cursor
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0001`: `from` or `to` matches the pattern but is not a real instant (for example 2026-02-30), or `cursor` was not returned by this query. Request the first page again without `cursor`.
        '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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a query parameter does not match the schema, or `from` is after `to`.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: List write-offs
      tags:
        - Collections Write-offs
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-write-offs
  /v1/collections/write-offs/{write_off_id}:
    get:
      description: |-
        Returns one of the tenant's write-offs, with its route, settlement, credit state, hold and cancellation deadline.

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

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

        **How it works**

        - The response never carries payer data.
      operationId: getWriteOff
      parameters:
        - description: Identifier of the write-off.
          in: path
          name: write_off_id
          required: true
          schema:
            description: Identifier of the write-off.
            examples:
              - 5b0c1e2d-3f4a-4b5c-8d6e-7f8091a2b3c4
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WriteOff'
          description: OK. The write-off.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Write-off not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: write-off not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no write-off with this id.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: validation failed
                    code: PBP-0006
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `write_off_id` is not a UUID.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            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. Contact support.
        '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. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or the tenant's storage) is unavailable. The request was not processed. Wait and retry.
      security:
        - BearerAuth: []
      summary: Get a write-off
      tags:
        - Collections Write-offs
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-write-off
  /v1/collections/write-offs/{write_off_id}/release:
    post:
      operationId: releaseWriteOff
      summary: Release a write-off's credit manually
      description: |-
        Releases a write-off's amount to release to the available balance (`RELEASE`), when a human decision is needed. Two cases qualify: an STR route without the PCR confirming the credit (queue `STR_RELEASE_PENDING`), and a write-off not settled in the cycle (queue `NOT_SETTLED_IN_CYCLE`).

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

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

        **How it works**

        - The operator attests the settlement in `settlementConfirmation`. The amount is never released before it settled on the route.
        - Not settled in the cycle: collections first runs an automatic check at the PCR on its own. The manual release is accepted only after that check ends unresolved (`lastAutomaticCheck.result` `UNRESOLVED` or `FAILED`). Before that, the action is refused with `PBP-0819`.
        - There is no operation to trigger the automatic check.
        - If the agreement's credit date has not arrived, the release is scheduled for it (`outcome: ENQUEUED`). `WriteOff.scheduledRelease` shows the date and the author. Cancel it before that date with `cancelScheduledRelease`.
        - The entry uses a stable key: title, write-off and `RELEASE`. Repeating the action, under the same or another `Idempotency-Key`, never credits twice. A second run is refused with `PBP-0802`.

        **Planned changes**

        - `RELEASE` becomes the only entry of the credit, from the counterparty to the default balance of the title's account. There is no earlier entry.
        - The release also follows the agreement's `releasePolicy`. Under `AFTER_CANCELLATION_WINDOW`, it waits for the write-off's cancellation deadline.
      tags:
        - Collections Write-offs
      parameters:
        - $ref: '#/components/parameters/WriteOffIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReleaseWriteOffRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` tells whether the effect is applied or follows in the background. A scheduled release returns `ENQUEUED`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` `operate` permission.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no write-off with this id. A resource of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Write-off not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: write-off not found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the target right now. Retry later under the same `Idempotency-Key`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Target claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the target is being processed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing or short `reason`.
            - `PBP-0802`: the write-off is not in a state the release accepts, for example the release already ran. The state is in `details.currentState`. Repeating the action, under any `Idempotency-Key`, never credits twice.
            - `PBP-0819`: the write-off was not settled in the cycle, and the automatic check at the PCR has not ended unresolved yet. Wait for the check (`lastAutomaticCheck` on the queue item).
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Already released'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: write-off already released
                    code: PBP-0802
                    details:
                      currentState: RELEASED
                PBP-0819:
                  summary: 'PBP-0819: Automatic check pending'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0819
                    title: AUTOMATIC_SETTLEMENT_CHECK_PENDING
                    status: 422
                    detail: the automatic settlement check has not ended unresolved
                    code: PBP-0819
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          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. The earlier request may have taken effect. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/release-a-write-offs-credit-manually
  /v1/collections/write-offs/{write_off_id}/reverse:
    post:
      operationId: reverseWriteOff
      summary: Reverse an unsettled write-off's amount to release
      description: |-
        Reverses the amount to release (`REVERSAL`) of a write-off not settled in the cycle, when the decision is not to credit it (queue `NOT_SETTLED_IN_CYCLE`).

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

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

        **How it works**

        - Send a `reason` and `evidence`.
        - It applies only to a write-off in `TO_RELEASE`.
        - It never applies after the release. The chargeback then happens automatically, through the cancellation of the write-off.
        - The entry uses a stable key: title, write-off and `REVERSAL`.

        **Planned changes**

        - There will be no `REVERSAL` entry. The amount to release becomes a state of the write-off, not a ledger balance. The reversal moves the write-off from `TO_RELEASE` to `REVERSED`, and nothing is posted to the ledger.
      tags:
        - Collections Write-offs
      parameters:
        - $ref: '#/components/parameters/WriteOffIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvidencedActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` tells whether the effect is applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` `operate` permission.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no write-off with this id. A resource of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Write-off not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: write-off not found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the target right now. Retry later under the same `Idempotency-Key`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Target claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the target is being processed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing or short `reason`. The body needs `reason` and `evidence`.
            - `PBP-0802`: the write-off is not `TO_RELEASE` (for example, already released or reversed). The state is in `details.currentState`. Read the write-off: the action may already be done.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: Write-off not TO_RELEASE'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the write-off is not TO_RELEASE
                    code: PBP-0802
                    details:
                      currentState: RELEASED
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          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. The earlier request may have taken effect. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/reverse-an-unsettled-write-offs-amount-to-release
  /v1/collections/write-offs/{write_off_id}/scheduled-release/cancel:
    post:
      operationId: cancelScheduledRelease
      summary: Cancel a scheduled manual release
      description: |-
        Cancels a release that `releaseWriteOff` scheduled, while the agreement's credit date has not arrived.

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

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

        **How it works**

        - The amount stays to release, and the write-off goes back to the queue it came from.
        - Nothing is posted to the ledger.
        - Without a scheduled release, the action is refused with `PBP-0802`.
        - Once the date arrives and the `RELEASE` entry is recorded, the action is refused with `PBP-0820`. From then on, only the chargeback through the cancellation of the write-off reverses it.
      tags:
        - Collections Write-offs
      parameters:
        - $ref: '#/components/parameters/WriteOffIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` tells whether the effect is applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` `operate` permission.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no write-off with this id. A resource of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Write-off not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: write-off not found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the target right now. Retry later under the same `Idempotency-Key`.
            - `PBP-0820`: the release already ran or is running: the date arrived and the `RELEASE` entry is recorded. Nothing is left to cancel. Only the chargeback, through the cancellation of the write-off, reverses it.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Target claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the target is being processed by a worker
                    code: PBP-0814
                PBP-0820:
                  summary: 'PBP-0820: Release already ran'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0820
                    title: SCHEDULED_RELEASE_ALREADY_EXECUTED
                    status: 409
                    detail: the scheduled release already ran
                    code: PBP-0820
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing or short `reason`.
            - `PBP-0802`: the write-off has no scheduled release.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: No scheduled release'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: no scheduled release
                    code: PBP-0802
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          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. The earlier request may have taken effect. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/cancel-a-scheduled-manual-release
  /v1/collections/write-offs/{write_off_id}/unhold:
    post:
      operationId: unholdWriteOff
      summary: Lift a negotiated write-off's release hold
      description: |-
        Removes the `NEGOTIATED` hold of a write-off (queue `NEGOTIATED_HOLD`).

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

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

        **How it works**

        - Send a `reason` and `evidence`. Both are required.
        - It does not release the amount. The release follows the usual rule: settlement on the route and the agreement's credit date.
      tags:
        - Collections Write-offs
      parameters:
        - $ref: '#/components/parameters/WriteOffIdPath'
        - $ref: '#/components/parameters/IdempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvidencedActionRequest'
      responses:
        '200':
          description: OK. The action is recorded in the audit trail. `outcome` tells whether the effect is applied or follows in the background.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResult'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a parameter, header or body is malformed.
            - `PBP-0012`: `Idempotency-Key` is missing, is not a UUID, or is the nil UUID.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Malformed request'
                  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: Idempotency-Key header is required and must be a UUID
                    code: PBP-0012
        '401':
          description: |-
            Unauthorized.

            - `PBP-0003`: the credential is missing or invalid, or does not identify a tenant. Get a valid bearer token.
          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
        '403':
          description: |-
            Forbidden.

            - `PBP-0004`: the credential does not have the `collections` `operate` permission.
          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
        '404':
          description: |-
            Not Found.

            - `PBP-0005`: the tenant has no write-off with this id. A resource of another tenant gets the same answer.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Write-off not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: write-off not found
                    code: PBP-0005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds. Do not switch keys: the earlier request can still take effect.
            - `PBP-0814`: a worker is processing the target right now. Retry later under the same `Idempotency-Key`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
                PBP-0814:
                  summary: 'PBP-0814: Target claimed by a worker'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0814
                    title: ITEM_CLAIMED_BY_WORKER
                    status: 409
                    detail: the target is being processed by a worker
                    code: PBP-0814
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: the body does not match the schema, for example a missing or short `reason`. The body needs `reason` and `evidence`.
            - `PBP-0802`: the write-off has no `NEGOTIATED` hold. The state is in `details.currentState`. The action may already be done.
            - `PBP-0013`: the same `Idempotency-Key` was sent with another body. Use a new key for a new request.
            - `PBP-0830`: the tenant does not have the collections module. Retrying does not change the answer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Invalid body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: reason must have at least 10 characters
                    code: PBP-0006
                PBP-0802:
                  summary: 'PBP-0802: No NEGOTIATED hold'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0802
                    title: Action Not Allowed In State
                    status: 422
                    detail: the write-off has no NEGOTIATED hold
                    code: PBP-0802
                PBP-0013:
                  summary: 'PBP-0013: Key reused with 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
                PBP-0830:
                  summary: 'PBP-0830: Collections not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0830
                    title: Collections Not Enabled
                    status: 422
                    detail: Collections Not Enabled
                    code: PBP-0830
        '500':
          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. The earlier request may have taken effect. Contact support. Do not resend under a new key.
          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
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/lift-a-negotiated-write-offs-release-hold
  /v1/dashboards/boletos:
    get:
      description: |-
        Returns counts, amounts and breakdowns of the boletos of the `X-Organization-Id` organization for a period.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Filter by creation date (`from`, `to`), due date (`dueDateFrom`, `dueDateTo`) and `type`. All bounds are inclusive.
        - `from` and `to` take a date (`YYYY-MM-DD`, a UTC day) or an RFC 3339 date-time with offset. Percent-encode a positive offset (`%2B`).
        - Hybrid boletos (boleto with Pix) issued earlier are still counted, also under `type=HYBRID`, because their payments still settle. No other boleto route shows them.
      operationId: getBoletoDashboard
      parameters:
        - description: 'Midaz organization whose boletos are aggregated. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only boletos of this organization are counted and summed.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization whose boletos are aggregated. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only boletos of this organization are counted and summed.'
            type: string
        - description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-01-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-12-31'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Due-date lower bound, inclusive.
          explode: false
          in: query
          name: dueDateFrom
          schema:
            description: Due-date lower bound, inclusive.
            examples:
              - '2026-02-01'
            format: date
            type: string
        - description: Due-date upper bound, inclusive.
          explode: false
          in: query
          name: dueDateTo
          schema:
            description: Due-date upper bound, inclusive.
            examples:
              - '2026-11-30'
            format: date
            type: string
        - description: Boleto type filter.
          explode: false
          in: query
          name: type
          schema:
            description: Boleto type filter.
            enum:
              - TRADITIONAL
              - HYBRID
              - QR_CODE
            examples:
              - TRADITIONAL
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoletoDashboardResponse'
          description: OK. The aggregated boleto figures for the period.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: invalid date
                        location: query.from
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `from`, `to`, `dueDateFrom`, `dueDateTo` or `type` is malformed.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Date range inverted'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: from must be before or equal to to
                    code: PBP-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: a lower bound is after its upper bound, for example `from` after `to`.
        '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. Contact support.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get boleto dashboard
      tags:
        - Dashboards
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-boleto-dashboard
  /v1/dashboards/payments:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns counts, amounts and breakdowns of the payments of the `X-Organization-Id` organization for a period.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Filter by creation date (`from`, `to`) and `type`. Both bounds are inclusive.
        - `from` and `to` take a date (`YYYY-MM-DD`, a UTC day) or an RFC 3339 date-time with offset. Percent-encode a positive offset (`%2B`).
      operationId: getPaymentDashboard
      parameters:
        - description: 'Midaz organization whose payments are aggregated. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only payments of this organization are counted and summed.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization whose payments are aggregated. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only payments of this organization are counted and summed.'
            type: string
        - description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-01-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-12-31'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Payment type filter.
          explode: false
          in: query
          name: type
          schema:
            description: Payment type filter.
            enum:
              - BANKSLIP
              - UTILITIES
              - DARF
            examples:
              - BANKSLIP
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentDashboardResponse'
          description: OK. The aggregated payment figures for the period.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                    errors:
                      - message: invalid date
                        location: query.from
                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 UUID
                    code: PBP-0025
          description: |-
            Bad Request.

            - `PBP-0001`: `from`, `to` or `type` is malformed.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0006:
                  summary: 'PBP-0006: Date range inverted'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0006
                    title: Unprocessable Entity
                    status: 422
                    detail: from date must be before or equal to 'to' date
                    code: PBP-0006
          description: |-
            Unprocessable Entity.

            - `PBP-0006`: `from` is after `to`.
        '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. Contact support.
        '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 processed. Retry the request. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable.
      security:
        - BearerAuth: []
      summary: Get payment dashboard
      tags:
        - Dashboards
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-payment-dashboard
  /v1/electronic-payers:
    post:
      tags:
        - Electronic payers
      operationId: registerElectronicPayer
      summary: Adhere a customer to electronic presentment
      description: |-
        Adheres a customer to electronic presentment of boletos (DDA) with the given accounts.

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

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

        **How it works**

        - Identify the customer by `holderId`, the holder in the Midaz CRM. Do not send the payer's document: the provider reads it from the holder record.
        - Every account in `accounts` must belong to that holder.
        - `aggregates` is optional and adds aggregates with the adhesion.
        - Send the customer's `consent`. `acceptedAt` cannot be in the future or older than 24 hours (configurable).
        - A customer already adhered in another organization of the tenant is not adhered twice. The accounts are added to the existing electronic payer, and the answer carries its `electronicPayerId` with kind `ACCOUNTS_UPDATE`.
        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/requests/{requestId}`.
        - The answer has no `electronicPayerId` only when the provider did not answer. Retry under the same `Idempotency-Key` to get it, and read the request meanwhile by `requestId`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
        - A `503` or a `4xx` refusal of this request releases the key, so a corrected retry can use it. `409` and `PBP-0013` refer to an earlier request and leave its key bound. After a `202`, the key stays bound to that request.
      parameters:
        - $ref: '#/components/parameters/OrganizationIdDDA'
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegisterElectronicPayerRequest'
      responses:
        '202':
          description: 'Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/requests/{requestId}`. Without `electronicPayerId`, the provider has not answered yet: retry under the same `Idempotency-Key` to get it.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: the body does not match the schema, for example `accounts` empty or with more than 20 items.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID. Send a UUID in the header.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match 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: Bad Request
                    status: 400
                    detail: The Idempotency-Key header is required for this endpoint.
                    code: PBP-0012
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                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
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support a feature the request uses. The `capability` member names it: `ELECTRONIC_PAYER_MULTIPLE_ACCOUNTS` for a second account or a second organization, `ELECTRONIC_PAYER_AGGREGATES` for `aggregates`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.
            - `PBP-1001`: a CPF or CNPJ in `aggregates` is invalid (check digit or length).
            - `PBP-1002`: `consent` is missing or incomplete, or `acceptedAt` is in the future or older than the accepted window (24 hours, configurable). Collect the consent again.
            - `PBP-1004`: an account or an aggregate appears more than once in the request.

            The provider can also refuse the request with its own code, for example when an account does not belong to the holder (`ACCOUNT_HOLDER_MISMATCH`). The `category` member gives a stable reason. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_AGGREGATES
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
                PBP-1001:
                  summary: 'PBP-1001: Invalid CPF or CNPJ'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1001
                    title: INVALID_DOCUMENT
                    status: 422
                    detail: the CPF or CNPJ is invalid
                    code: PBP-1001
                PBP-1002:
                  summary: 'PBP-1002: Consent invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1002
                    title: INVALID_CONSENT
                    status: 422
                    detail: consent is missing, incomplete or outside the accepted time window
                    code: PBP-1002
                PBP-1004:
                  summary: 'PBP-1004: Repeated or incomplete item'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1004
                    title: INVALID_REQUEST_ITEMS
                    status: 422
                    detail: an account appears more than once in the request
                    code: PBP-1004
        '503':
          description: |-
            Service Unavailable. The provider is unavailable, and no attempt under this `Idempotency-Key` reached it. The key is released: retry, and the same key can be used.

            - When an earlier attempt under the same key went unanswered, the answer is `202` `PENDING` with that attempt's `requestId` instead.
            - When the provider does not answer after the request was sent, the answer is also `202` `PENDING`. The key stays bound to that request.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/adhere-a-customer-to-electronic-presentment
    get:
      tags:
        - Electronic payers
      operationId: listElectronicPayers
      summary: List the organization's electronic payers
      description: |-
        Lists the customers with at least one adhered account in this organization.

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

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

        **How it works**

        - Filter by `midazAccountId` to find the payer of one account.
        - Page with `cursor`, using the `nextCursor` of the previous page. The last page carries `syncCursor`.
        - To read only what changed, send the last `syncCursor` as `changedSince`.
        - With `changedSince`, a payer with no adhered account left here appears once as a removal item (`ElectronicPayerRemoval`). This holds while the cursor is valid. The item carries no other data.
        - Apply a removal item only when its `version` is greater than the last one applied for that payer. Otherwise the payer came back, and the item is stale.
        - Items are ordered by the position of each change, not by the payer's version.
      parameters:
        - $ref: '#/components/parameters/OrganizationIdDDA'
        - name: midazAccountId
          in: query
          required: false
          schema:
            type: string
            maxLength: 100
        - $ref: '#/components/parameters/CursorDDA'
        - $ref: '#/components/parameters/ChangedSince'
        - $ref: '#/components/parameters/LimitDDA'
      responses:
        '200':
          description: OK. A page of electronic payers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ElectronicPayerPage'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a query parameter does not match the schema, for example `limit` outside 1 to 200.
            - `PBP-1008`: `cursor` or `changedSince` is invalid or came from another filter. Send a cursor returned for the same filter.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                PBP-1008:
                  summary: 'PBP-1008: Invalid cursor'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1008
                    title: INVALID_CURSOR
                    status: 400
                    detail: the cursor is invalid or belongs to another filter
                    code: PBP-1008
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-the-organizations-electronic-payers
  /v1/electronic-payers/requests/{requestId}:
    get:
      tags:
        - Electronic payers
      operationId: getElectronicPayerRequestById
      summary: Read a request by id
      description: |-
        Reads a request of this organization and its outcome by `requestId` alone.

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

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

        **How it works**

        - Use it when the answer to an adhesion had no `electronicPayerId`, because the provider did not answer. It also reads any other request of this organization.
        - Access depends on the record of the request made by this organization, as in `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - `electronicPayerId` is absent while the provider has not answered the adhesion.
      responses:
        '200':
          description: OK. The request and its outcome. A refused request carries the reason in `rejection`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ElectronicPayerRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1007`: this organization made no request with this `requestId`.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1007:
                  summary: 'PBP-1007: Request not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1007
                    title: REQUEST_NOT_FOUND
                    status: 404
                    detail: request not found for this organization
                    code: PBP-1007
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/read-a-request-by-id
    parameters:
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - name: requestId
        in: path
        required: true
        schema:
          type: string
          format: uuid
  /v1/electronic-payers/{electronicPayerId}:
    get:
      tags:
        - Electronic payers
      operationId: getElectronicPayer
      summary: Read an electronic payer
      responses:
        '200':
          description: OK. The electronic payer.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ElectronicPayer'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
      security:
        - BearerAuth: []
      description: |-
        Reads an electronic payer visible to this organization.

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

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

        **How it works**

        - A payer is visible when it has an adhered account in this organization.
        - The answer lists only this organization's adhered accounts.
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/read-an-electronic-payer
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
    patch:
      tags:
        - Electronic payers
      operationId: updateElectronicPayerAccounts
      summary: Add or remove adhered accounts
      description: |-
        Adds or removes adhered accounts of the electronic payer.

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

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

        **How it works**

        - Send `accountsToAdd`, `accountsToRemove`, or both.
        - At least one account stays active.
        - To change an account, remove it and add the new one in the same request.
        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateElectronicPayerAccountsRequest'
      responses:
        '202':
          description: Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                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
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support a second account. The `capability` member is `ELECTRONIC_PAYER_MULTIPLE_ACCOUNTS`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.
            - `PBP-1003`: the request has no account to add and none to remove.
            - `PBP-1004`: an account appears more than once in the request.

            The provider can also refuse the request with its own code, for example when the request would leave no active account. The `category` member gives a stable reason. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_MULTIPLE_ACCOUNTS
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
                PBP-1003:
                  summary: 'PBP-1003: No account to change'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1003
                    title: NO_ACCOUNT_CHANGE
                    status: 422
                    detail: the request neither adds nor removes an account
                    code: PBP-1003
                PBP-1004:
                  summary: 'PBP-1004: Repeated or incomplete item'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1004
                    title: INVALID_REQUEST_ITEMS
                    status: 422
                    detail: an account appears more than once in the request
                    code: PBP-1004
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/add-or-remove-adhered-accounts
    delete:
      tags:
        - Electronic payers
      operationId: excludeElectronicPayer
      summary: Exclude the adhesion in this organization
      description: |-
        Removes this organization's adhered accounts from the electronic payer.

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

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

        **How it works**

        - While another organization of the tenant still has adhered accounts, the adhesion stays for that organization.
        - When this organization was the last one, the adhesion is excluded with its accounts and aggregates. No new boleto is presented afterwards.
        - On confirmation, this organization receives `ELECTRONIC_PAYER_EXCLUDED` and stops seeing the payer. It still reads this request at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - The other organizations receive `ELECTRONIC_PAYER_UPDATED` with the same payer version.
        - A refusal arrives as `ELECTRONIC_PAYER_UPDATE_REJECTED`, with the `requestId` and the reason in `rejection`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
        - A `503` or a `4xx` refusal of this request releases the key, so a corrected retry can use it. `409` and `PBP-0013` refer to an earlier request and leave its key bound. After a `202`, the key stays bound to that request.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      responses:
        '202':
          description: Accepted. The outcome arrives as `ELECTRONIC_PAYER_EXCLUDED` for this organization, or as `ELECTRONIC_PAYER_UPDATE_REJECTED`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
        '409':
          description: |-
            Conflict.

            - `PBP-0007`: an earlier request under the same `Idempotency-Key` is still running. It answers this for at most 5 minutes. After that, the same key returns the stored answer, or 500 `PBP-0002` when it cannot be replayed, or runs the request again when no answer was kept. Retry under the same key after a few seconds.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                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
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.

            The provider can also refuse the request with its own code. The `category` member gives a stable reason, for example `PAYER_NOT_ACTIVE` when the adhesion is excluded. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
        '503':
          description: |-
            Service Unavailable. The provider is unavailable, and no attempt under this `Idempotency-Key` reached it. The key is released: retry, and the same key can be used.

            - When an earlier attempt under the same key went unanswered, the answer is `202` `PENDING` with that attempt's `requestId` instead.
            - When the provider does not answer after the request was sent, the answer is also `202` `PENDING`. The key stays bound to that request.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/exclude-the-adhesion-in-this-organization
  /v1/electronic-payers/{electronicPayerId}/aggregates:
    post:
      tags:
        - Electronic payers
      operationId: addElectronicPayerAggregate
      summary: Add an aggregate
      description: |-
        Adds an aggregate to the electronic payer. Boletos issued against the aggregate are presented to this payer, at this institution only.

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

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

        **How it works**

        - Send the aggregate's `document` (CPF or CNPJ, without punctuation; a CNPJ can be alphanumeric) and the customer's `consent`.
        - `consent.acceptedAt` cannot be in the future or older than 24 hours (configurable).
        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddAggregateRequest'
      responses:
        '202':
          description: Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support aggregates. The `capability` member is `ELECTRONIC_PAYER_AGGREGATES`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.
            - `PBP-1001`: the aggregate's CPF or CNPJ is invalid (check digit or length).
            - `PBP-1002`: `consent` is missing or incomplete, or `acceptedAt` is in the future or older than the accepted window (24 hours, configurable). Collect the consent again.

            The provider can also refuse the request with its own code, for example when the aggregate is the payer itself. The `category` member gives a stable reason. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_AGGREGATES
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
                PBP-1001:
                  summary: 'PBP-1001: Invalid CPF or CNPJ'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1001
                    title: INVALID_DOCUMENT
                    status: 422
                    detail: the CPF or CNPJ is invalid
                    code: PBP-1001
                PBP-1002:
                  summary: 'PBP-1002: Consent invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1002
                    title: INVALID_CONSENT
                    status: 422
                    detail: consent is missing, incomplete or outside the accepted time window
                    code: PBP-1002
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/add-an-aggregate
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
  /v1/electronic-payers/{electronicPayerId}/aggregates/{aggregateId}:
    delete:
      tags:
        - Electronic payers
      operationId: removeElectronicPayerAggregate
      summary: Remove an aggregate
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      responses:
        '202':
          description: Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support aggregates. The `capability` member is `ELECTRONIC_PAYER_AGGREGATES`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.

            The provider can also refuse the request with its own code. The `category` member gives a stable reason, for example `PAYER_NOT_ACTIVE` when the adhesion is excluded. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_AGGREGATES
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
      security:
        - BearerAuth: []
      description: |-
        Removes an aggregate from the electronic payer.

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

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

        **How it works**

        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/remove-an-aggregate
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - name: aggregateId
        in: path
        required: true
        schema:
          type: string
          format: uuid
  /v1/electronic-payers/{electronicPayerId}/boletos:
    get:
      tags:
        - Presented boletos
      operationId: listPresentedBoletos
      summary: List boletos presented to the electronic payer
      description: |-
        Lists the boletos presented to the electronic payer.

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

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

        **How it works**

        - Filter with `audience`: `PAYER` for boletos issued against the customer, `AGGREGATE` for boletos against one of its aggregates, `THIRD_PARTY` for boletos the customer was authorized to see. Without it, all.
        - Page with `cursor`, using the `nextCursor` of the previous page. The last page carries `syncCursor`.
        - Send `syncCursor` as `changedSince` to get only boletos created or changed since: new, amended, written off, paid or lapsed.
        - Reading while the list changes neither repeats nor skips items.
        - Items are ordered by the position of each change, not by the boleto's version.
      parameters:
        - name: audience
          in: query
          required: false
          schema:
            type: string
            enum:
              - PAYER
              - AGGREGATE
              - THIRD_PARTY
          description: PAYER, boletos issued against the customer; AGGREGATE, against one of the customer's aggregates; THIRD_PARTY, boletos the customer was authorized to see. Absent, all.
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - OPEN
              - PARTIALLY_PAID
              - WRITTEN_OFF
              - LAPSED
              - NO_LONGER_VISIBLE
        - $ref: '#/components/parameters/CursorDDA'
        - $ref: '#/components/parameters/ChangedSince'
        - $ref: '#/components/parameters/LimitDDA'
      responses:
        '200':
          description: OK. A page of presented boletos.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PresentedBoletoPage'
        '400':
          description: |-
            Bad Request.

            - `PBP-0001`: a query parameter does not match the schema, for example `limit` outside 1 to 200.
            - `PBP-1008`: `cursor` or `changedSince` is invalid or came from another filter. Send a cursor returned for the same filter.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request does not match the schema'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                PBP-1008:
                  summary: 'PBP-1008: Invalid cursor'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1008
                    title: INVALID_CURSOR
                    status: 400
                    detail: the cursor is invalid or belongs to another filter
                    code: PBP-1008
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-boletos-presented-to-the-electronic-payer
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
  /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}:
    get:
      tags:
        - Presented boletos
      operationId: getPresentedBoleto
      summary: Read a presented boleto
      responses:
        '200':
          description: OK. The presented boleto.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PresentedBoleto'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
            - `PBP-1006`: the boleto was not presented to this electronic payer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
                PBP-1006:
                  summary: 'PBP-1006: Boleto not presented'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1006
                    title: PRESENTED_BOLETO_NOT_FOUND
                    status: 404
                    detail: boleto not presented to this electronic payer
                    code: PBP-1006
      security:
        - BearerAuth: []
      description: |-
        Reads a boleto presented to the electronic payer.

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

        <Warning>**Under development.** This endpoint can change before it is released.</Warning>
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/read-a-presented-boleto
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - $ref: '#/components/parameters/ReceiverBoletoId'
  /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}/acceptance:
    put:
      tags:
        - Presented boletos
      operationId: setPresentedBoletoAcceptance
      summary: Accept or refuse a presented boleto
      description: |-
        Records the customer's acceptance or refusal of a presented boleto.

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

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

        **How it works**

        - Send `acceptance` (`ACCEPTED` or `REFUSED`) and `channel`.
        - The acceptance is informative. It does not prevent payment.
        - A later request replaces the previous one.
        - The customer can accept or refuse a boleto issued against it or against one of its aggregates. A boleto it sees only as an authorized third party is refused with `PBP-1010`.
        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetAcceptanceRequest'
      responses:
        '202':
          description: Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
            - `PBP-1006`: the boleto was not presented to this electronic payer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
                PBP-1006:
                  summary: 'PBP-1006: Boleto not presented'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1006
                    title: PRESENTED_BOLETO_NOT_FOUND
                    status: 404
                    detail: boleto not presented to this electronic payer
                    code: PBP-1006
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support acceptance. The `capability` member is `ELECTRONIC_PAYER_ACCEPTANCE`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.
            - `PBP-1010`: the customer sees this boleto only as an authorized third party. Only boletos issued against the customer or one of its aggregates can be accepted or refused.

            The provider can also refuse the request with its own code. The `category` member gives a stable reason, for example `PAYER_NOT_ACTIVE` when the adhesion is excluded. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_ACCEPTANCE
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
                PBP-1010:
                  summary: 'PBP-1010: Customer is only a third party'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1010
                    title: ACCEPTANCE_NOT_ALLOWED
                    status: 422
                    detail: the customer is only an authorized third party on this boleto
                    code: PBP-1010
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/accept-or-refuse-a-presented-boleto
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - $ref: '#/components/parameters/ReceiverBoletoId'
  /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}/authorized-third-parties:
    post:
      tags:
        - Presented boletos
      operationId: addAuthorizedThirdParty
      summary: Authorize a third party for a boleto
      description: |-
        Authorizes a third party to see and pay a presented boleto.

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

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

        **How it works**

        - The third party must also be an electronic payer, at any institution.
        - The third party must differ from the customer who owes the boleto.
        - Send `authorizer.kind`: `PAYER`, or `AGGREGATE` with `aggregateId` when the boleto is issued against one of the customer's aggregates.
        - Send the third party's `document` (CPF or CNPJ) and the customer's `consent`.
        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddThirdPartyRequest'
      responses:
        '202':
          description: Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
            - `PBP-1006`: the boleto was not presented to this electronic payer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
                PBP-1006:
                  summary: 'PBP-1006: Boleto not presented'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1006
                    title: PRESENTED_BOLETO_NOT_FOUND
                    status: 404
                    detail: boleto not presented to this electronic payer
                    code: PBP-1006
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support authorized third parties. The `capability` member is `ELECTRONIC_PAYER_THIRD_PARTIES`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.
            - `PBP-1001`: the third party's CPF or CNPJ is invalid (check digit or length).
            - `PBP-1002`: `consent` is missing or incomplete, or `acceptedAt` is in the future or older than the accepted window (24 hours, configurable). Collect the consent again.
            - `PBP-1004`: `authorizer.kind` is `AGGREGATE` without `aggregateId`.

            The provider can also refuse the request with its own code, for example when the third party is the customer who owes the boleto. The `category` member gives a stable reason. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_THIRD_PARTIES
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
                PBP-1001:
                  summary: 'PBP-1001: Invalid CPF or CNPJ'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1001
                    title: INVALID_DOCUMENT
                    status: 422
                    detail: the CPF or CNPJ is invalid
                    code: PBP-1001
                PBP-1002:
                  summary: 'PBP-1002: Consent invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1002
                    title: INVALID_CONSENT
                    status: 422
                    detail: consent is missing, incomplete or outside the accepted time window
                    code: PBP-1002
                PBP-1004:
                  summary: 'PBP-1004: Repeated or incomplete item'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1004
                    title: INVALID_REQUEST_ITEMS
                    status: 422
                    detail: authorizer kind AGGREGATE requires aggregateId
                    code: PBP-1004
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/authorize-a-third-party-for-a-boleto
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - $ref: '#/components/parameters/ReceiverBoletoId'
  /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}/authorized-third-parties/{thirdPartyId}:
    delete:
      tags:
        - Presented boletos
      operationId: removeAuthorizedThirdParty
      summary: Remove an authorized third party
      description: |-
        Removes an authorized third party from a presented boleto.

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

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

        **How it works**

        - Any third party of the boleto can be removed, including one authorized at another institution.
        - The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
        - A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
        - The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
        - If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      responses:
        '202':
          description: Accepted. The request was taken for processing. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1005`: the electronic payer does not exist or has no adhered account in this organization.
            - `PBP-1006`: the boleto was not presented to this electronic payer.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
                PBP-1006:
                  summary: 'PBP-1006: Boleto not presented'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1006
                    title: PRESENTED_BOLETO_NOT_FOUND
                    status: 404
                    detail: boleto not presented to this electronic payer
                    code: PBP-1006
        '422':
          description: |-
            Unprocessable Entity.

            - `PBP-0013`: the `Idempotency-Key` was already used on this endpoint with a different body or `X-Organization-Id`. Resend the original request under that key, or send the new request under a new key.
            - `PBP-0701`: the provider does not support authorized third parties. The `capability` member is `ELECTRONIC_PAYER_THIRD_PARTIES`.
            - `PBP-1000`: DDA is not enabled for the tenant: there is no provider route for `ELECTRONIC_PAYER`. Configure the route first.

            The provider can also refuse the request with its own code. The `category` member gives a stable reason, for example `PAYER_NOT_ACTIVE` when the adhesion is excluded. Handle the refusal by `category`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_THIRD_PARTIES
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/remove-an-authorized-third-party
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - $ref: '#/components/parameters/ReceiverBoletoId'
      - name: thirdPartyId
        in: path
        required: true
        schema:
          type: string
          format: uuid
  /v1/electronic-payers/{electronicPayerId}/requests/{requestId}:
    get:
      tags:
        - Electronic payers
      operationId: getElectronicPayerRequest
      summary: Read the outcome of a request
      description: |-
        Reads a request of this organization and its outcome.

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

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

        **How it works**

        - Access depends on the record of the request made by this organization, not on the payer's current visibility.
        - After a confirmed exclusion, the organization no longer sees the payer, but it still reads its own request.
      responses:
        '200':
          description: OK. The request and its outcome. A refused request carries the reason in `rejection`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ElectronicPayerRequest'
        '404':
          description: |-
            Not Found.

            - `PBP-1007`: this organization made no request with this `requestId`.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1007:
                  summary: 'PBP-1007: Request not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1007
                    title: REQUEST_NOT_FOUND
                    status: 404
                    detail: request not found for this organization
                    code: PBP-1007
      security:
        - BearerAuth: []
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/read-the-outcome-of-a-request
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
      - name: requestId
        in: path
        required: true
        schema:
          type: string
          format: uuid
  /v1/payments:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Lists the payments of an organization, with pagination and optional filters.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - `X-Organization-Id` is required. Only payments of that organization are listed and counted.
        - Filter by `status`, `type`, creation date (`from`, `to`) and due date (`dueDateFrom`, `dueDateTo`). All bounds are inclusive.
        - `status=UNCONFIRMED` selects payments whose outcome at the provider is not known yet, such as one answered `202`.
        - `from` and `to` take a date (`YYYY-MM-DD`, a UTC day) or an RFC 3339 date-time with offset. Percent-encode a positive offset (`%2B`).
        - Due-date bounds match only `DARF` and `BANKSLIP` payments. `UTILITIES` payments have no due date.
        - `idempotencyKey` lists the payment that key created in this organization, if any. Use it to recover what a creation answered when you have no payment id, for example after a `5xx`. It is not for polling.
        - A key whose creation was refused before anything was created lists nothing. An empty value is ignored.

        **Planned changes**

        - Lerian (PCR): boleto payment through Lerian (PCR) is planned. The `status` filter accepts `RETURNED` (the amount went back to the funding account after the issuing institution returned it). Items carry the new payment members `antifraud`, `requestedAmount` and `return`.
        - Payment scheduling: a future `scheduledDate` is sent to the provider on its effective date (first business day on or after it), once. Adds `scheduledDate` (DARF too), `effectiveScheduledDate`, `effectiveAfterDueDate`, `amountIsEstimated`, `executedAt`, `failureReason`, the `PROCESSING` status and new error codes. This change will be specified again before it applies. The list gains the filters `effectiveScheduledDateFrom` and `effectiveScheduledDateTo` (the date the payment occurs, not the requested or creation date).
        - `payee.taxId` (the CPF or CNPJ of the slip's beneficiary) will be masked, as the consult already masks it. Today it is returned in full, even on `FAILED` or `REJECTED` payments.
      operationId: listPayments
      parameters:
        - description: 'Midaz organization whose payments are listed. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only payments of this organization are listed and counted.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization whose payments are listed. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. Only payments of this organization are listed and counted.'
            type: string
        - description: |-
            Status filter. UNCONFIRMED selects the payments whose outcome at the payment provider is not known yet: an initiation answered 202 leaves its payment there until it resolves.

            Planned: accepts RETURNED, the payments whose amount went back to the funding account after the issuing institution returned it.
          explode: false
          in: query
          name: status
          schema:
            description: 'Status filter. UNCONFIRMED selects the payments whose outcome at the payment provider is not known yet: an initiation answered 202 leaves its payment there until it resolves.'
            enum:
              - UNCONFIRMED
              - CREATED
              - SCHEDULED
              - PENDING_APPROVAL
              - APPROVED
              - EXECUTED
              - SETTLED
              - REJECTED
              - FAILED
              - CANCELED
            examples:
              - CREATED
            type: string
          x-mint:
            post:
              - Under development
        - description: Payment type filter.
          explode: false
          in: query
          name: type
          schema:
            description: Payment type filter.
            enum:
              - BANKSLIP
              - UTILITIES
              - DARF
            examples:
              - BANKSLIP
            type: string
        - description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: from
          schema:
            description: Created-from bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and starts at its first instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T00:00:00-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-01-01'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
          explode: false
          in: query
          name: to
          schema:
            description: Created-to bound, inclusive. A calendar date (YYYY-MM-DD) is a UTC day and covers it to its last instant; an RFC 3339 date-time with offset (e.g. 2026-09-30T23:59:59.999999-03:00) is used as the exact instant. A positive offset must be percent-encoded (%2B).
            examples:
              - '2026-12-31'
            pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
            type: string
            x-pattern-description: a YYYY-MM-DD date or an RFC 3339 date-time with offset
        - description: Due-date lower bound, inclusive. It matches the DARF and BANKSLIP payments that carry a due date (see dueDate on the payment). UTILITIES payments carry none, so this bound matches none of them.
          explode: false
          in: query
          name: dueDateFrom
          schema:
            description: Due-date lower bound, inclusive. It matches the DARF and BANKSLIP payments that carry a due date (see dueDate on the payment). UTILITIES payments carry none, so this bound matches none of them.
            examples:
              - '2026-02-01'
            format: date
            type: string
        - description: Due-date upper bound, inclusive. It matches the DARF and BANKSLIP payments that carry a due date (see dueDate on the payment). UTILITIES payments carry none, so this bound matches none of them.
          explode: false
          in: query
          name: dueDateTo
          schema:
            description: Due-date upper bound, inclusive. It matches the DARF and BANKSLIP payments that carry a due date (see dueDate on the payment). UTILITIES payments carry none, so this bound matches none of them.
            examples:
              - '2026-11-30'
            format: date
            type: string
        - description: Page number, one-based.
          explode: false
          in: query
          name: page
          schema:
            default: 1
            description: Page number, one-based.
            examples:
              - 1
            format: int64
            minimum: 1
            type: integer
        - description: Items per page.
          explode: false
          in: query
          name: limit
          schema:
            default: 20
            description: Items per page.
            examples:
              - 20
            format: int64
            maximum: 100
            minimum: 1
            type: integer
        - description: 'The Idempotency-Key a payment was created under, on POST /v1/payments or POST /v1/payments/darf. Lists the payment that key created in this organization, if any: the way to find what a creation answered without a payment id left behind, a 5xx above all. A key whose creation was refused before anything was created lists nothing. A payment retried under the same key after a refusal for funds is listed with the refused attempt. Combines with the other filters. A value that is not a UUID is refused with 400 PBP-0001; an empty value is ignored, as on the other filters. Meant for recovering one request, not for polling.'
          explode: false
          in: query
          name: idempotencyKey
          schema:
            description: 'The Idempotency-Key a payment was created under, on POST /v1/payments or POST /v1/payments/darf. Lists the payment that key created in this organization, if any: the way to find what a creation answered without a payment id left behind, a 5xx above all. A key whose creation was refused before anything was created lists nothing. A payment retried under the same key after a refusal for funds is listed with the refused attempt. Combines with the other filters. A value that is not a UUID is refused with 400 PBP-0001; an empty value is ignored, as on the other filters. Meant for recovering one request, not for polling.'
            examples:
              - 6f9619ff-8b86-d011-b42d-00c04fc964ff
            type: string
        - name: effectiveScheduledDateFrom
          in: query
          explode: false
          description: |-
            Planned. Effective date of the scheduled payment, lower bound, inclusive. Filters by the date the payment runs or ran, not by the requested date (`scheduledDate`), the creation date (`from`) or the title due date (`dueDateFrom`). Immediate payments are not returned by this filter.
          schema:
            type: string
            format: date
            description: Effective scheduled-date lower bound, inclusive.
            examples:
              - '2026-09-14'
          x-mint:
            post:
              - Under development
        - name: effectiveScheduledDateTo
          in: query
          explode: false
          description: |-
            Planned. Effective date of the scheduled payment, upper bound, inclusive. Independent of `effectiveScheduledDateFrom`: sending only one side leaves the other side open.
          schema:
            type: string
            format: date
            description: Effective scheduled-date upper bound, inclusive.
            examples:
              - '2026-09-18'
          x-mint:
            post:
              - Under development
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListPaymentsResponse'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0001`: a filter is malformed, for example `idempotencyKey` is not a UUID, or a date bound is not a date or an RFC 3339 date-time with offset.

            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 permission for this operation.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: List payments
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/list-payments
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Pays a bank slip (boleto) or a utilities bill through the provider the tenant routes `BANKSLIP_PAYMENT` or `BARCODE_BILL_PAYMENT` to. The type comes from the digitable line.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The payment runs at once. There is no scheduling: a `scheduledDate` is refused.
        - Before anything is created, the provider checks the slip. A slip that cannot be paid, or that the source refuses or does not know, creates nothing.
        - The payer is always the registered owner of the funding account (`midazAccountId`). Do not send payer data.
        - Funds are reserved in the ledger before the provider is instructed.
        - `201`: the provider acknowledged the payment (status `CREATED`). `202`: the outcome is not known (status `UNCONFIRMED`). Follow both with `GET /v1/payments/{id}`.
        - After a `202`, do not resend under a new `Idempotency-Key`: the provider may have it, and you can pay twice.
        - A retry under the same `Idempotency-Key` returns the stored answer of a `201`, a `202`, or a refusal that consumes the key (see each code). After a refusal that releases the key, the same key runs the request again. While the first request runs, the same key gets `409` `PBP-0007`.
        - To find what a request created when you have no payment id, call `GET /v1/payments` with `idempotencyKey`.

        **Planned changes**

        - Lerian (PCR): boleto payment through Lerian (PCR) is planned. The body gains optional `amount` (informed amount), `channel` and `paymentMethod`, and the payment can pass an antifraud step. Lerian sets up the tenant's antifraud, default channel and payment method at onboarding. No client endpoint reads or changes them.
        - DDA (electronic payer): new optional `receiverBoletoId`, the presented boleto being paid. With `channel` `DDA`, it is required, must name a boleto presented to the holder of `midazAccountId`, and `digitableLine` must be that boleto's line.
        - Payment scheduling: a future `scheduledDate` is sent to the provider on its effective date (first business day on or after it), once. Adds `scheduledDate` (DARF too), `effectiveScheduledDate`, `effectiveAfterDueDate`, `amountIsEstimated`, `executedAt`, `failureReason`, the `PROCESSING` status and new error codes. This change will be specified again before it applies.
      operationId: initiatePayment
      parameters:
        - description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiatePaymentRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitiatePaymentResponse'
          description: 'Created. The provider acknowledged the payment. It is `CREATED` and has `providerId`. Follow its outcome with `GET /v1/payments/{id}`. A key that already names an acknowledged payment also returns `201`, with the payment as it stands.'
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitiatePaymentResponse'
          description: 'Accepted. The payment was created and sent, but the outcome is not known. It is `UNCONFIRMED`, with no `providerId`. Do not resend under a new `Idempotency-Key`: you can pay twice. It resolves on its own: to the status the provider reports, or to `FAILED` with its funds released when the provider has no record of it. A resend under the same key is safe: for up to 48 hours it returns this same `202`, even after the payment has resolved. Read the current status with `GET /v1/payments/{id}`. A key that names a payment still `UNCONFIRMED` also returns `202`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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: ledgerId missing'
                  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
                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-0204:
                  summary: 'PBP-0204: Account has no owner'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0204
                    title: Payer Not Registered
                    status: 400
                    detail: The account this payment would be debited from has no registered owner on file, so the payer cannot be established. Register the account's owner, or use an account that has one.
                    code: PBP-0204
          description: |-
            Bad Request. No payment was created and nothing was sent to the provider.

            - `PBP-0001`: the body is missing, is not JSON, fails the schema, or has a member this operation does not accept (`payer`, `payeeName`, `payeeTaxId`, `scheduledDate`). `errors[]` names each one.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0026`: `ledgerId` is missing, blank or is not a UUID.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0204`: the account in `midazAccountId` has no registered owner, so the payer cannot be established. Register the owner, or use an account that has one.

            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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Account not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Account not found or not accessible.
                    code: PBP-0005
                PBP-0110:
                  summary: 'PBP-0110: Bill not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0110
                    title: Bill Not Found
                    status: 404
                    detail: The payment slip was not found at its source.
                    code: PBP-0110
          description: |-
            Not Found. Nothing was created or sent. The `Idempotency-Key` is released.

            - `PBP-0005`: the funding account was not found or is not accessible.
            - `PBP-0110`: the slip's source has no bill under this digitable line. Check the line.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0300:
                  summary: 'PBP-0300: Insufficient funds'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0300
                    title: Insufficient Funds
                    status: 422
                    detail: The funding account does not have enough available balance to complete this operation.
                    code: PBP-0300
                PBP-0302:
                  summary: 'PBP-0302: Overdraft limit exceeded'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0302
                    title: Ledger Refused
                    status: 422
                    detail: The ledger declined this operation. It was not completed and will not be retried; resolve the condition on the funding account before submitting a new request.
                    code: PBP-0302
                PBP-0014:
                  summary: 'PBP-0014: Provider refused payment'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0014
                    title: Provider Rejection
                    status: 422
                    detail: The payment was rejected by the provider.
                    code: PBP-0014
                PBP-0212:
                  summary: 'PBP-0212: Outside provider hours'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0212
                    title: Payment Outside Provider Window
                    status: 422
                    detail: 'The payment provider refused this payment because it was sent outside the hours it accepts payments. Nothing was paid. This Idempotency-Key is consumed: resend under a new Idempotency-Key once the provider accepts payments again.'
                    code: PBP-0212
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0210:
                  summary: 'PBP-0210: Slip not payable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0210
                    title: Slip Not Payable
                    status: 422
                    detail: The payment slip cannot be paid.
                    code: PBP-0210
                PBP-0111:
                  summary: 'PBP-0111: Source refused the bill'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0111
                    title: Bill Refused By Source
                    status: 422
                    detail: The payment slip was refused by its source (provider code 123).
                    code: PBP-0111
                PBP-0202:
                  summary: 'PBP-0202: Account validation unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0202
                    title: PAYMENT_VALIDATOR_NOT_CONFIGURED
                    status: 422
                    detail: Account ownership validation is unavailable, so the payment was NOT submitted. Retrying this request unchanged will not clear the condition.
                    code: PBP-0202
                PBP-0017:
                  summary: 'PBP-0017: Provider account unresolved'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: The paying provider account could not be established, so the payment was NOT submitted. Retrying this request unchanged will not clear the condition.
                    code: PBP-0017
                PBP-0205:
                  summary: 'PBP-0205: Owner registration invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0205
                    title: Payer Registration Invalid
                    status: 422
                    detail: The registered owner of the account this payment would be debited from is recorded inconsistently, so the payer cannot be established. Correct the account owner's registration; resubmitting this request unchanged will not resolve it.
                    code: PBP-0205
                PBP-0208:
                  summary: 'PBP-0208: Owner document not numeric'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0208
                    title: Payer Document Not Numeric For Provider
                    status: 422
                    detail: The registered owner of the account this payment would be debited from has a tax document that is not all digits, so the payment was NOT submitted.
                    code: PBP-0208
                PBP-0700:
                  summary: 'PBP-0700: No provider on the route'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0700
                    title: PROVIDER_ROUTE_NOT_CONFIGURED
                    status: 422
                    detail: No provider is configured for BANKSLIP_PAYMENT operations of this tenant, so nothing was recorded and no provider was called.
                    code: PBP-0700
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: The provider that serves this operation does not support OPERATION_BANKSLIP_PAYMENT, so nothing was recorded and the provider was not called.
                    code: PBP-0701
                    capability: OPERATION_BANKSLIP_PAYMENT
                PBP-0220:
                  summary: 'PBP-0220: Presented boleto required'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0220
                    title: PRESENTED_BOLETO_REQUIRED
                    status: 422
                    detail: Channel DDA requires a presented boleto that matches the digitable line.
                    code: PBP-0220
          description: |-
            Unprocessable Entity.

            - `PBP-0300`: the funding account does not have enough available balance. The payment is recorded as `FAILED`. Nothing was sent or paid. The key is released: resend under the same or a new key once the balance allows.
            - `PBP-0302`: the funds reservation would take the funding account past its overdraft limit. The payment is recorded as `FAILED`. Nothing was sent or paid. The key is released.
            - `PBP-0014`: the provider refused the payment instruction. Nothing was paid and the reservation is cancelled. The key is consumed: fix the cause and send under a new `Idempotency-Key`.
            - `PBP-0212`: the provider refused the payment because it arrived outside its accepted hours. Nothing was paid. The key is consumed: send under a new `Idempotency-Key` once the provider accepts payments. Until the first reservation is released, you may get `PBP-0300`.
            - `PBP-0013`: the `Idempotency-Key` was already used for a different request (another body, digitable line, funding account, `X-Organization-Id` or `ledgerId`). Nothing was done. Send under a new key.
            - `PBP-0210`: the provider's check found the slip cannot be paid: already paid, cancelled, expired, or with an amount of zero or less. Nothing was created. It keeps returning this code until the slip changes.
            - `PBP-0111`: the slip's source refused it in the provider's check, for the reason whose provider code the `detail` names (for example a different amount). Nothing was created. Resend once the cause is fixed.
            - `PBP-0202`: account validation is not available on this deployment. No payment was created. Contact support.
            - `PBP-0017`: the provider account to pay from could not be established. Nothing was created or sent. A resend does not fix it. Contact support.
            - `PBP-0205`: the funding account owner's registration is inconsistent (invalid CPF or CNPJ, a tax id that contradicts the person type, or more than one owner), so the payer cannot be established. Fix the registration, then resend.
            - `PBP-0208`: the funding account owner's tax document is not numeric, for example an alphanumeric CNPJ. The provider accepts only a numeric CPF or CNPJ. No payment was created. Use an account whose owner has a numeric document.
            - `PBP-0700`: the tenant's provider route has no provider for `BANKSLIP_PAYMENT` or `BARCODE_BILL_PAYMENT`. Nothing was written and no provider was called.
            - `PBP-0701`: the routed provider does not declare a capability this request needs. The `capability` member names it: `OPERATION_BANKSLIP_PAYMENT`, `OPERATION_BARCODE_BILL_PAYMENT`, `PAYMENT_SEGMENT_BANKSLIP` or `PAYMENT_SEGMENT_UTILITIES`. Nothing was written and no provider was called.
            - Planned: `PBP-0220`: DDA (electronic payer): `channel` is `DDA` without a valid `receiverBoletoId`, or `digitableLine` is not the line of that presented boleto.

            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.

            - `PBP-0002`: an unexpected failure. The payment may or may not exist, and in rare cases it may have been sent. A resend under the same key is safe: it gets `409` `PBP-0007` while the first request holds the key, then replays this `500` or runs the request again. Before you send under a new `Idempotency-Key`, look for the payment with `GET /v1/payments?idempotencyKey=`. If one is found, follow it with `GET /v1/payments/{id}` and do not resend. After you switch keys, never resend under the old one: it can run again after five minutes and pay alongside the new one.
        '502':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0113:
                  summary: 'PBP-0113: Unusable provider answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0113
                    title: Provider Unexpected Response
                    status: 502
                    detail: internal error
                    code: PBP-0113
          description: |-
            Bad Gateway. The `detail` is a fixed text.

            - `PBP-0113`: the provider's check of the slip returned an answer that cannot be used (no amount, an amount outside its declared limits, an error inside the answer, an unknown refusal reason or an unreadable body). A provider that does not answer gets `503` `PBP-0015` instead. Nothing was created. The key is released: resend under the same key.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0211:
                  summary: 'PBP-0211: Provider did not receive it'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0211
                    title: Payment Not Received By Provider
                    status: 503
                    detail: internal error
                    code: PBP-0211
                PBP-0015:
                  summary: 'PBP-0015: Provider unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: Provider Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0015
                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
                PBP-0206:
                  summary: 'PBP-0206: Owner records unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0206
                    title: Owner Registry Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0206
                PBP-0706:
                  summary: 'PBP-0706: Counterparty unusable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0706
                    title: Ledger Counterparty Unusable
                    status: 503
                    detail: internal error
                    code: PBP-0706
                PBP-0301:
                  summary: 'PBP-0301: Funds not reserved'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0301
                    title: Ledger Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0301
                PBP-0704:
                  summary: 'PBP-0704: Provider not available'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. The `detail` is a fixed text.

            - `PBP-0211`: the provider did not receive the instruction. Nothing was paid. The payment is recorded as failed and its reservation is cancelled. The key is consumed: send under a new `Idempotency-Key`. Until the first reservation is released, you may get `PBP-0300`. While the provider refuses these calls or they cannot be authenticated, every new attempt gets `PBP-0211` until an operator restores access.
            - `PBP-0015`: the provider's check of the slip gave no usable answer. Nothing was created. The key is released: resend under the same key.
            - `PBP-0008`: a dependency (authentication, storage or the provider route) is unavailable. Nothing was processed. Retry under the same `Idempotency-Key`.
            - `PBP-0206`: the records that identify the funding account owner (payer) could not be reached. No payment was created. Retry. If a resend under the same key returns `PBP-0002`, use a new key. If a new key returns this code again, contact support.
            - `PBP-0706`: the ledger account set as the provider's counterparty cannot be used. Nothing was reserved, sent or paid. The answer is stored under this key. Once the counterparty is fixed, send under a new `Idempotency-Key`. A payment the first request created may read `UNCONFIRMED` until it ends `FAILED`. It is never sent or paid.
            - `PBP-0301`: the funds could not be reserved, or the payment could not be recorded, before the provider was instructed. Nothing was sent or paid. Once the cause is fixed, send under a new `Idempotency-Key` and never reuse the old one. Find a payment the first request may have created with `GET /v1/payments?idempotencyKey=`. It reads `UNCONFIRMED` until it ends `FAILED`, and it is never paid. Until its reservation is released, the request under the new key may get `PBP-0300`.
            - `PBP-0704`: the routed provider is not installed on this deployment or not connected to the tenant. Nothing was written and no provider was called.
      security:
        - BearerAuth: []
      summary: Initiate a payment
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/initiate-a-payment
  /v1/payments/antifraud/resolve:
    post:
      operationId: resolveAntifraudAnalysis
      summary: Apply the antifraud final decision
      description: |-
        Applies the final decision of the client's antifraud partner on a payment it sent to review (`REVIEW`). The partner calls it, not the payer.

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

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

        **How it works**

        - It follows the Lerian antifraud resolve contract (v1), shared with the other Lerian transactional plugins. The body is `AntifraudResolveRequest`.
        - Only the partner's machine credential can call it: an application the tenant lists as its antifraud partner, with the `antifraud-partner` role. `editor` users and the client's own applications get `403`.
        - Requires the `payments` x `resolve` permission, held only by the `antifraud-partner` role.
        - The partner application gets `403` on every other route. It never creates, cancels or reads a payment.
        - No `X-Organization-Id`: the analysis is found by `analysisId` in the token's tenant.
        - `X-Idempotency` is `<analysisId>:<decision>`. The same key returns the first outcome. Repeat a `5xx` under the same key.
        - `ALLOW`: the slip is consulted again with the stored data, and the capability and limit checks run again. If accepted, the payment moves to `UNCONFIRMED` with the amount of the new consult (the informed amount, when one was stored) and follows the normal payment flow. If refused, it ends `REJECTED` with the consult's reason.
        - `DENY`: the payment ends `REJECTED` with `ANTIFRAUD_DENIED`.
        - Both send `PAYMENT_REJECTED` when the payment ends `REJECTED`. The outcome later goes back to the partner as feedback.
        - Lerian sets up the tenant's antifraud (on or off, the partner's credential and address, the review window) and the partner's applications at onboarding. No client endpoint reads or changes them.
      parameters:
        - name: X-Idempotency
          in: header
          required: true
          description: Raw `<analysisId>:<decision>`, as the library contract defines. The same key replays the first outcome.
          schema:
            type: string
            pattern: ^[\x21-\x7E]{1,128}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AntifraudResolveRequest'
      responses:
        '200':
          description: OK. The decision was applied, whatever happened to the payment. Read the outcome on the payment. On `ALLOW`, if the source no longer accepts the informed amount, the payment ends `REJECTED` with `PBP-0217`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: X-Idempotency is missing or malformed.
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0012`: `X-Idempotency` is missing or malformed.
        '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 `payments` x `resolve` permission. It is held only by the listed antifraud partner application.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Analysis not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: No antifraud analysis with this analysisId.
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: no analysis with this `analysisId` in the token's tenant.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemWithI13Extensions'
              examples:
                PBP-0214:
                  summary: 'PBP-0214: Analysis already closed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0214
                    title: ANTIFRAUD_ANALYSIS_CLOSED
                    status: 409
                    detail: The antifraud analysis is already closed.
                    code: PBP-0214
                    currentStatus: REJECTED
                PBP-0215:
                  summary: 'PBP-0215: Review window ended'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0215
                    title: ANTIFRAUD_REVIEW_EXPIRED
                    status: 409
                    detail: The review window of this analysis has ended.
                    code: PBP-0215
          description: |-
            Conflict. Final. Do not repeat.

            - `PBP-0214`: the analysis is already closed: a final decision was applied before, or it expired. `currentStatus` names the payment's status. A concurrent decision under another key also gets this code.
            - `PBP-0215`: the review window ended (`antifraud.reviewExpiresAt` passed). The payment ends `REJECTED` with `ANTIFRAUD_REVIEW_EXPIRED`.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0219:
                  summary: 'PBP-0219: Invalid resolve body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0219
                    title: ANTIFRAUD_RESOLVE_INVALID
                    status: 422
                    detail: The body does not follow the antifraud resolve contract.
                    code: PBP-0219
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  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.

            - `PBP-0219`: the body breaks the resolve contract. Only `analysisId`, `decision` and the body size (16 KiB) can cause it.
            - `PBP-0013`: this `X-Idempotency` was already used with a different body. A repeat must be byte-identical. A `422` after a `5xx` on the same key means the earlier outcome was not recorded: do not repeat.

            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.

            - `PBP-0002`: an unexpected failure. Repeat under the same `X-Idempotency`.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0015:
                  summary: 'PBP-0015: Consult unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: Provider Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0015
                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. Repeat with the same `X-Idempotency`.

            - `PBP-0015`: on `ALLOW`, the new consult of the slip gave no usable answer. Nothing changed: the payment stays `PENDING_APPROVAL` until it is decided or expires.
            - `PBP-0008`: a dependency (authentication or storage) is unavailable, or a request with the same `X-Idempotency` is still running. In that case the answer has `Retry-After`: wait, then repeat with the same key.
          headers:
            Retry-After:
              description: Seconds to wait before repeating with the same X-Idempotency. Sent on the in-flight answer.
              schema:
                type: integer
                minimum: 1
                examples:
                  - 1
      security:
        - BearerAuth: []
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/apply-the-antifraud-final-decision
  /v1/payments/consult:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Consults a bill by its digitable line without paying it. It returns the source's view of the amount, the dates and who receives the money.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The line goes in the body because it is sensitive. Nothing is created or changed. There is no `Idempotency-Key`, and repeating is safe.
        - The line must be 47 digits (bank slip) or 48 digits starting with 8 (utilities bill), digits only. It is never normalized.
        - A line in the wrong form, or with wrong check digits, is refused before it reaches the source.
        - Every answer member is always present. A member the segment does not report is `null`.
        - A bank slip reports payability, face value, fine, interest, discount, due and limit dates, the beneficiary and the receiving bank.
        - A utilities bill reports the assignor, its segment, the state, the payment window and a settlement date (not a due date).
        - Requires the `payments/create` permission, the same as paying: consulting is the first step of paying.
        - The tenant and the provider credential come from the token. `X-Organization-Id` is required and must be a UUID, but it does not scope the consult.
        - The rate limit is per client and user of the token: 100 consults per 60 seconds to start, counted per replica. Payments are not affected.
      operationId: consultBill
      parameters:
        - description: 'Midaz organization of the caller. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. The organization is validated and does not scope the consult: the tenant and the provider credential come from the token.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization of the caller. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. The organization is validated and does not scope the consult: the tenant and the provider credential come from the token.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConsultBillRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConsultBillResponse'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                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
          description: |-
            Bad Request.

            - `PBP-0001`: the line is not 47 digits, nor 48 digits starting with 8 (for example a 44-digit barcode, a letter, a space or a hyphen), or the body is missing, is not JSON, or has a member not accepted. The refusal never echoes the line.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a 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, does not identify a tenant, or has no `sub`. 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 `payments/create` permission.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0110:
                  summary: 'PBP-0110: Bill not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0110
                    title: Bill Not Found
                    status: 404
                    detail: The payment slip was not found at its source.
                    code: PBP-0110
          description: |-
            Not Found.

            - `PBP-0110`: the source has no bank slip for this line. For a utilities line the source does not know, see `PBP-0111`.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0100:
                  summary: 'PBP-0100: Wrong check digits'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0100
                    title: Invalid FEBRABAN Checksum
                    status: 422
                    detail: invalid checksum for field 1
                    code: PBP-0100
                PBP-0111:
                  summary: 'PBP-0111: Source refused the line'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0111
                    title: Bill Refused By Source
                    status: 422
                    detail: The payment slip was refused by its source (provider code 123).
                    code: PBP-0111
                    providerCode: '123'
                PBP-0017:
                  summary: 'PBP-0017: Provider not connected'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: The payment provider is not connected for this tenant.
                    code: PBP-0017
                PBP-0700:
                  summary: 'PBP-0700: No provider on the route'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0700
                    title: PROVIDER_ROUTE_NOT_CONFIGURED
                    status: 422
                    detail: No provider is configured for BANKSLIP_PAYMENT operations of this tenant, so nothing was recorded and no provider was called.
                    code: PBP-0700
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: The provider that serves this operation does not support OPERATION_BANKSLIP_PAYMENT, so nothing was recorded and the provider was not called.
                    code: PBP-0701
                    capability: OPERATION_BANKSLIP_PAYMENT
          description: |-
            Unprocessable Entity. The line is well formed but cannot be consulted.

            - `PBP-0100`: the line's check digits do not match. Check the line.
            - `PBP-0111`: the source refused the line with a reason of its own, in `providerCode` when the source names one. For a utilities bill, this includes a line the source does not know.
            - `PBP-0017`: the tenant has no connection to the payment provider.
            - `PBP-0700`: the tenant's provider route has no provider for `BANKSLIP_PAYMENT` or `BARCODE_BILL_PAYMENT`. Nothing was written and no provider was called.
            - `PBP-0701`: the routed provider does not declare a capability this request needs. The `capability` member names it: `OPERATION_BANKSLIP_PAYMENT`, `OPERATION_BARCODE_BILL_PAYMENT`, `PAYMENT_SEGMENT_BANKSLIP` or `PAYMENT_SEGMENT_UTILITIES`. Nothing was written and no provider was called.

            See the [error list](/en/reference/interfaces/payments-btg/payments-error-list) for every code.
        '429':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0112:
                  summary: 'PBP-0112: Rate limit exceeded'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0112
                    title: Consult Rate Limit Exceeded
                    status: 429
                    detail: The consult rate limit for this caller was exceeded. Payments are not affected.
                    code: PBP-0112
          description: |-
            Too Many Requests. Every consult that passes authentication counts, including one the schema refuses. A token without `sub` gets `401` `PBP-0003`. The per-replica count makes this an enumeration barrier, not a guaranteed global quota. The headers `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` describe the current window.

            - `PBP-0112`: the consult rate limit for this caller was exceeded. Wait for `Retry-After` seconds. Payments are not affected.
          headers:
            Retry-After:
              description: 'Seconds to wait before retrying: the time left in the limiter''s window for this key, a whole number of at least 1.'
              schema:
                minimum: 1
                type: integer
            X-RateLimit-Limit:
              description: The limit of the current window for the `(tenantId, sub)` key.
              schema:
                minimum: 0
                type: integer
            X-RateLimit-Remaining:
              description: Consults left in the current window.
              schema:
                minimum: 0
                type: integer
            X-RateLimit-Reset:
              description: Seconds until the current window resets, a whole number of at least 1.
              schema:
                minimum: 1
                type: integer
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '502':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0113:
                  summary: 'PBP-0113: Unusable source answer'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0113
                    title: Provider Unexpected Response
                    status: 502
                    detail: internal error
                    code: PBP-0113
          description: |-
            Bad Gateway.

            - `PBP-0113`: the source answered in a way that cannot be used. Retrying the same line is unlikely to help.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0114:
                  summary: 'PBP-0114: Bill source unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0114
                    title: Bill Source Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0114
                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
                PBP-0704:
                  summary: 'PBP-0704: Provider not available'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable.

            - `PBP-0114`: the bill source is temporarily unavailable: it did not answer, calls to it are suspended after failures, the provider is limiting requests, or the tenant's provider credential cannot be used. Retry. When the answer has `Retry-After`, wait that long first.
            - `PBP-0008`: a dependency (authentication, storage or the provider route) is unavailable. Nothing was processed. Retry.
            - `PBP-0704`: the routed provider is not installed on this deployment or not connected to the tenant. Nothing was written and no provider was called.
          headers:
            Retry-After:
              description: Seconds to wait before retrying, a whole number of at least 1. Present when the provider limited the request or payments to it are suspended; absent when the source named no wait.
              schema:
                minimum: 1
                type: integer
      security:
        - BearerAuth: []
      summary: Consult a bill by digitable line
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/consult-a-bill-by-digitable-line
  /v1/payments/darf:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Pays a DARF (federal tax) through the provider the tenant routes `DARF_PAYMENT` to.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The taxpayer is always the registered owner of the funding account (`midazAccountId`). Do not send `personType`, `taxId` or `name`.
        - The owner's name must fit the 80 bytes a DARF accepts (accented characters use more than one byte). It is never shortened.
        - Funds are reserved in the ledger before the provider is instructed.
        - `201`: the provider acknowledged the payment (status `CREATED`). `202`: the outcome is not known (status `UNCONFIRMED`). Follow both with `GET /v1/payments/{id}`.
        - After a `202`, do not resend under a new `Idempotency-Key`: you can pay the tax twice.
        - A retry under the same `Idempotency-Key` returns the stored answer of a `201`, a `202`, or a refusal that consumes the key (see each code). After a refusal that releases the key, the same key runs the request again. While the first request runs, the same key gets `409` `PBP-0007`.
        - To find what a request created when you have no payment id, call `GET /v1/payments` with `idempotencyKey`.

        **Planned changes**

        - An antifraud step, with new outcomes on `202`, `422` and `503`.
        - Payment scheduling: a future `scheduledDate` is sent to the provider on its effective date (first business day on or after it), once. Adds `scheduledDate` (DARF too), `effectiveScheduledDate`, `effectiveAfterDueDate`, `amountIsEstimated`, `executedAt`, `failureReason`, the `PROCESSING` status and new error codes. This change will be specified again before it applies.
      operationId: initiateDARFPayment
      parameters:
        - description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the account and the ledger entry live under. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025.'
            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.'
          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.'
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateDARFPaymentRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitiateDARFPaymentResponse'
          description: 'Created. The provider acknowledged the DARF payment. It is `CREATED` and has `providerId`. Follow its outcome with `GET /v1/payments/{id}`. A key that already names an acknowledged payment also returns `201`, with the payment as it stands, in whatever status it has reached.'
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitiateDARFPaymentResponse'
          description: 'Accepted. The payment was created and sent, but the outcome is not known. It is `UNCONFIRMED`, with no `providerId`, and its funds stay reserved. Do not resend under a new `Idempotency-Key`. A resend under the same key is safe: for up to 48 hours it returns this same `202`, even after the payment has resolved. Read the current status with `GET /v1/payments/{id}`. A key that names a payment still `UNCONFIRMED` also returns `202`.'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
                PBP-0200:
                  summary: 'PBP-0200: DARF rule not met'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0200
                    title: DARF Validation Error
                    status: 400
                    detail: type must be S or N
                    code: PBP-0200
                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: ledgerId missing'
                  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
                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-0204:
                  summary: 'PBP-0204: Account has no owner'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0204
                    title: Payer Not Registered
                    status: 400
                    detail: The account this payment would be debited from has no registered owner on file, so the payer cannot be established. Register the account's owner, or use an account that has one.
                    code: PBP-0204
          description: |-
            Bad Request. No payment was created and nothing was sent to the provider.

            - `PBP-0001`: the body is missing, is not JSON, fails the schema, has a member not accepted (`personType`, `taxId`, `name`), has a date or amount that cannot be parsed, or has markup in a text field.
            - `PBP-0200`: a DARF rule was not met: `type` other than `S` or `N`, an amount out of range or with more than two decimals, or `treasuryRevenueCode` or `history` too long.
            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0026`: `ledgerId` is missing, blank or is not a UUID.
            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
            - `PBP-0204`: the account in `midazAccountId` has no registered owner, so the taxpayer cannot be established. Register the owner, or use an account that has one.

            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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Account not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: Account not found or not accessible.
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: the funding account was not found or is not accessible. Nothing was created.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0300:
                  summary: 'PBP-0300: Insufficient funds'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0300
                    title: Insufficient Funds
                    status: 422
                    detail: The funding account does not have enough available balance to complete this operation.
                    code: PBP-0300
                PBP-0302:
                  summary: 'PBP-0302: Overdraft limit exceeded'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0302
                    title: Ledger Refused
                    status: 422
                    detail: The ledger declined this operation. It was not completed and will not be retried; resolve the condition on the funding account before submitting a new request.
                    code: PBP-0302
                PBP-0014:
                  summary: 'PBP-0014: Provider refused payment'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0014
                    title: Provider Rejection
                    status: 422
                    detail: The payment was rejected by the provider.
                    code: PBP-0014
                PBP-0212:
                  summary: 'PBP-0212: Outside provider hours'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0212
                    title: Payment Outside Provider Window
                    status: 422
                    detail: 'The payment provider refused this payment because it was sent outside the hours it accepts payments. Nothing was paid. This Idempotency-Key is consumed: resend under a new Idempotency-Key once the provider accepts payments again.'
                    code: PBP-0212
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: The request body or X-Organization-Id does not match the original request for this idempotency key.
                    code: PBP-0013
                PBP-0202:
                  summary: 'PBP-0202: Account validation unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0202
                    title: PAYMENT_VALIDATOR_NOT_CONFIGURED
                    status: 422
                    detail: Account ownership validation is unavailable, so the payment was NOT submitted. Retrying this request unchanged will not clear the condition.
                    code: PBP-0202
                PBP-0017:
                  summary: 'PBP-0017: Provider account unresolved'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0017
                    title: PROVIDER_SETUP_INCOMPLETE
                    status: 422
                    detail: The paying provider account could not be established, so the payment was NOT submitted. Retrying this request unchanged will not clear the condition.
                    code: PBP-0017
                PBP-0205:
                  summary: 'PBP-0205: Owner registration invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0205
                    title: Payer Registration Invalid
                    status: 422
                    detail: The registered owner of the account this payment would be debited from is recorded inconsistently, so the payer cannot be established. Correct the account owner's registration; resubmitting this request unchanged will not resolve it.
                    code: PBP-0205
                PBP-0207:
                  summary: 'PBP-0207: Owner name too long'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0207
                    title: Payer Name Too Long For DARF
                    status: 422
                    detail: The registered owner of the account this payment would be debited from has a name longer than the 80 bytes a DARF can carry, so the payment was NOT submitted.
                    code: PBP-0207
                PBP-0208:
                  summary: 'PBP-0208: Owner document not numeric'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0208
                    title: Payer Document Not Numeric For Provider
                    status: 422
                    detail: The registered owner of the account this payment would be debited from has a tax document that is not all digits, so the payment was NOT submitted.
                    code: PBP-0208
                PBP-0700:
                  summary: 'PBP-0700: No provider on the route'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0700
                    title: PROVIDER_ROUTE_NOT_CONFIGURED
                    status: 422
                    detail: No provider is configured for DARF_PAYMENT operations of this tenant, so nothing was recorded and no provider was called.
                    code: PBP-0700
                PBP-0701:
                  summary: 'PBP-0701: Capability not supported'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: The provider that serves this operation does not support OPERATION_DARF_PAYMENT, so nothing was recorded and the provider was not called.
                    code: PBP-0701
                    capability: OPERATION_DARF_PAYMENT
          description: |-
            Unprocessable Entity.

            - `PBP-0300`: the funding account does not have enough available balance. The payment is recorded as `FAILED`. Nothing was sent or paid. The key is released: resend under the same or a new key once the balance allows.
            - `PBP-0302`: the funds reservation would take the funding account past its overdraft limit. The payment is recorded as `FAILED`. Nothing was sent or paid. The key is released.
            - `PBP-0014`: the provider refused the DARF instruction. Nothing was paid and the reservation is cancelled. The key is consumed: fix the cause and send under a new `Idempotency-Key`.
            - `PBP-0212`: the provider refused the payment because it arrived outside its accepted hours. Nothing was paid. The key is consumed: send under a new `Idempotency-Key` once the provider accepts payments. Until the first reservation is released, you may get `PBP-0300`.
            - `PBP-0013`: the `Idempotency-Key` was already used for a different request (another body, revenue code, reference date, type, amounts, funding account, `X-Organization-Id` or `ledgerId`). Nothing was done. Send under a new key.
            - `PBP-0202`: account validation is not available on this deployment. No payment was created. Contact support.
            - `PBP-0017`: the provider account to pay from could not be established. Nothing was created or sent. A resend does not fix it. Contact support.
            - `PBP-0205`: the funding account owner's registration is inconsistent (invalid CPF or CNPJ, a tax id that contradicts the person type, or more than one owner), so the taxpayer cannot be established. Fix the registration, then resend.
            - `PBP-0207`: the funding account owner's name is longer than the 80 bytes a DARF accepts. It is never shortened. Shorten the registered name, or use an account whose owner's name fits.
            - `PBP-0208`: the funding account owner's tax document is not numeric, for example an alphanumeric CNPJ. The provider accepts only a numeric CPF or CNPJ. No payment was created. Use an account whose owner has a numeric document.
            - `PBP-0700`: the tenant's provider route has no provider for `DARF_PAYMENT`. Nothing was written and no provider was called.
            - `PBP-0701`: the routed provider does not declare a capability this request needs. The `capability` member names it: `OPERATION_DARF_PAYMENT`. Nothing was written and no provider was called.

            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.

            - `PBP-0002`: an unexpected failure. The payment may or may not exist, and in rare cases it may have been sent. A resend under the same key is safe: it gets `409` `PBP-0007` while the first request holds the key, then replays this `500` or runs the request again. Before you send under a new `Idempotency-Key`, look for the payment with `GET /v1/payments?idempotencyKey=`. If one is found, follow it with `GET /v1/payments/{id}` and do not resend. After you switch keys, never resend under the old one: it can run again after five minutes and pay alongside the new one.
        '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
                PBP-0211:
                  summary: 'PBP-0211: Provider did not receive it'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0211
                    title: Payment Not Received By Provider
                    status: 503
                    detail: internal error
                    code: PBP-0211
                PBP-0015:
                  summary: 'PBP-0015: Provider calls suspended'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: Provider Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0015
                PBP-0206:
                  summary: 'PBP-0206: Owner records unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0206
                    title: Owner Registry Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0206
                PBP-0706:
                  summary: 'PBP-0706: Counterparty unusable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0706
                    title: Ledger Counterparty Unusable
                    status: 503
                    detail: internal error
                    code: PBP-0706
                PBP-0301:
                  summary: 'PBP-0301: Funds not reserved'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0301
                    title: Ledger Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0301
                PBP-0704:
                  summary: 'PBP-0704: Provider not available'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0704
                    title: PROVIDER_NOT_INSTALLED
                    status: 503
                    detail: internal error
                    code: PBP-0704
          description: |-
            Service Unavailable. The `detail` is a fixed text.

            - `PBP-0008`: a dependency (authentication, storage or the provider route) is unavailable. Nothing was processed. Retry under the same `Idempotency-Key`.
            - `PBP-0211`: the provider did not receive the instruction. Nothing was paid. The payment is recorded as failed and its reservation is cancelled. The key is consumed: send under a new `Idempotency-Key`. Until the first reservation is released, you may get `PBP-0300`. While the provider refuses these calls or they cannot be authenticated, every new attempt gets `PBP-0211` until an operator restores access.
            - `PBP-0015`: calls to the provider were suspended after repeated failures while the DARF was prepared. Nothing was created. The key is released: resend under the same key once the provider recovers.
            - `PBP-0206`: the records that identify the funding account owner (taxpayer) could not be reached. No payment was created. Retry. If a resend under the same key returns `PBP-0002`, use a new key. If a new key returns this code again, contact support.
            - `PBP-0706`: the ledger account set as the provider's counterparty cannot be used. Nothing was reserved, sent or paid. The answer is stored under this key. Once the counterparty is fixed, send under a new `Idempotency-Key`. A payment the first request created may read `UNCONFIRMED` until it ends `FAILED`. It is never sent or paid.
            - `PBP-0301`: the funds could not be reserved, or the payment could not be recorded, before the provider was instructed. Nothing was sent or paid. Once the cause is fixed, send under a new `Idempotency-Key` and never reuse the old one. Find a payment the first request may have created with `GET /v1/payments?idempotencyKey=`. It reads `UNCONFIRMED` until it ends `FAILED`, and it is never paid. Until its reservation is released, the request under the new key may get `PBP-0300`.
            - `PBP-0704`: the routed provider is not installed on this deployment or not connected to the tenant. Nothing was written and no provider was called.
      security:
        - BearerAuth: []
      summary: Initiate a DARF payment
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/initiate-a-darf-payment
  /v1/payments/{id}:
    get:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Returns one payment by its ID, with full detail, including the DARF fields when they apply.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - `X-Organization-Id` is required. A payment of another organization gets `404`, the same as one that does not exist.

        **Planned changes**

        - Lerian (PCR): boleto payment through Lerian (PCR) is planned. The payment gains `antifraud`, `requestedAmount` and `return`, and the status `RETURNED`.
        - Payment scheduling: a future `scheduledDate` is sent to the provider on its effective date (first business day on or after it), once. Adds `scheduledDate` (DARF too), `effectiveScheduledDate`, `effectiveAfterDueDate`, `amountIsEstimated`, `executedAt`, `failureReason`, the `PROCESSING` status and new error codes. This change will be specified again before it applies.
        - `payee.taxId` (the CPF or CNPJ of the slip's beneficiary) will be masked, as the consult already masks it. Today it is returned in full, even on `FAILED` or `REJECTED` payments.
      operationId: getPayment
      parameters:
        - description: 'Midaz organization the payment belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A payment of another organization is answered 404, exactly as one that does not exist.'
          in: header
          name: X-Organization-Id
          schema:
            description: 'Midaz organization the payment belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A payment of another organization is answered 404, exactly as one that does not exist.'
            type: string
        - description: Payment identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Payment identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetPaymentResponse'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
          description: |-
            Bad Request.

            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
        '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 permission for this operation.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Payment not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: payment with ID 0b9e8c1e-4f6a-4c1d-9b7e-2a3f5d6c7e8f not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: no payment with this ID in the organization of `X-Organization-Id`.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      summary: Get payment by ID
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-payment-by-id
  /v1/payments/{id}/cancel:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Payment cancellation is not available.

        <Info>**Providers:** none. This endpoint answers 501 Not Implemented for every provider.</Info>

        **How it works**

        - Every request that passes authentication and validation gets `501` with `PBP-0203`, even for a payment already cancelled.
        - No cancellation is made and no payment changes.
        - A request refused before that keeps its own `4xx` status and code.
      operationId: cancelPayment
      parameters:
        - description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
          in: header
          name: X-Organization-Id
          schema:
            description: Tenant organization ID. Optional. The organization context is determined by the credentials you authenticate with; this header does not select or change it.
            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.'
          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.'
            type: string
        - description: Payment identifier (UUID).
          in: path
          name: id
          required: true
          schema:
            description: Payment identifier (UUID).
            examples:
              - 123e4567-e89b-12d3-a456-426614174000
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelPaymentRequest'
        required: true
      responses:
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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
          description: |-
            Bad Request.

            - `PBP-0012`: `Idempotency-Key` is missing or is not a UUID.
        '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 permission for this operation.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0007`: an earlier request under the same `Idempotency-Key` is still running. Retry under the same key after a short wait: this code lasts at most five minutes after the first request arrived. After that, the same key returns the stored answer, `500` `PBP-0002` when that answer cannot be replayed, or, when no answer was kept, runs the request again. Do not switch keys: the earlier request can still take effect.
        '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.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity.
        '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.

            - `PBP-0002`: an unexpected failure. Nothing was cancelled: this endpoint changes no payment.
        '501':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0203:
                  summary: 'PBP-0203: Cancellation not available'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0203
                    title: Not Implemented
                    status: 501
                    detail: Payment cancellation is not implemented in this version of the API. No cancellation was attempted and the payment was not changed. Retrying this request will not help.
                    code: PBP-0203
          description: |-
            Not Implemented.

            - `PBP-0203`: payment cancellation is not available. The `detail` names the unavailable capability. Nothing changed. Retrying does not help.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry under the same `Idempotency-Key`.
      security:
        - BearerAuth: []
      summary: Cancel a payment
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/cancel-a-payment
  /v1/payments/{id}/receipt:
    get:
      operationId: getPaymentReceipt
      summary: Get a payment receipt
      description: |-
        Returns the receipt of a settled payment, for providers that issue receipts (capability `PAYMENT_RECEIPT`). Today only Lerian (PCR) issues them.

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

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

        **How it works**

        - The receipt has the minimum data of the market rule MAPX-OP084-2019 V19, section 6.20.3.
        - It is recorded once, when the write-off is registered, and never rewritten. Every read returns the same data and the same `authentication`.
        - It stays available for at least 5 years from the payment date, also after a return (`returned: true`).
        - `complete` is `false` while the source does not deliver every mandatory field. `missingFields` names them, and the receipt is still returned.
        - Requires the `payments` x `read` permission, as `GET /v1/payments/{id}`.
        - The receipt has names and tax ids of the payer and the beneficiary. It is never sent in a notice.
      parameters:
        - $ref: '#/components/parameters/OrganizationIdI13'
        - $ref: '#/components/parameters/PaymentId'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentReceipt'
          description: OK.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                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-0001:
                  summary: 'PBP-0001: Request malformed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0001
                    title: Bad Request
                    status: 400
                    detail: validation failed
                    code: PBP-0001
          description: |-
            Bad Request.

            - `PBP-0025`: `X-Organization-Id` is missing or is not a UUID.
            - `PBP-0001`: `id` is not a 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 `payments` x `read` permission on the organization.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Payment not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: payment with ID 0b9e8c1e-4f6a-4c1d-9b7e-2a3f5d6c7e8f not found
                    code: PBP-0005
          description: |-
            Not Found.

            - `PBP-0005`: no payment with this ID in the organization of `X-Organization-Id`.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemWithI13Extensions'
              examples:
                PBP-0218:
                  summary: 'PBP-0218: No receipt'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0218
                    title: RECEIPT_UNAVAILABLE
                    status: 409
                    detail: The payment has no receipt.
                    code: PBP-0218
                    receiptUnavailableReason: PAYMENT_NOT_SETTLED
          description: |-
            Conflict.

            - `PBP-0218`: the payment has no receipt. `receiptUnavailableReason` says why: `PAYMENT_NOT_SETTLED` (the payment is still `UNCONFIRMED`, `CREATED` or `PENDING_APPROVAL`; try again after `PAYMENT_SETTLED`), `PAYMENT_REJECTED`, `PAYMENT_FAILED`, `PAYMENT_CANCELED` (never paid, no receipt will exist) or `PROVIDER_WITHOUT_RECEIPT` (the provider does not issue receipts through this API, such as BTG).
        '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.

            - `PBP-0002`: an unexpected failure. Contact support.
        '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.

            - `PBP-0008`: a dependency (authentication or storage) is unavailable. Nothing was processed. Retry.
      security:
        - BearerAuth: []
      tags:
        - Payments
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
        href: /en/reference/interfaces/payments-pcr/get-a-payment-receipt
webhooks:
  BOLETO_AMENDED:
    post:
      description: |-
        Sent when Payments applies a boleto amendment request, in the same transaction.

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

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

        **How it works**

        - The body carries the amendment id (`amendmentId`), the changes applied, the terms now in effect and when they were applied.
        - A cancellation request can supersede a pending amendment. When that cancellation fails, the amendment resumes and this notice can follow.
        - When the provider undoes a cancellation it had confirmed, this notice comes after the `BOLETO_CANCEL_FAILED` of the same transaction, with a greater `occurredAt`.
        - When the provider refuses a requested cancellation, this notice comes in the same transaction, with a later `occurredAt`. It follows the refusal's `BOLETO_CANCEL_FAILED` when one is sent.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoAmendedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoAmendedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto amendment applied
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto amendment applied
  BOLETO_AMENDMENT_REJECTED:
    post:
      description: |-
        Sent when the provider refuses a boleto amendment request, in the transaction that records the refusal.

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

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

        **How it works**

        - `rejection` carries the reason: a problem document, with the provider's stable reason in `providerReason`.
        - The body also carries the amendment id (`amendmentId`), the requested changes and `rejectedAt`.
        - A cancellation request can supersede a pending amendment. When that cancellation fails, the amendment resumes and can be refused.
        - When the provider undoes a cancellation it had confirmed, this notice comes after the `BOLETO_CANCEL_FAILED` of the same transaction, with a greater `occurredAt`.
        - When the provider refuses a requested cancellation, this notice comes in the same transaction, with a later `occurredAt`. It follows the refusal's `BOLETO_CANCEL_FAILED` when one is sent.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoAmendmentRejectedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoAmendmentRejectedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto amendment refused
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto amendment refused
  BOLETO_BATCH_FINISHED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Sent once per boleto batch, when no item of the batch is still `PENDING`.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Sent in the transaction that marks the batch finished.
        - The entity is the batch (`entityType` `BOLETO_BATCH`). The body carries no boleto members: it has the batch id, its status and the item counts.
        - `occurredAt` is when Payments recorded that the batch finished.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoBatchFinishedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoBatchFinishedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto batch finished
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto batch finished
  BOLETO_CANCELED:
    post:
      description: |-
        Sent once per cancellation, when the boleto becomes `CANCELED`.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Sent when the provider confirms a requested cancellation, at once or later.
        - Also sent when the provider cancels the boleto on its own and reports it.
        - The body carries `canceledAt` and, when there is one, `cancellationReason`.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).

        **Provider differences**

        | | Lerian (PCR) | BTG |
        |---|---|---|
        | Cancellation confirmed | Later, after the request | In the cancellation request, or later when the request was left unanswered |
      operationId: boletoCanceledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoCanceledNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto canceled
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto canceled
  BOLETO_CANCEL_FAILED:
    post:
      description: |-
        Sent when a boleto's cancellation fails after the cancellation request, not in its direct answer, or when the provider undoes a cancellation it had confirmed.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Every case uses the same body. `status` is `CREATED`, and the boleto can still be paid.
        - `rejection` carries the reason when the provider gives one: a problem document, with the provider's stable reason in `providerReason`.
        - Undone cancellation: the provider reverses a cancellation it had confirmed. The boleto returns from `CANCELED` to `CREATED`, and no `BOLETO_CREATED` is sent.
        - In that case, this notice comes before the notices of the amendments the return resumes, with a smaller `occurredAt`.
        - Late refusal: a provider that confirms cancellations later refuses one. The refusal comes from the provider's notice or from Payments asking the provider. This applies whether the provider accepted the request for later confirmation or left it unanswered. The boleto stays `CREATED`.
        - Unanswered request: a provider that confirms cancellations in the request left it unanswered. Payments later checks the boleto at the provider and finds the cancellation failed. The boleto stays `CREATED`.
        - In that last case, `rejection` carries the generic refusal `PBP-0014`, without the provider's own reason.
        - Not sent when the provider refuses in its direct answer to the cancellation request. You get that refusal as the error response of the request.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).

        **Provider differences**

        | | Lerian (PCR) | BTG |
        |---|---|---|
        | Cancellation outcome | Decided later | Decided in the request |
        | Case that sends this notice | Late refusal | Undone cancellation; unanswered request found failed |
      operationId: boletoCancelFailedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoCancelFailedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto cancellation failed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto cancellation failed
  BOLETO_CREATED:
    post:
      description: |-
        Sent when the boleto's registration is confirmed and the boleto becomes `CREATED`.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Sent only when that write applied.
        - This is the notice of a registered boleto. There is no `BOLETO_REGISTERED`.
        - Not sent for a boleto that leaves `PENDING` for a final status without passing through `CREATED`.
        - Not sent when a canceled boleto returns to `CREATED` after a failed cancellation. That case sends `BOLETO_CANCEL_FAILED`.
        - The body carries the boleto's charges and terms, each only when the boleto has it.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoCreatedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoCreatedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto registered
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto registered
  BOLETO_EXCESS_PAYMENT:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Sent when a hybrid boleto already `SETTLED` receives a payment through its other leg, and Payments records that payment.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - Sent at most once per leg.
        - It moves no money.
        - Hybrid boleto issuance is not available. This notice is only sent for hybrid boletos issued before.
        - The body carries the excess payment in `excessPayment`.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoExcessPaymentEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoExcessPaymentNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Excess payment on a hybrid boleto
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Excess payment on a hybrid boleto
  BOLETO_FAILED:
    post:
      description: |-
        Sent when the boleto becomes `FAILED`, whatever the path: issuance, batch sending, checking with the provider or installment recovery.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Sent only when that write applied.
        - The body carries the failure code (`errorCode`) when there is one.
        - When the provider refused the boleto with a reason from its catalog, `providerReason` carries the stable reason.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoFailedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoFailedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto failed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto failed
  BOLETO_INACTIVATED:
    post:
      description: |-
        Sent when the boleto's payment period ends without payment and the boleto becomes `INACTIVATED`.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Sent in the transaction that records `INACTIVATED`.
        - The body carries `inactivatedAt`.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoInactivatedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoInactivatedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto written off
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto written off
  BOLETO_OVERDUE:
    post:
      description: |-
        Sent once per boleto when it passes its effective due date without being paid. The effective due date is the due date moved to a business day.

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

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

        **How it works**

        - Not sent when, by the time the notice is recorded, the boleto's collections title is no longer registered and open. That is, it was paid, canceled, written off or lapsed.
        - It does not change the boleto's status.
        - `providerId` is always present. It is the id of the boleto's collections title.
        - The body carries `dueDate` and `effectiveDueDate`.
        - The same `X-Webhook-Id` identifies the overdue on every delivery. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by it.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
      operationId: boletoOverdueEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoOverdueNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto overdue
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto overdue
  BOLETO_PAID:
    post:
      description: |-
        Sent when a boleto is paid, for every provider, in the transaction that records `SETTLED`. `BOLETO_SETTLED` reports when the credit is available.

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent once per boleto. When a reopened title is paid again, `BOLETO_REOPENED_PAID_AGAIN` is sent instead.
        - `settlement` shows the stage at payment, with cycle 1, even when a later stage was already recorded.
        - Lerian (PCR): if a later stage was recorded before the boleto became `SETTLED`, its notices follow this one in the same transaction.
        - Those notices keep the order of the normal flow: `BOLETO_SETTLED`, `BOLETO_SETTLEMENT_REVERSED`, `BOLETO_SETTLEMENT_CHARGED_BACK`. The sequence does not depend on the order in which the facts arrived.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).

        **Provider differences**

        | | Lerian (PCR) | BTG |
        |---|---|---|
        | Settlement mode | HELD: the credit is held until release | DIRECT: the credit is available at payment |
        | Stage in this notice | PENDING_RELEASE, cycle 1 | RELEASED, cycle 1 |
        | BOLETO_SETTLED | Sent later, on release | Sent in the same transaction, after this notice |
      operationId: boletoPaidEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoPaidNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto paid
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto paid
  BOLETO_PAYMENT_BLOCKED:
    post:
      description: |-
        Sent when the boleto's payment is blocked.

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

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

        **How it works**

        - It does not carry the reason of the block and does not change the boleto's status.
        - `providerId` is always present. It is the id of the boleto's collections title.
        - It can arrive after the unblock. Order by `occurredAt`. In a tie, read the title with `GET /v1/collections/titles/{title_id}`, using `providerId`, and check its `blockState`.
        - Not sent when an unblock of the boleto with a later `occurredAt` is already recorded for delivery, whatever its delivery status.
        - The body carries `blockedAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoPaymentBlockedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoPaymentBlockedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto payment blocked
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto payment blocked
  BOLETO_PAYMENT_UNBLOCKED:
    post:
      description: |-
        Sent when the boleto's payment is unblocked.

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

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

        **How it works**

        - It does not change the boleto's status.
        - `providerId` is always present. It is the id of the boleto's collections title.
        - It can arrive before the block. Order by `occurredAt`. In a tie, read the title with `GET /v1/collections/titles/{title_id}`, using `providerId`, and check its `blockState`.
        - The body carries `unblockedAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoPaymentUnblockedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoPaymentUnblockedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto payment unblocked
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto payment unblocked
  BOLETO_REOPENED_FROM_CANCELED:
    post:
      description: |-
        Sent when the registry base reopens a canceled title (`CANCELLED` to `OPEN`).

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that records the reopening.
        - A `CANCELED` boleto moves back to `CREATED`. It can be paid again, and `canceledAt` is cleared.
        - A `SETTLED` boleto whose reopened paid title had been canceled stays `SETTLED`. The body then carries `settlement`.
        - No `BOLETO_CREATED` or `BOLETO_CANCEL_FAILED` is sent for it.
        - `reopenedAt` is when the base reopened the title, as the collections module reported it.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoReopenedFromCanceledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoReopenedFromCanceledNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Canceled title reopened at the base
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Canceled title reopened at the base
  BOLETO_REOPENED_FROM_PAID:
    post:
      description: |-
        Sent when the registry base reopens a paid title (`PAID` to `OPEN`).

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that records the reopening.
        - `status` stays `SETTLED`, and `baseSituation` becomes `OPEN`.
        - `settlement` shows what happened to the credit so far: `REVERSED` before release, or `CHARGEBACK_PENDING` or `CHARGED_BACK` after it.
        - `reopenedAt` is when the base reopened the title, as the collections module reported it.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoReopenedFromPaidEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoReopenedFromPaidNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Paid title reopened at the base
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Paid title reopened at the base
  BOLETO_REOPENED_PAID_AGAIN:
    post:
      description: |-
        Sent when a paid title that the registry base had reopened is paid again (`OPEN` to `PAID`). The boleto is `SETTLED`.

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - The new payment opens a new payment cycle. `status` stays `SETTLED`, and no `BOLETO_PAID` or `BOLETO_SETTLED` is sent at this point.
        - The new settlement starts at `PENDING_RELEASE`, with `settlement.cycle` increased by 1.
        - The stage notices are sent again in the new cycle, once each. The release sends `BOLETO_SETTLED`. A reversal or a charge-back sends `BOLETO_SETTLEMENT_REVERSED` or `BOLETO_SETTLEMENT_CHARGED_BACK`.
        - `settlement` shows the new cycle when its settlement is already recorded. Otherwise it shows the final stage of the previous cycle.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoReopenedPaidAgainEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoReopenedPaidAgainNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Reopened paid title paid again at the base
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Reopened paid title paid again at the base
  BOLETO_REOPENED_TITLE_CANCELED:
    post:
      description: |-
        Sent when a paid title that the registry base had reopened is then canceled (`OPEN` to `CANCELLED`).

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that records the change.
        - `status` stays `SETTLED`, and no `BOLETO_CANCELED` is sent.
        - `settlement` shows the stage of the credit, which moves on its own. A reversal or charge-back that comes later sends its own notice.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoReopenedTitleCanceledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoReopenedTitleCanceledNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Reopened paid title canceled at the base
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Reopened paid title canceled at the base
  BOLETO_REOPENED_TITLE_LAPSED:
    post:
      description: |-
        Sent when a paid title that the registry base had reopened then lapses past its payment deadline (`OPEN` to `LAPSED`).

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that records the change.
        - `status` stays `SETTLED`, and no `BOLETO_INACTIVATED` is sent.
        - `settlement` shows the stage of the credit, which moves on its own. A reversal or charge-back that comes later sends its own notice.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoReopenedTitleLapsedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoReopenedTitleLapsedNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Reopened paid title lapsed at the base
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Reopened paid title lapsed at the base
  BOLETO_REVERSED:
    post:
      description: |-
        Sent when a `PENDING` or `CREATED` boleto that is not hybrid becomes `REVERSED`: the payment was returned to the payer.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - Payments records it after reading the boleto at the provider confirms the return.
        - A reversal on a `SETTLED` or hybrid boleto is not recorded and not notified.
        - The body carries `reversedAt`.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoReversedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoReversedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment returned to the payer
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment returned to the payer
  BOLETO_SETTLED:
    post:
      description: |-
        Sent when the boleto is paid and Payments records the payment, in the transaction that makes the boleto `SETTLED`.

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

        <Warning>**Lerian (PCR): under development.** The Lerian provider can change before it is released. BTG is available.</Warning>

        **How it works**

        - The body carries the amount paid (`settledAmount`), when it was paid (`settledAt`) and the leg it was paid through (`paidVia`).
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).

        **Planned changes**

        - The body gains `settlement`: mode, stage and payment cycle. The notice is sent when the credit is available.
        - BTG: sent when the boleto becomes `SETTLED`, as today.
        - Lerian (PCR): sent when the release of the credit is recorded. If the release was recorded first, sent when the boleto becomes `SETTLED`.
        - Sent once per payment cycle (`settlement.cycle`).
      operationId: boletoSettledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoSettledNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto settled
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto settled
  BOLETO_SETTLEMENT_CHARGED_BACK:
    post:
      description: |-
        Sent when a credit already released for a `SETTLED` boleto is charged back, that is, debited back from the account.

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that records `CHARGED_BACK`. That is always after the release, so after `BOLETO_SETTLED`.
        - If the charge-back was recorded before the boleto became `SETTLED`, it is sent in the transaction that records `SETTLED`, after `BOLETO_PAID` and `BOLETO_SETTLED`.
        - `CHARGEBACK_PENDING` sends nothing.
        - Sent at most once per payment cycle. Identify it by the boleto and `settlement.cycle`.
        - The body has `status` `SETTLED` and `settlement` in state `CHARGED_BACK`, with `chargedBackAt`.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoSettlementChargedBackEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoSettlementStageNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Released credit charged back
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Released credit charged back
  BOLETO_SETTLEMENT_REVERSED:
    post:
      description: |-
        Sent when a held settlement is undone before release. Nothing was ever credited to the account.

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that records `REVERSED` for a `SETTLED` boleto.
        - If the reversal was recorded before the boleto became `SETTLED`, it is sent in the transaction that records `SETTLED`, right after `BOLETO_PAID`.
        - The boleto got `BOLETO_PAID` and never gets `BOLETO_SETTLED` in that payment cycle.
        - Sent at most once per payment cycle. Identify it by the boleto and `settlement.cycle`.
        - The body has `status` `SETTLED` and `settlement` in state `REVERSED`, with `reversedAt`.
        - Not related to `BOLETO_REVERSED`, in which the payment was returned to the payer before settlement.
        - Delivery order is not guaranteed. Order a boleto's notices by `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: boletoSettlementReversedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BoletoSettlementStageNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Held settlement reversed before release
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Held settlement reversed before release
  CNAB_RETURN_AVAILABLE:
    post:
      description: |-
        Sent once per CNAB 240 return file, when Payments generates the file and stores it. The file can come from a scheduled cut or an on-demand cut.

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

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

        **How it works**

        - A cut with nothing to report generates no file and sends nothing.
        - The entity is the return (`entityType` `CNAB_RETURN`).
        - The body carries the return id, its CNAB agreement and agreement code, and its NSA.
        - It also carries the number of movements, how the file was cut and when it was generated.
        - The body carries no personal data. That data is only inside the file.
        - The file stays available through `GET /v1/cnab/returns`.
        - The same `X-Webhook-Id` identifies the notice on every delivery. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by it.
      operationId: cnabReturnAvailableEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CnabReturnAvailableNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: CNAB return file available
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: CNAB return file available
  ELECTRONIC_PAYER_EXCLUDED:
    post:
      description: |-
        Sent when the electronic payer adhesion ends for this organization.

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

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

        **How it works**

        - The end can come from a request through this API, from the closing of the account (`origin` `ACCOUNT_CLOSURE`) or from another institution (`OTHER_INSTITUTION`).
        - When one organization excludes its adhesion and another keeps adhered accounts, only the calling organization receives this type. The others receive `ELECTRONIC_PAYER_UPDATED`.
        - Afterwards, the organization no longer sees the payer.
        - The body carries `excludedAt`.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerExcludedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Electronic payer excluded
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Electronic payer excluded
  ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED:
    post:
      description: |-
        Sent once per load, when the load of the open boletos presented to the payer ends.

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

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

        **How it works**

        - A load runs after the adhesion. It also runs after an aggregate with no previous adhesion at the institution is included; the body then carries `aggregateId`.
        - The body carries `completedAt`, `boletoCount` and `syncCursor`, the initial cursor of the list of presented boletos.
        - The boletos of the load do not send `RECEIVER_BOLETO_NOTICED`.
        - Only providers that declare the initial load event send it. With other providers, the boletos of the load arrive as `RECEIVER_BOLETO_NOTICED`.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.
        - This notice does not change the payer. It carries the current `version` and is not discarded by version.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerInitialLoadCompletedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Initial load of presented boletos completed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Initial load of presented boletos completed
  ELECTRONIC_PAYER_REGISTERED:
    post:
      description: |-
        Sent when the customer's adhesion to the electronic presentment of boletos is confirmed.

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

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

        **How it works**

        - The adhesion was requested through this API (`origin` `API`) or came from a bulk load (`origin` `BULK_LOAD`).
        - The body carries `registeredAt` and, when it answers a request of this API, its `requestId`.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerRegisteredEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Electronic payer registered
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Electronic payer registered
  ELECTRONIC_PAYER_REJECTED:
    post:
      description: |-
        Sent when the electronic payer adhesion is refused.

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

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

        **How it works**

        - The body carries `rejectedAt` and `rejection`, with the provider's original code in `providerReason` and a stable category.
        - It changes the payer's state and follows the version rule below.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerRejectedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Electronic payer adhesion refused
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Electronic payer adhesion refused
  ELECTRONIC_PAYER_THIRD_PARTY_CHANGED:
    post:
      description: |-
        Sent when an authorized third party is included in or removed from a boleto of the payer, also when another institution made the change.

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

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

        **How it works**

        - The body carries `changedAt`.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerThirdPartyChangedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Authorized third party changed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Authorized third party changed
  ELECTRONIC_PAYER_THIRD_PARTY_REJECTED:
    post:
      description: |-
        Sent when the inclusion or removal of an authorized third party is refused.

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

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

        **How it works**

        - The body carries `rejectedAt`, `rejection` and the `requestId` of the request.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.
        - This notice does not change the payer. It carries the current `version` and is not discarded by version.
        - Recognize a repeated refusal by `requestId`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerThirdPartyRejectedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Authorized third party change refused
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Authorized third party change refused
  ELECTRONIC_PAYER_UPDATED:
    post:
      description: |-
        Sent when a change to the electronic payer adhesion is confirmed: accounts or aggregates included or removed.

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

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

        **How it works**

        - Also sent to the other organizations when one organization excludes its adhesion and they keep adhered accounts.
        - The body carries `updatedAt`.
        - Aggregates have no notice types of their own. Read the payer to see them.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerUpdatedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Electronic payer updated
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Electronic payer updated
  ELECTRONIC_PAYER_UPDATE_REJECTED:
    post:
      description: |-
        Sent when a change to the electronic payer adhesion is refused.

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

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

        **How it works**

        - This includes the refusal of an exclusion requested through this API: removal of the organization's accounts or exclusion of the adhesion.
        - The body carries `rejectedAt`, `rejection` and the `requestId` of the request.
        - One notice goes to each organization with an adhered account of the payer. Each has its own `organizationId` and `X-Webhook-Id`, and all share the same `sourceFactId`.
        - Apply a notice only when its `version` is greater than the last one applied for the same `organizationId` and `electronicPayerId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the electronic payers (`GET /v1/electronic-payers`) with `changedSince`.
        - The body carries no personal data. Read the payer with `GET /v1/electronic-payers/{electronicPayerId}`.
        - This notice does not change the payer. It carries the current `version` and is not discarded by version.
        - Recognize a repeated refusal by `requestId`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: electronicPayerUpdateRejectedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPayerNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Electronic payer change refused
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Electronic payer change refused
  PAYMENT_CANCELED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Sent when a payment is canceled, in the transaction that records `CANCELED`.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The body carries `canceledAt`.
        - Payment notices carry no `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: paymentCanceledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment canceled
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment canceled
  PAYMENT_FAILED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Sent when a payment fails, in the transaction that records `FAILED`.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The body carries `failedAt` and `errorMessage`.
        - Payment notices carry no `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: paymentFailedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment failed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment failed
  PAYMENT_REJECTED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Sent when a payment is rejected, in the transaction that records `REJECTED`.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The body carries `rejectedAt` and `rejectionReason`.
        - Payment notices carry no `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).

        **Planned changes**

        - More cases will send it: a final antifraud `DENY`, the end of the review window, and a refused consult after a final `ALLOW`.
        - Later, a write-off refused by the clearing base, or a withdrawn write-off, will also send it.
        - Each case sets `rejectionReason`. The body does not change.
        - These cases also apply to Lerian (PCR), so both providers will send this event.
      operationId: paymentRejectedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment rejected
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment rejected
  PAYMENT_RETURNED:
    post:
      description: |-
        Sent when a settled payment is returned and the amount goes back to the funding account.

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent in the transaction that moves the payment from `SETTLED` to `RETURNED` and schedules the return posting in the ledger.
        - Sent when the amount goes back to the funding account, not when the issuing institution's notice arrives.
        - The body carries `returnedAmount`, `returnedAt`, `returnReason` (the reason the issuing institution gave) and `settledAmount`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: paymentReturnedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentReturnedNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment returned
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment returned
  PAYMENT_SCHEDULED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Not sent. You can enable the type in `enabledEvents`, but no notice of this type is sent today.

        <Info>**Providers:** none. This event is not sent.</Info>

        **How it works**

        - Enabling it delivers nothing.
      operationId: paymentScheduledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotEmittedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment scheduled (not sent)
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment scheduled (not sent)
  PAYMENT_SETTLED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Sent when a payment is settled, in the transaction that records `SETTLED`.

        <Info>**Providers:** BTG.</Info>

        **How it works**

        - The body carries `settledAmount` and `settledAt`.
        - Payment notices carry no `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: paymentSettledEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment settled
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment settled
  PAYMENT_UNDER_REVIEW:
    post:
      description: |-
        Sent when a payment is held for review: the antifraud answered `REVIEW`, and Payments records the payment in `PENDING_APPROVAL` with the analysis.

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

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

        **How it works**

        - Opt-in: enable the type in `enabledEvents`. A configuration that does not enable it receives nothing new.
        - Sent once per payment. A retry under the same `Idempotency-Key` answers from the recorded payment and sends nothing.
        - The body carries `analysisId` and `reviewExpiresAt`. `amount` is the amount of the consult made at initiation.
        - The body does not carry the partner's reasons or score. They stay in the analysis, for audit only.
        - The outcome uses existing notices. A final `ALLOW` moves the payment to `UNCONFIRMED` and the usual flow, with its usual notices.
        - These end the payment `REJECTED` and send `PAYMENT_REJECTED`: a final `DENY`, the end of the review window, or a refused consult after a final `ALLOW`.
        - Payment notices carry no `occurredAt`.
        - The same notice can arrive more than once. Verify the signature and `X-Webhook-Timestamp`, then discard repeats by `X-Webhook-Id` (equal to `eventId`).
      operationId: paymentUnderReviewEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentUnderReviewNotification'
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Payment under review
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Payment under review
  PIX_KEY_CHANGED:
    post:
      description: |-
        <Warning>**Under development.** This Payments PCR preview is subject to change. Endpoint descriptions distinguish current behavior from planned changes. Confirm availability with Lerian before integration.</Warning>

        Not sent. You can enable the type in `enabledEvents`, but no notice of this type is sent today.

        <Info>**Providers:** none. This event is not sent.</Info>

        **How it works**

        - Enabling it delivers nothing.
      operationId: pixKeyChangedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PixKeyChangedNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Pix key changed (not sent)
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Pix key changed (not sent)
  RECEIVER_BOLETO_ACCEPTANCE_CHANGED:
    post:
      description: |-
        Sent when an acceptance or a refusal of a presented boleto is recorded, by this or another institution.

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

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

        **How it works**

        - The body carries `changedAt`, `acceptance` and `byThisInstitution`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoAcceptanceChangedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto acceptance changed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto acceptance changed
  RECEIVER_BOLETO_ACCEPTANCE_REJECTED:
    post:
      description: |-
        Sent when a request to accept or refuse a presented boleto is refused.

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

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

        **How it works**

        - The body carries `rejectedAt`, `rejection` and the `requestId` of the request.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.
        - This notice does not change the boleto. It carries the current `version` and is not discarded by version.
        - Recognize a repeated refusal by `requestId`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoAcceptanceRejectedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto acceptance refused
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto acceptance refused
  RECEIVER_BOLETO_LAPSED:
    post:
      description: |-
        Sent when a presented boleto lapses, past its payment deadline.

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

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

        **How it works**

        - The body carries `lapsedAt`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoLapsedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto lapsed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto lapsed
  RECEIVER_BOLETO_NOTICED:
    post:
      description: |-
        Sent when a new boleto is presented to the electronic payer, issued against the customer or one of their aggregates.

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

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

        **How it works**

        - The body carries `noticedAt`, `amount`, `dueDate` and `beneficiaryType`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoNoticedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto presented
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto presented
  RECEIVER_BOLETO_PARTIALLY_PAID:
    post:
      description: |-
        Sent when a presented boleto receives a partial payment that leaves a balance.

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

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

        **How it works**

        - The body carries `paidAt`, `paidAmount` and `remainingAmount`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoPartiallyPaidEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto partially paid
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto partially paid
  RECEIVER_BOLETO_THIRD_PARTY_NOTICED:
    post:
      description: |-
        Sent when a boleto is presented to the customer as an authorized third party.

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

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

        **How it works**

        - The body carries `noticedAt`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoThirdPartyNoticedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Boleto presented to an authorized third party
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Boleto presented to an authorized third party
  RECEIVER_BOLETO_UPDATED:
    post:
      description: |-
        Sent when the issuer changes a presented boleto, including the rights holder, the link to a duplicate and taxes.

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

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

        **How it works**

        - The body carries `updatedAt`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoUpdatedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto updated
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto updated
  RECEIVER_BOLETO_WRITEOFF_REVERSED:
    post:
      description: |-
        Sent when a write-off of a presented boleto is canceled and the boleto reopens.

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

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

        **How it works**

        - The body carries `reversedAt`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoWriteoffReversedEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto write-off reversed
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto write-off reversed
  RECEIVER_BOLETO_WRITTEN_OFF:
    post:
      description: |-
        Sent when a presented boleto is written off: paid at any institution, written off in full or written off in contingency.

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

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

        **How it works**

        - The body carries `writtenOffAt`.
        - One notice goes to each organization with an adhered account of the payer.
        - Apply a notice only when its `version` (the boleto's version) is greater than the last one applied for the same `organizationId` and `receiverBoletoId`. One change yields one notice per organization, all with the same version.
        - Discard repeated deliveries by `X-Webhook-Id`, after you verify the signature and `X-Webhook-Timestamp`.
        - A lost notice is not delivered again. Recover it by listing the presented boletos (`GET /v1/electronic-payers/{electronicPayerId}/boletos`) with `changedSince`.
        - The body carries no document or name of a person. Read the boleto with `GET /v1/electronic-payers/{electronicPayerId}/boletos/{receiverBoletoId}`.

        **Planned changes**

        - The type enters the notice catalog together with the feature that sends it. Until then, `enabledEvents` refuses it with 400 `PBP-0402`.
      operationId: receiverBoletoWrittenOffEvent
      parameters:
        - description: Lowercase hex of HMAC-SHA256 over "<X-Webhook-Timestamp>.<raw body>", keyed with the configuration's secret, without prefix.
          in: header
          name: X-Webhook-Signature
          required: true
          schema:
            pattern: ^[0-9a-f]{64}$
            type: string
        - description: 'When this attempt was sent, in Unix seconds. It changes on every attempt and is part of the signature. After verifying the signature, reject the delivery when this instant differs from the receiver''s clock by more than 5 minutes: a captured delivery cannot be replayed later. It is not when the fact happened: that is occurredAt in the body.'
          in: header
          name: X-Webhook-Timestamp
          required: true
          schema:
            pattern: ^[0-9]+$
            type: string
        - description: Notice type, equal to the event member of the body.
          in: header
          name: X-Webhook-Event
          required: true
          schema:
            $ref: '#/components/schemas/WebhookEventType'
        - description: 'Notice identifier, equal to the eventId member of the body and the same on every delivery attempt of one notice. The same POST can arrive more than once: verify the signature first, with a constant-time comparison, then X-Webhook-Timestamp, and only then discard repetitions by it.'
          in: header
          name: X-Webhook-Id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReceiverBoletoNotice'
        required: true
      responses:
        '2XX':
          description: |-
            Delivery accepted. Any 2XX acknowledges the notice, and the response body is ignored.

            After a 429, a 5XX or a network failure, the notice is delivered again, in at most three attempts in all. After a 3XX or a 4XX, it is not delivered again.
      security: []
      summary: Presented boleto written off
      tags:
        - Notices
      x-mint:
        metadata:
          tag: 🚧 Under development
          icon: person-digging
          title: Presented boleto written off
components:
  schemas:
    ActionRequest:
      additionalProperties: false
      properties:
        reason:
          description: Reason for the action, recorded in the audit trail. Must not carry personal data.
          examples:
            - Notice intake restored after the window.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - reason
      type: object
    ActionResult:
      additionalProperties: false
      properties:
        action:
          description: What the action did.
          enum:
            - RELEASE_WRITE_OFF
            - CANCEL_SCHEDULED_RELEASE
            - UNHOLD_WRITE_OFF
            - REVERSE_WRITE_OFF
            - REPROCESS_CREDIT_ENTRY
            - REPROCESS_PCR_COMMAND
            - CLOSE_PCR_COMMAND
            - SETTLE_SUBMISSION_FAILURE
            - ASSOCIATE_PCR_NOTICE
            - DISCARD_PCR_NOTICE
            - APPLY_PCR_NOTICE
            - WRITE_OFF_LATE_REGISTRATION
            - ENABLE_ACCOUNT
            - CREATE_ENABLEMENT_BATCH
            - APPROVE_ENABLEMENT
            - REJECT_ENABLEMENT
            - DISABLE_BENEFICIARY
            - CORRECT_AGREEMENT_DIVERGENCE
            - ADOPT_AGREEMENT_DIVERGENCE
            - BULK_ADOPT_AGREEMENT_DIVERGENCES
            - CREATE_AGREEMENT
            - UPDATE_AGREEMENT
            - CLOSE_AGREEMENT
            - REPROCESS_AGREEMENT_CLOSURE
            - FORCE_CLOSE_AGREEMENT
            - LINK_POOLED_ACCOUNT
            - REMOVE_POOLED_ACCOUNT_LINK
            - PUT_PCR_CONNECTION
            - PUT_COLLECTIONS_SETTINGS
            - SYNC_PCR_SUBSCRIPTION
            - ROTATE_PCR_NOTICE_SECRET
            - REDELIVER_PCR_NOTICE
          examples:
            - REDELIVER_PCR_NOTICE
          type: string
        auditActionId:
          description: Entry created in the audit trail.
          examples:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
          format: uuid
          type: string
        outcome:
          description: 'APPLIED: the local effect is written and, when there is an external effect, it is confirmed. ENQUEUED: the action is recorded under a stable key and its effect follows asynchronously, at the PCR or the ledger.'
          enum:
            - APPLIED
            - ENQUEUED
          examples:
            - ENQUEUED
          type: string
        targetId:
          description: Identifier of the resource the action acted on.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type: string
        targetState:
          description: State of the target after the action, as far as collections knows it when it answers.
          examples:
            - FAILED
          maxLength: 64
          type: string
        targetType:
          description: Kind of resource the action acted on.
          enum:
            - TITLE
            - WRITE_OFF
            - CREDIT_ENTRY
            - PCR_COMMAND
            - PCR_NOTICE
            - BENEFICIARY
            - ENABLEMENT_BATCH
            - AGREEMENT
            - AGREEMENT_DIVERGENCE
            - POOLED_ACCOUNT_LINK
            - PCR_CONNECTION
            - PCR_SUBSCRIPTION
            - PCR_WEBHOOK_DELIVERY
            - COLLECTIONS_SETTINGS
            - ACCOUNT
          examples:
            - PCR_WEBHOOK_DELIVERY
          type: string
      required:
        - auditActionId
        - action
        - targetType
        - targetId
        - outcome
        - targetState
      type: object
    Actor:
      additionalProperties: false
      properties:
        clientId:
          description: OAuth client that presented the token, null when unknown.
          examples:
            - console
          maxLength: 128
          type:
            - string
            - 'null'
        id:
          description: Subject of the token, or the name of the service's worker for SYSTEM.
          examples:
            - a1b2c3d4-0000-4000-8000-000000000001
          maxLength: 128
          type: string
        type:
          description: USER for a person's token, MACHINE for a machine client's, SYSTEM for the service itself.
          enum:
            - USER
            - MACHINE
            - SYSTEM
          examples:
            - USER
          type: string
      required:
        - type
        - id
      type: object
    AddressRequest:
      additionalProperties: false
      properties:
        city:
          type: string
        complement:
          type: string
        neighborhood:
          type: string
        number:
          type: string
        state:
          type: string
        street:
          type: string
        zipCode:
          type: string
      type: object
    AddressResponse:
      additionalProperties: false
      properties:
        city:
          type: string
        complement:
          type: string
        neighborhood:
          type: string
        number:
          type: string
        state:
          type: string
        street:
          type: string
        zipCode:
          type: string
      type: object
    AdoptAgreementDivergenceRequest:
      additionalProperties: false
      properties:
        accountId:
          description: Ledger account of the holder the agreement of a MISSING_LOCALLY is adopted on. Required when the holder has several accounts; with a single account, optional, and it must be that one. It must be the holder's (otherwise 422 PBP-0825) and open (otherwise 422 PBP-0808). The organization and the ledger come from the account itself.
          examples:
            - 8e1f2a3b-4c5d-4e6f-9a0b-1c2d3e4f5a6b
          format: uuid
          type: string
        reason:
          description: Reason for the action, recorded in the audit trail. Must not carry personal data.
          examples:
            - Adopt the agreement registered before collections.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - reason
      type: object
    AdoptBoletoEmissionRequestBody:
      additionalProperties: false
      properties:
        providerId:
          description: The provider's id of the title.
          examples:
            - 8c2f0b5e-1d3a-4c7e-9f6b-2a4d5e6f7a8b
          maxLength: 64
          type: string
      required:
        - providerId
      type: object
    Agreement:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the agreement.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        beneficiaryId:
          description: Beneficiary of the account's holder.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a61
          format: uuid
          type: string
        chargebackRiskAcknowledged:
          description: Whether the client acknowledged that, under AT_SETTLEMENT, a cancellation confirmed after the release is charged back from the account's default balance. Always true under AT_SETTLEMENT and false under AFTER_CANCELLATION_WINDOW.
          examples:
            - false
          type: boolean
        closedAt:
          description: When the agreement was CLOSED, RFC 3339 in UTC; null otherwise.
          examples:
            - '2026-11-12T10:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        createdAt:
          description: When the agreement was created, RFC 3339 in UTC.
          examples:
            - '2026-11-11T10:00:00Z'
          format: date-time
          type: string
        creditDelayBusinessDays:
          description: Business days before the agreement's credit is released, counted from the write-off's movement day.
          examples:
            - 0
          format: int64
          maximum: 30
          minimum: 0
          type: integer
        id:
          description: Identifier of the agreement.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
          format: uuid
          type: string
        importedAgreementCode:
          description: Code the agreement had in the beneficiary base when it was adopted (origin IMPORTED); null for an agreement collections created.
          examples:
            - AB-1234
          maxLength: 40
          readOnly: true
          type:
            - string
            - 'null'
        ledgerId:
          description: Midaz ledger of the account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6c
          format: uuid
          readOnly: true
          type: string
        nucleaAccountNumber:
          description: Agreement's account at Núclea, optional.
          examples:
            - '87654321'
          maxLength: 20
          readOnly: true
          type:
            - string
            - 'null'
        nucleaAccountType:
          description: Type of the agreement's account at Núclea, optional.
          examples:
            - CC
          maxLength: 2
          readOnly: true
          type:
            - string
            - 'null'
        nucleaAgreementCode:
          description: Seven-digit code collections assigned to the agreement, unique in the institution and never reused.
          examples:
            - '0000042'
          pattern: ^[0-9]{7}$
          readOnly: true
          type: string
        nucleaBranchNumber:
          description: Agreement's branch at Núclea. Null until the branch is assigned.
          examples:
            - '0001'
          pattern: ^[0-9]{1,4}$
          readOnly: true
          type:
            - string
            - 'null'
        nucleaBranchType:
          description: 'Type of the agreement''s branch at Núclea: F physical, V virtual, N not informed. Null until the branch is assigned.'
          enum:
            - F
            - V
            - N
            -
          examples:
            - F
          readOnly: true
          type:
            - string
            - 'null'
        nucleaSituation:
          description: 'Situation of the agreement in the beneficiary base: A active, C cancelled, E excluded, I inactive. Null before Núclea accepts it.'
          enum:
            - A
            - C
            - E
            - I
            -
          examples:
            - A
          readOnly: true
          type:
            - string
            - 'null'
        numbering:
          $ref: '#/components/schemas/AgreementNumbering'
          description: Nosso número range of the agreement and the next value of its counter.
        organizationId:
          description: Midaz organization of the account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type: string
        origin:
          description: COLLECTIONS for an agreement collections created; IMPORTED for one registered elsewhere and adopted.
          enum:
            - COLLECTIONS
            - IMPORTED
          examples:
            - COLLECTIONS
          type: string
        paymentDeadlineDays:
          description: Calendar days after the due date up to the default payment deadline of the agreement's boletos.
          examples:
            - 30
          format: int64
          maximum: 365
          minimum: 1
          type: integer
        portfolio:
          description: Portfolio of the agreement.
          enum:
            - '01'
            - '02'
            - '03'
            - '04'
            - '05'
            - '06'
          examples:
            - '01'
          type: string
        productType:
          description: Product type of the agreement at Núclea, two digits.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type: string
        registrationBlockedReason:
          description: 'MISSING_BRANCH: the agreement is PENDING_REGISTRATION and was not sent to Núclea because its branch type or number is missing, or because the branch found for it is held back while another agreement of the holder holds the key at Núclea that the branch would give it; the holder''s boletos wait meanwhile. Null when nothing holds the inclusion back.'
          enum:
            - MISSING_BRANCH
            -
          examples:
            - MISSING_BRANCH
          readOnly: true
          type:
            - string
            - 'null'
        releasePolicy:
          description: 'When the credit of a paid boleto of the agreement is released. AFTER_CANCELLATION_WINDOW waits until the write-off''s cancellation deadline, and any margin the platform adds to it, has passed. AT_SETTLEMENT releases it once the payment is settled and the credit date is reached, without waiting for the deadline: a cancellation confirmed after the release is then charged back from the account''s default balance. Applies to the boletos issued under the agreement; each boleto keeps the policy it was issued with.'
          enum:
            - AFTER_CANCELLATION_WINDOW
            - AT_SETTLEMENT
          examples:
            - AFTER_CANCELLATION_WINDOW
          type: string
        speciesCode:
          description: Species of the boletos, at two digits.
          examples:
            - '02'
          pattern: ^[0-9]{2}$
          type: string
        state:
          description: PENDING_REGISTRATION until Núclea accepts the inclusion; then ACTIVE, or BLOCKED while the beneficiary is refused or unfit. CLOSING once the exclusion is sent, then CLOSED, or CLOSURE_FAILED when Núclea refuses it. REGISTRATION_REJECTED when Núclea refuses the inclusion.
          enum:
            - PENDING_REGISTRATION
            - ACTIVE
            - BLOCKED
            - CLOSING
            - CLOSED
            - CLOSURE_FAILED
            - REGISTRATION_REJECTED
          examples:
            - ACTIVE
          type: string
        updatedAt:
          description: When the agreement last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-11T10:00:00Z'
          format: date-time
          type: string
        version:
          description: Version of the agreement; a change sends it back.
          examples:
            - 3
          format: int64
          minimum: 1
          type: integer
      required:
        - id
        - beneficiaryId
        - organizationId
        - ledgerId
        - accountId
        - productType
        - portfolio
        - speciesCode
        - creditDelayBusinessDays
        - releasePolicy
        - chargebackRiskAcknowledged
        - paymentDeadlineDays
        - numbering
        - nucleaAgreementCode
        - state
        - origin
        - version
        - createdAt
        - updatedAt
      type: object
    AgreementDivergence:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the agreement or, on an open MISSING_LOCALLY, the holder's single ledger account; null when there is none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a23
          format: uuid
          type:
            - string
            - 'null'
        adoptionBlockReason:
          description: 'Only on a MISSING_LOCALLY: why it is not adopted without the operator''s decision. AMBIGUOUS_ACCOUNT: the holder has several ledger accounts. NO_LEDGER_ACCOUNT: the holder has none, or the person was not found. Null when the holder has a single account, answered in accountId. After an adoption with an account given, it stays as history.'
          enum:
            - AMBIGUOUS_ACCOUNT
            - NO_LEDGER_ACCOUNT
            -
          examples:
            - AMBIGUOUS_ACCOUNT
          type:
            - string
            - 'null'
        agreementId:
          description: Collections agreement the divergence is about; null when collections holds none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a21
          format: uuid
          type:
            - string
            - 'null'
        beneficiaryId:
          description: Collections beneficiary the divergence is about; null when collections holds none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a22
          format: uuid
          type:
            - string
            - 'null'
        detectedAt:
          description: When the divergence was detected, RFC 3339 in UTC.
          examples:
            - '2026-11-10T12:00:00Z'
          format: date-time
          type: string
        fields:
          description: The attributes that differ; empty when the divergence lists none.
          items:
            $ref: '#/components/schemas/DivergenceField'
          maxItems: 32
          type: array
        id:
          description: Identifier of the divergence.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
          format: uuid
          type: string
        inventoryRunId:
          description: Consumption of the inventory that raised the divergence; null when none did.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a11
          format: uuid
          type:
            - string
            - 'null'
        kind:
          description: 'What the reconciliation found. MISSING_IN_NUCLEA: a live collections agreement the beneficiary base lacks. MISSING_LOCALLY: an agreement of the base that collections lacks, registered outside collections. ATTRIBUTE_MISMATCH: an agreement whose attributes differ between the two. SITUATION_MISMATCH: an agreement whose situation differs between the two.'
          enum:
            - MISSING_IN_NUCLEA
            - MISSING_LOCALLY
            - ATTRIBUTE_MISMATCH
            - SITUATION_MISMATCH
          examples:
            - MISSING_LOCALLY
          type: string
        nucleaBeneficiaryNumber:
          description: Number of the beneficiary at Núclea; null when the divergence has none.
          examples:
            - '1234567890123'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        organizationId:
          description: Midaz organization of the related account; null when there is none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        productType:
          description: Product type of the diverging agreement at Núclea, two digits, as the base carries it; null when the divergence is not about an agreement.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type:
            - string
            - 'null'
        resolution:
          description: 'How the divergence was resolved. CORRECTED: the base was corrected from what collections holds. ADOPTED: collections adopted what the base holds. Null until it is resolved.'
          enum:
            - CORRECTED
            - ADOPTED
            -
          examples:
            - ADOPTED
          type:
            - string
            - 'null'
        resolvedAt:
          description: When the divergence was resolved, RFC 3339 in UTC; null until it is resolved.
          examples:
            - '2026-11-10T13:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        state:
          description: 'Where the divergence is in the operator''s queue. OPEN: waiting. RESOLVING: its correction or adoption is in flight. RESOLVED: corrected or adopted.'
          enum:
            - OPEN
            - RESOLVING
            - RESOLVED
          examples:
            - OPEN
          type: string
      required:
        - id
        - kind
        - state
        - detectedAt
      type: object
    AgreementDivergenceList:
      additionalProperties: false
      properties:
        items:
          description: The page's divergences, oldest first.
          items:
            $ref: '#/components/schemas/AgreementDivergence'
          type: array
        limit:
          description: Most divergences the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    AgreementNumbering:
      additionalProperties: false
      properties:
        nextValue:
          description: Next nosso número the counter allocates, at 16 positions, for information; null once the range is exhausted, or where the counter is not read.
          examples:
            - '0000000000001234'
          pattern: ^[0-9]{16}$
          readOnly: true
          type:
            - string
            - 'null'
        rangeEnd:
          description: Last nosso número of the range, at 16 positions.
          examples:
            - '9999999999999999'
          pattern: ^[0-9]{16}$
          type: string
        rangeStart:
          description: First nosso número of the range, at 16 positions.
          examples:
            - '0000000000000001'
          pattern: ^[0-9]{16}$
          type: string
      required:
        - rangeStart
        - rangeEnd
      type: object
    AgreementPage:
      additionalProperties: false
      properties:
        items:
          description: The page's agreements, oldest first.
          items:
            $ref: '#/components/schemas/Agreement'
          type: array
        limit:
          description: Most agreements the page holds.
          examples:
            - 20
          format: int64
          type: integer
        page:
          description: The page, from 1.
          examples:
            - 1
          format: int64
          type: integer
        total:
          description: How many agreements the filters match, in every page.
          examples:
            - 3
          format: int64
          type: integer
      required:
        - page
        - limit
        - total
        - items
      type: object
    AgreementSpec:
      additionalProperties: false
      properties:
        chargebackRiskAcknowledged:
          description: The client acknowledges that, under AT_SETTLEMENT, a cancellation confirmed after the release is charged back from the account's default balance, which may no longer hold the amount. Required true with AT_SETTLEMENT, which is refused without it with 422 PBP-0006; recorded false under AFTER_CANCELLATION_WINDOW.
          examples:
            - false
          type: boolean
        creditDelayBusinessDays:
          default: 0
          description: 'Business days before the agreement''s credit is released, counted from the write-off''s movement day: the write-off date, or the next business day when it falls on a weekend or holiday. The release also waits for the settlement; 0 releases it on the movement day or on settlement, whichever is later.'
          examples:
            - 0
          format: int64
          maximum: 30
          minimum: 0
          type: integer
        numbering:
          $ref: '#/components/schemas/NumberingRule'
          description: Nosso número range of the agreement. Left out, the whole range, 1 to 9999999999999999.
        paymentDeadlineDays:
          default: 30
          description: Calendar days after the due date up to the default payment deadline of the agreement's boletos.
          examples:
            - 30
          format: int64
          maximum: 365
          minimum: 1
          type: integer
        portfolio:
          description: 'Portfolio of the agreement: 01 Simples, 02 Vinculada, 03 Caucionada, 04 Descontada, 05 Vendor, 06 Cessão. Only 01 is issued; 02 to 06 are refused with 422 PBP-0801.'
          enum:
            - '01'
            - '02'
            - '03'
            - '04'
            - '05'
            - '06'
          examples:
            - '01'
          type: string
        productType:
          description: 'Product type of the agreement at Núclea, two digits: 01 is the Boleto de Cobrança and 07 the Terceiro Habilitado. Any other product type is refused with 422 PBP-0801.'
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type: string
        releasePolicy:
          description: 'When the credit of a paid boleto of the agreement is released. AFTER_CANCELLATION_WINDOW, the default, waits until the write-off''s cancellation deadline, and any margin the platform adds to it, has passed. AT_SETTLEMENT releases it once the payment is settled and the credit date is reached, without waiting for the deadline: a cancellation confirmed after the release is then charged back from the account''s default balance. Applies to the boletos issued under the agreement.'
          enum:
            - AFTER_CANCELLATION_WINDOW
            - AT_SETTLEMENT
          examples:
            - AFTER_CANCELLATION_WINDOW
          type: string
        speciesCode:
          description: 'Species of the boleto, one or two digits, 1 to 30 or 99; 31, 32 and 33 are refused with 422 PBP-0801. Answered always as two digits: 2 and 02 are the same species, answered 02.'
          examples:
            - '02'
          pattern: ^[0-9]{1,2}$
          type: string
      required:
        - productType
        - portfolio
        - speciesCode
      type: object
    AuditAction:
      additionalProperties: false
      properties:
        action:
          description: What was done.
          enum:
            - RELEASE_WRITE_OFF
            - CANCEL_SCHEDULED_RELEASE
            - UNHOLD_WRITE_OFF
            - REVERSE_WRITE_OFF
            - REPROCESS_CREDIT_ENTRY
            - REPROCESS_PCR_COMMAND
            - CLOSE_PCR_COMMAND
            - SETTLE_SUBMISSION_FAILURE
            - ASSOCIATE_PCR_NOTICE
            - DISCARD_PCR_NOTICE
            - APPLY_PCR_NOTICE
            - WRITE_OFF_LATE_REGISTRATION
            - ENABLE_ACCOUNT
            - CREATE_ENABLEMENT_BATCH
            - APPROVE_ENABLEMENT
            - REJECT_ENABLEMENT
            - DISABLE_BENEFICIARY
            - CORRECT_AGREEMENT_DIVERGENCE
            - ADOPT_AGREEMENT_DIVERGENCE
            - BULK_ADOPT_AGREEMENT_DIVERGENCES
            - CREATE_AGREEMENT
            - UPDATE_AGREEMENT
            - CLOSE_AGREEMENT
            - REPROCESS_AGREEMENT_CLOSURE
            - FORCE_CLOSE_AGREEMENT
            - LINK_POOLED_ACCOUNT
            - REMOVE_POOLED_ACCOUNT_LINK
            - PUT_PCR_CONNECTION
            - PUT_COLLECTIONS_SETTINGS
            - SYNC_PCR_SUBSCRIPTION
            - ROTATE_PCR_NOTICE_SECRET
            - REDELIVER_PCR_NOTICE
          examples:
            - PUT_COLLECTIONS_SETTINGS
          type: string
        actor:
          $ref: '#/components/schemas/Actor'
          description: Who made the action.
        after:
          additionalProperties: {}
          description: The module's fields after the action. Never personal data or secrets.
          type:
            - object
            - 'null'
        before:
          additionalProperties: {}
          description: The module's fields before the action, null when the action created them. Never personal data or secrets.
          type:
            - object
            - 'null'
        evidence:
          $ref: '#/components/schemas/Evidence'
          description: Evidence that backs the action, when there is any.
        id:
          description: Identifier of the audited action.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a01
          format: uuid
          type: string
        idempotencyKey:
          description: Idempotency-Key of the request that made the action, when it had one.
          examples:
            - 0190f3a4-2b6c-7d8e-9f01-23456789abcd
          format: uuid
          type: string
        occurredAt:
          description: When the action happened, RFC 3339 in UTC.
          examples:
            - '2026-11-09T15:04:05Z'
          format: date-time
          type: string
        organizationId:
          description: Midaz organization of the related account, null when the action relates to none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        reason:
          description: Reason given for the action.
          examples:
            - Default agreement template for the new portfolio.
          maxLength: 500
          minLength: 10
          type: string
        targetId:
          description: Identifier of the resource acted on.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a02
          format: uuid
          type: string
        targetType:
          description: Kind of resource acted on.
          enum:
            - TITLE
            - WRITE_OFF
            - CREDIT_ENTRY
            - PCR_COMMAND
            - PCR_NOTICE
            - BENEFICIARY
            - ENABLEMENT_BATCH
            - AGREEMENT
            - AGREEMENT_DIVERGENCE
            - POOLED_ACCOUNT_LINK
            - PCR_CONNECTION
            - PCR_SUBSCRIPTION
            - PCR_WEBHOOK_DELIVERY
            - COLLECTIONS_SETTINGS
            - ACCOUNT
          examples:
            - COLLECTIONS_SETTINGS
          type: string
      required:
        - id
        - action
        - targetType
        - targetId
        - actor
        - reason
        - occurredAt
      type: object
    AuditActionList:
      additionalProperties: false
      properties:
        items:
          description: The page's actions, oldest first.
          items:
            $ref: '#/components/schemas/AuditAction'
          type: array
        limit:
          description: Most actions the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    AutomaticSettlementCheck:
      additionalProperties: false
      properties:
        attempts:
          description: How many automatic checks ran.
          examples:
            - 3
          format: int64
          minimum: 1
          type: integer
        checkedAt:
          description: When the last check ran, RFC 3339 in UTC.
          examples:
            - '2026-11-11T09:30:00Z'
          format: date-time
          type: string
        detail:
          description: What the last check recorded, a text written by collections without personal data; null when it recorded none.
          maxLength: 500
          type:
            - string
            - 'null'
        result:
          description: 'SETTLED: the check found the write-off settled. NOT_SETTLED: the check found it not settled yet. UNRESOLVED: the checks ended without a settlement, and the operator decides. FAILED: the PCR did not answer the check. An item never carries SETTLED: a write-off whose settlement a check confirmed leaves the queue.'
          enum:
            - SETTLED
            - NOT_SETTLED
            - UNRESOLVED
            - FAILED
          examples:
            - UNRESOLVED
          type: string
      required:
        - checkedAt
        - result
        - attempts
      type: object
    BatchInvalidItemsProblem:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - properties:
            code:
              enum:
                - PBP-0123
              type: string
            itemErrors:
              description: The problems of the items, by ascending position and, within an item, in the order of its members.
              items:
                $ref: '#/components/schemas/BatchItemError'
              minItems: 1
              type: array
          required:
            - code
            - itemErrors
          type: object
      description: '422 PBP-0123: one or more items are invalid. The whole batch is refused, and nothing is recorded or sent for issuance. Every problem of every item comes at once, in two forms: errors[], the service''s form for generic clients, with location body.items[<position>].<member> and message; and itemErrors[], an extension member with the same problems, each with position, field and the item''s code, to mark the member and translate the problem without reading the message. A refusal that holds for the whole batch (account, ledger, holder registration) prevails and comes under its own code, without the list.'
    BatchItemError:
      additionalProperties: false
      properties:
        code:
          description: 'Code of the item''s problem. An open list; today: PBP-0001 (form, size, presence, document, amount, due date, address, charge start date, documentNumber), PBP-0006 (type not supported, HYBRID included, with the reason in message; charges), PBP-0119 (payer is the final beneficiary) and PBP-0125 (ourNumber repeated in the batch). It is the code the single boleto or the installment series gives the same condition, except the last, which is the batch''s own.'
          examples:
            - PBP-0125
          pattern: ^PBP-[0-9]{4}$
          type: string
        field:
          description: Path of the member inside the item, in dot notation (payer.address.zipCode, ourNumber, discount.limitDate, fine). paymentDeadline names the deadline the service computed for the item, which the item does not carry.
          examples:
            - payer.address.zipCode
          type: string
        message:
          description: Human-readable message, in English like every message of the service. A client translates by code, never by this text.
          examples:
            - type HYBRID is not supported for batch issuance
          type: string
        position:
          description: Position of the item in the request, from 0.
          examples:
            - 1
          format: int64
          maximum: 24
          minimum: 0
          type: integer
      required:
        - position
        - field
        - code
        - message
      type: object
    BatchSizeProblem:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - properties:
            code:
              enum:
                - PBP-0122
              type: string
            maxItems:
              description: The most items a batch holds.
              enum:
                - 25
              format: int64
              type: integer
            receivedItems:
              description: The number of items sent.
              examples:
                - 26
              format: int64
              minimum: 0
              type: integer
          required:
            - code
            - maxItems
            - receivedItems
          type: object
      description: '422 PBP-0122: the number of items is outside 1 to 25.'
    Beneficiary:
      additionalProperties: false
      properties:
        agreementIds:
          description: Agreements of the beneficiary, in any state, oldest first; at most the first 16. In the answer of an enablement, the agreements that enablement created on the account.
          items:
            type: string
          maxItems: 16
          type: array
        baseSituation:
          description: 'The holder''s own situation in the beneficiary base: FIT, UNDER_REVIEW or UNFIT; null until the base reports one.'
          enum:
            - FIT
            - UNDER_REVIEW
            - UNFIT
            -
          examples:
            - FIT
          type:
            - string
            - 'null'
        connectionId:
          description: Connection to the PCR the beneficiary is registered through.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a72
          format: uuid
          type: string
        createdAt:
          description: When the beneficiary was created, RFC 3339 in UTC.
          examples:
            - '2026-11-11T14:00:00Z'
          format: date-time
          type: string
        enablementMode:
          description: 'EXPLICIT: asked for one account. BATCH: an item of an enablement batch. AUTOMATIC: started by an issuance, as the tenant''s settings allow. IMPORT: taken from Núclea''s base, never asked for.'
          enum:
            - EXPLICIT
            - BATCH
            - AUTOMATIC
            - IMPORT
          examples:
            - EXPLICIT
          type: string
        enablementState:
          description: 'REQUESTED: asked for, not yet consulted in the beneficiary base. CONSULTED: the consultation found nothing that holds it, or an operator approved it over an alert. HELD_BY_ALERT: held because another institution marked the holder under review or unfit; an operator approves or rejects it. SUBMITTED: the registration was sent to the PCR, waiting for its outcome. ACCEPTED: registered in the base, enabled to issue. REJECTED: refused, by the PCR or by an operator; reason says why. DISABLED: no longer enabled to issue.'
          enum:
            - REQUESTED
            - CONSULTED
            - HELD_BY_ALERT
            - SUBMITTED
            - ACCEPTED
            - REJECTED
            - DISABLED
          examples:
            - ACCEPTED
          type: string
        holderId:
          description: Holder, the person in the platform's people registry.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
          format: uuid
          type: string
        id:
          description: Identifier of the beneficiary.
          examples:
            - c56a4180-65aa-42ec-a945-5fd21dec0538
          format: uuid
          type: string
        marketAlert:
          description: The latest situation another institution reported about the holder; null when there is none.
          oneOf:
            - $ref: '#/components/schemas/MarketAlert'
            - type: 'null'
        nucleaBeneficiaryNumber:
          description: Number of the beneficiary in Núclea's base (NumIdentcBenfcrio); null until Núclea registers it.
          examples:
            - '1234567890'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        organizationId:
          description: Midaz organization of the account whose enablement created the beneficiary; null for a beneficiary taken from Núclea's base without an account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        origin:
          description: 'COLLECTIONS: registered by collections. IMPORTED: registered outside collections and adopted.'
          enum:
            - COLLECTIONS
            - IMPORTED
          examples:
            - COLLECTIONS
          type: string
        reason:
          description: Why the enablement was REJECTED, by the PCR, the Núclea, an operator or collections itself; on a DISABLED beneficiary, why the exclusion of its relationship at the Núclea was refused, while that refusal stands. Null otherwise.
          oneOf:
            - $ref: '#/components/schemas/FailureReason'
            - type: 'null'
        updatedAt:
          description: When the beneficiary last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-11T14:00:00Z'
          format: date-time
          type: string
      required:
        - id
        - holderId
        - connectionId
        - enablementState
        - enablementMode
        - origin
        - agreementIds
        - createdAt
        - updatedAt
      type: object
    BeneficiaryPage:
      additionalProperties: false
      properties:
        items:
          description: The page's beneficiaries, oldest first.
          items:
            $ref: '#/components/schemas/Beneficiary'
          type: array
        limit:
          description: Most beneficiaries the page holds.
          examples:
            - 20
          format: int64
          type: integer
        page:
          description: The page, from 1.
          examples:
            - 1
          format: int64
          type: integer
        total:
          description: How many beneficiaries the filters match, in every page.
          examples:
            - 3
          format: int64
          type: integer
      required:
        - page
        - limit
        - total
        - items
      type: object
    BoletoAmendedNotice:
      additionalProperties: true
      properties:
        amendmentId:
          description: Amendment request identifier.
          format: uuid
          type: string
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        appliedAt:
          description: When the amendment was applied, RFC 3339 in UTC.
          format: date-time
          type: string
        appliedChanges:
          $ref: '#/components/schemas/NoticeAmendmentChanges'
          description: The changes applied, as the request asked for them.
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        effectiveTerms:
          $ref: '#/components/schemas/NoticeEffectiveTerms'
          description: The boleto's terms in force, with only the members the boleto holds.
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_AMENDED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        provider:
          description: Provider of the boleto; not the providerId.
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        status:
          description: Boleto status when the amendment was applied.
          type: string
      required:
        - event
        - status
        - amendmentId
        - appliedChanges
        - effectiveTerms
        - appliedAt
        - provider
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoAmendmentDiscount:
      additionalProperties: false
      properties:
        amount:
          description: Discount amount as a decimal string.
          examples:
            - '5'
          type: string
        limitDate:
          description: Last day the discount applies, YYYY-MM-DD.
          examples:
            - '2030-01-10'
          format: date
          type: string
        type:
          description: Discount type.
          examples:
            - FIXED
          type: string
      required:
        - type
        - amount
        - limitDate
      type: object
    BoletoAmendmentRejectedNotice:
      additionalProperties: true
      properties:
        amendmentId:
          description: Amendment request identifier.
          format: uuid
          type: string
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_AMENDMENT_REJECTED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        rejectedAt:
          description: When the request was refused, RFC 3339 in UTC.
          format: date-time
          type: string
        rejection:
          $ref: '#/components/schemas/NoticeRejection'
          description: Why the request was refused, as a problem document.
        requestedChanges:
          $ref: '#/components/schemas/NoticeAmendmentChanges'
          description: The changes the request asked for.
        status:
          description: Boleto status when the request was refused.
          type: string
      required:
        - event
        - status
        - amendmentId
        - requestedChanges
        - rejection
        - rejectedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoAmendmentRejection:
      additionalProperties: false
      properties:
        code:
          description: Product code of the refusal.
          examples:
            - PBP-0014
          type: string
        detail:
          description: Explanation of the refusal.
          type: string
        providerReason:
          description: Stable reason of the provider's rule, when it gave one.
          type: string
        status:
          description: Status of the refusal.
          examples:
            - 422
          format: int64
          type: integer
        title:
          description: Short summary of the refusal.
          examples:
            - Unprocessable Entity
          type: string
      required:
        - title
        - status
        - detail
        - code
      type: object
    BoletoAmendmentRequest:
      additionalProperties: true
      properties:
        amount:
          description: New amount as a decimal string, positive, at most two decimal places. Cannot be null. On LERIAN it must be below 100000000.00; otherwise 422 PBP-0006 naming the member, before anything is recorded.
          examples:
            - '150.00'
          maxLength: 32
          type: string
        discounts:
          description: The whole new list of discount bands, under the issuance's rules for bands; an empty list removes every band. Cannot be null.
          items:
            $ref: '#/components/schemas/DiscountRequest'
          maxItems: 3
          type: array
        documentNumber:
          description: New payee's reference of the charge (seu numero), 1 to 15 printable ASCII characters. null removes it.
          examples:
            - INV-0042
          maxLength: 15
          minLength: 1
          pattern: ^[ -~]{1,15}$
          type:
            - string
            - 'null'
        dueDate:
          description: New due date, YYYY-MM-DD, not before today in Brazil. Cannot be null. On LERIAN it must be at most 3650 days after the day of issuance; otherwise 422 PBP-0006 naming the member, before anything is recorded.
          examples:
            - '2030-01-20'
          format: date
          type: string
        fine:
          additionalProperties: false
          description: New fine. null exempts the boleto from the fine.
          properties:
            amount:
              description: Fine amount as a decimal string, greater than zero. On LERIAN a PERCENTAGE must be at most 100 and a FIXED below the boleto's amount; otherwise 422 PBP-0006 naming the member, before anything is recorded.
              maxLength: 32
              type: string
            startDate:
              description: 'Day the fine starts to apply, YYYY-MM-DD: after the resulting due date, on or before the resulting payment deadline, and not before today; otherwise 422 PBP-0006 naming fine.startDate. Absent, the day after the resulting due date. On LERIAN, without paymentDeadline in the request, the resulting payment deadline is the one the boleto holds, which a new due date does not move, and a later day is refused: 422 PBP-0006 naming the member, before anything is recorded.'
              examples:
                - '2030-01-21'
              format: date
              type: string
            type:
              description: 'Fine type, charged once when the boleto is paid after its due date: FIXED (amount in BRL, at most 2 decimal places) or PERCENTAGE (percent of the boleto''s amount, at most 6 decimal places, 5 on LERIAN). An absent, empty or unlisted value is refused with 422 PBP-0006.'
              type: string
          required:
            - amount
          type:
            - object
            - 'null'
        interest:
          additionalProperties: false
          description: New interest. null exempts the boleto from interest.
          properties:
            amount:
              description: Interest amount as a decimal string, greater than zero. On LERIAN a DAILY_FIXED must be below 1000000000000, and a MONTHLY_PERCENTAGE, or 30 times a DAILY_PERCENTAGE, below 1000000000; otherwise 422 PBP-0006 naming the member, before anything is recorded.
              maxLength: 32
              type: string
            startDate:
              description: 'Day the interest starts to accrue, YYYY-MM-DD: after the resulting due date, on or before the resulting payment deadline, and not before today; otherwise 422 PBP-0006 naming interest.startDate. Absent, the day after the resulting due date. On LERIAN, without paymentDeadline in the request, the resulting payment deadline is the one the boleto holds, which a new due date does not move, and a later day is refused: 422 PBP-0006 naming the member, before anything is recorded.'
              examples:
                - '2030-01-21'
              format: date
              type: string
            type:
              description: 'Interest type, accrued for each calendar day the boleto is paid late: DAILY_FIXED (BRL per day, at most 2 decimal places), DAILY_PERCENTAGE or MONTHLY_PERCENTAGE (percent of the boleto''s amount, at most 6 decimal places, 5 on LERIAN, where 30 times a DAILY_PERCENTAGE, the monthly rate it is registered as, must have at most 2). An absent, empty or unlisted value is refused with 422 PBP-0006.'
              type: string
          required:
            - amount
          type:
            - object
            - 'null'
        paymentDeadline:
          description: 'New last day the boleto can be paid, YYYY-MM-DD, on or after the resulting due date and within the provider''s maximum after it, LERIAN declaring none. It can be changed, never removed: null is refused with 400 PBP-0001.'
          examples:
            - '2030-02-20'
          format: date
          type: string
      type: object
    BoletoAmendmentResponse:
      additionalProperties: false
      properties:
        boletoId:
          description: Boleto the request amends.
          format: uuid
          type: string
        effectiveTerms:
          $ref: '#/components/schemas/BoletoAmendmentTerms'
          description: Every term in force once the request was applied; present on APPLIED. A null member is a clause or reference the boleto does not have.
        id:
          description: Amendment request identifier.
          format: uuid
          type: string
        provider:
          description: Provider of the boleto.
          type: string
        rejection:
          $ref: '#/components/schemas/BoletoAmendmentRejection'
          description: Why the request was refused; present on REJECTED and on a SUPERSEDED request the provider refused afterwards.
        requestedAt:
          description: When the request was recorded, in UTC.
          format: date-time
          type: string
        requestedChanges:
          $ref: '#/components/schemas/BoletoAmendmentTerms'
          description: 'The members the request changes, with their final values, in normalized form: null exempts a fine or interest, or removes the seu numero.'
        resolvedAt:
          description: When the request was decided, in UTC; absent while it is PENDING.
          format: date-time
          type: string
        status:
          description: PENDING while the provider's outcome is awaited; APPLIED and REJECTED once decided; SUPERSEDED when a cancellation of the boleto came first.
          enum:
            - PENDING
            - APPLIED
            - REJECTED
            - SUPERSEDED
          type: string
      required:
        - id
        - boletoId
        - status
        - requestedChanges
        - requestedAt
        - provider
      type: object
    BoletoAmendmentTerms:
      additionalProperties: false
      properties:
        amount:
          description: Amount as a decimal string, without trailing zeros.
          examples:
            - '150.5'
          type: string
        discounts:
          description: The discount bands, in the order they apply; an empty list is no band.
          items:
            $ref: '#/components/schemas/BoletoAmendmentDiscount'
          type: array
        documentNumber:
          description: The payee's reference of the charge (seu numero); null is none.
          examples:
            - INV-0042
          type:
            - string
            - 'null'
        dueDate:
          description: Due date, YYYY-MM-DD.
          examples:
            - '2030-01-20'
          format: date
          type: string
        fine:
          additionalProperties: false
          description: The fine; null is no fine.
          properties:
            amount:
              description: Clause amount as a decimal string.
              examples:
                - '2'
              type: string
            startDate:
              description: Day the clause starts; absent, the day after the due date.
              examples:
                - '2030-01-21'
              format: date
              type: string
            type:
              description: Clause type.
              examples:
                - PERCENTAGE
              type: string
          required:
            - type
            - amount
          type:
            - object
            - 'null'
        interest:
          additionalProperties: false
          description: The interest; null is no interest.
          properties:
            amount:
              description: Clause amount as a decimal string.
              examples:
                - '2'
              type: string
            startDate:
              description: Day the clause starts; absent, the day after the due date.
              examples:
                - '2030-01-21'
              format: date
              type: string
            type:
              description: Clause type.
              examples:
                - PERCENTAGE
              type: string
          required:
            - type
            - amount
          type:
            - object
            - 'null'
        paymentDeadline:
          description: Last day the boleto can be paid, YYYY-MM-DD; null when none is recorded.
          examples:
            - '2030-02-20'
          format: date
          type:
            - string
            - 'null'
      type: object
    BoletoBatchCapability:
      additionalProperties: false
      properties:
        maxItems:
          description: Most items one batch submission carries. 0 when batches are not supported.
          examples:
            - 25
          format: int64
          minimum: 0
          type: integer
        supported:
          description: Whether the provider accepts boleto batches (POST /v1/boletos/batches).
          type: boolean
      required:
        - supported
        - maxItems
      type: object
    BoletoBatchCounts:
      additionalProperties: false
      properties:
        canceled:
          description: Items CANCELED.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
        failed:
          description: Items FAILED.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
        inactivated:
          description: 'Items INACTIVATED: written off.'
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
        overdue:
          description: 'Items still processing past the service''s deadline (overdue: true). Never more than processing.'
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
        processing:
          description: Items PENDING, still being issued.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
        registered:
          description: 'Items CREATED: registered and available for payment.'
          examples:
            - 2
          format: int64
          minimum: 0
          type: integer
        requested:
          description: 'Number of items requested: the size of the batch.'
          examples:
            - 5
          format: int64
          maximum: 25
          minimum: 1
          type: integer
        reversed:
          description: 'Items REVERSED: the payment was returned to the payer; the boleto will not be paid.'
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
        settled:
          description: 'Items SETTLED: paid.'
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
      required:
        - requested
        - processing
        - registered
        - settled
        - canceled
        - inactivated
        - reversed
        - failed
        - overdue
      type: object
    BoletoBatchCountsNotice:
      additionalProperties: false
      properties:
        canceled:
          description: Items canceled.
          format: int64
          minimum: 0
          type: integer
        failed:
          description: Items failed.
          format: int64
          minimum: 0
          type: integer
        inactivated:
          description: Items written off.
          format: int64
          minimum: 0
          type: integer
        overdue:
          description: Items past their due date.
          format: int64
          minimum: 0
          type: integer
        processing:
          description: Items still being registered.
          format: int64
          minimum: 0
          type: integer
        registered:
          description: Items registered and available for payment.
          format: int64
          minimum: 0
          type: integer
        requested:
          description: Items the request carried.
          format: int64
          minimum: 0
          type: integer
        reversed:
          description: Items reversed.
          format: int64
          minimum: 0
          type: integer
        settled:
          description: Items settled.
          format: int64
          minimum: 0
          type: integer
      required:
        - requested
        - processing
        - registered
        - settled
        - canceled
        - inactivated
        - reversed
        - failed
        - overdue
      type: object
    BoletoBatchFinishedNotice:
      additionalProperties: true
      properties:
        batchId:
          description: Batch identifier.
          format: uuid
          type: string
        closed:
          description: Every item is settled, canceled, written off, reversed or failed.
          type: boolean
        counts:
          $ref: '#/components/schemas/BoletoBatchCountsNotice'
          description: Item counts when the batch finished.
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO_BATCH
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_BATCH_FINISHED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        finished:
          description: 'Always true: no item is still being processed.'
          enum:
            - true
          type: boolean
        finishedAt:
          description: When the batch finished, RFC 3339 in UTC.
          format: date-time
          type: string
        occurredAt:
          description: When Payments recorded that the batch finished, in UTC with milliseconds.
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        status:
          description: Outcome of the batch.
          enum:
            - COMPLETED
            - PARTIAL_FAILURE
            - FAILED
          type: string
      required:
        - event
        - entityType
        - batchId
        - status
        - finished
        - closed
        - counts
        - finishedAt
        - occurredAt
        - eventId
      type: object
    BoletoBatchItemResponse:
      additionalProperties: false
      properties:
        amount:
          description: Requested amount, as a decimal string with two decimal places.
          examples:
            - '150.00'
          type: string
        boletoId:
          description: 'Identifier of the boleto this item produced: the id GET /v1/boletos/{id}, the PDF and the boleto cancellation take.'
          format: uuid
          type: string
        cancelable:
          description: 'Same meaning as cancelable on GET /v1/boletos/{id}: true only for a CREATED item that carries a providerId. Always present.'
          type: boolean
        discount:
          $ref: '#/components/schemas/DiscountResponse'
        dueDate:
          description: Requested due date.
          examples:
            - '2030-01-15'
          format: date
          type: string
        errorCode:
          description: Product code of the failure. Present only with status FAILED. The list is open; today PBP-0108 when the requested ourNumber is already in use, and PBP-0014 when the item was refused.
          examples:
            - PBP-0108
          pattern: ^PBP-[0-9]{4}$
          type: string
        errorMessage:
          description: Readable reason of the failure, present only with status FAILED. Written by this service; after provider reported ERROR it may carry, in parentheses, the error code the issuing bank sent. Translate it by errorCode.
          examples:
            - no title was issued for this emission
          maxLength: 500
          type: string
        fine:
          $ref: '#/components/schemas/FineResponse'
        instructions:
          description: Instructions requested for the item. Absent when the item carried none.
          type: string
        interest:
          $ref: '#/components/schemas/InterestResponse'
        ourNumber:
          description: Bank-side identification of the item's boleto (nosso numero), read from the barcode with leading zeros, as GET /v1/boletos/{id} answers it. Absent while the provider has not produced the boleto.
          examples:
            - '00000000152'
          type: string
        ourNumberDigit:
          description: Check digit of ourNumber, computed by the bank, as GET /v1/boletos/{id} answers it. Absent whenever the provider did not return it.
          examples:
            - '3'
          type: string
        ourNumberHolderBoletoId:
          description: 'Boleto that held the requested ourNumber when the item collided with it on creation (errorCode PBP-0108). It may be an earlier issuance of the same charge, so read that boleto before requesting another number. Absent in every other case, and when the boleto holding the number is a hybrid boleto, which is not available on this service: errorMessage then names no boleto. When that hybrid has no answer from the provider yet, errorMessage does not ask for another number, since that emission can still become a live boleto; when it has one, errorMessage says it may be an earlier issuance of the same charge whose answer was lost and stays payable, so the charge must not be issued again, and asks for another number only for a different charge.'
          type: string
        overdue:
          description: 'Whether the item is PENDING past the service''s deadline. Derived on every read. It is not a failure: the item is still being processed. Always false outside PENDING.'
          type: boolean
        payer:
          $ref: '#/components/schemas/PayerResponse'
        paymentDeadline:
          description: 'Last date the item''s boleto can be paid, YYYY-MM-DD, computed by the service: it is not a member of the batch request. Its due date plus the days the tenant set for the batch''s provider (/v1/admin/providers/{provider_type}/payment-deadline), or plus the provider''s default when none is set, recorded when the batch was created. A later change of the setting does not move it. Absent on an item recorded without one: a batch created before the payment deadline was recorded, or on a provider that registers none.'
          examples:
            - '2030-02-14'
          format: date
          type: string
        position:
          description: 'Position of the item in the request, from 0: its index in the request''s items and in body.items[<i>] of a refusal. Add 1 to show it as item n.'
          examples:
            - 0
          format: int64
          maximum: 24
          minimum: 0
          type: integer
        providerId:
          description: Identifier the payment provider assigned to the item's boleto. Present only once the item is bound to a live boleto at the provider; absent while it is queued or being sent, and on FAILED.
          type: string
        requestedOurNumber:
          description: 'ourNumber requested for the item, in canonical form: no hyphen and no check digit. Absent when the item requested none, and on an item that failed with PBP-0108 on creation. Distinct from ourNumber, which reports the boleto.'
          examples:
            - '00000000152'
          type: string
        status:
          description: 'Status of the item''s boleto, the same GET /v1/boletos/{id} answers. PENDING covers an item queued, sent or still being processed; CREATED is a registered item with barcode and digitable line. An item becomes FAILED only once it is certain that no boleto was registered for it. REVERSED: the payment was returned to the payer; the boleto will not be paid.'
          enum:
            - PENDING
            - CREATED
            - SETTLED
            - CANCELED
            - INACTIVATED
            - FAILED
            - REVERSED
          examples:
            - CREATED
          type: string
      required:
        - position
        - boletoId
        - status
        - overdue
        - cancelable
        - amount
        - dueDate
        - payer
      type: object
    BoletoBatchOutcome:
      description: 'Issuance outcome of the batch, derived from its items on every read. CREATED: some item is still PENDING. COMPLETED: no item is PENDING and none is FAILED. PARTIAL_FAILURE: no item is PENDING and some, not all, are FAILED; those carry errorCode and errorMessage. FAILED: every item is FAILED. Only issuance moves it: payment, cancellation and write-off do not, and it never moves back to CREATED.'
      enum:
        - CREATED
        - COMPLETED
        - PARTIAL_FAILURE
        - FAILED
      type: string
    BoletoBatchProviderBinding:
      additionalProperties: false
      properties:
        batchId:
          examples:
            - 0199b2c3-d4e5-7f60-8a1b-2c3d4e5f6a7b
          format: uuid
          type: string
        providerAccountId:
          description: Provider account resolved for the batch at creation. Null when the installation has no account discovery and the batch carries no nosso número.
          examples:
            - '001234567'
          maxLength: 100
          type:
            - string
            - 'null'
        providerType:
          description: Provider identifier, uppercase. Records created before provider routing read BTG.
          examples:
            - BTG
          maxLength: 20
          minLength: 1
          pattern: ^[A-Z][A-Z0-9_]{0,19}$
          type: string
      required:
        - batchId
        - providerType
        - providerAccountId
      type: object
    BoletoBatchResponse:
      additionalProperties: false
      properties:
        batchId:
          description: Batch identifier.
          examples:
            - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          type: string
        closed:
          description: 'Whether every item is SETTLED, CANCELED, INACTIVATED, REVERSED or FAILED: nothing else will happen to the batch, payment included. Always present. It moves back to false when a cancellation is refused and the item returns to CREATED. True implies finished.'
          type: boolean
        counts:
          $ref: '#/components/schemas/BoletoBatchCounts'
        createdAt:
          description: When the batch was created, RFC 3339 in UTC.
          examples:
            - '2026-10-14T19:34:00Z'
          format: date-time
          type: string
        finished:
          description: 'Whether no item is PENDING: the issuance of the batch is over. Always present. It never moves back to false; an overdue item keeps it false.'
          type: boolean
        items:
          description: 'Every item, in ascending position. Never paginated: a batch holds at most 25 items.'
          items:
            $ref: '#/components/schemas/BoletoBatchItemResponse'
          type:
            - array
            - 'null'
        ledgerId:
          description: Ledger of the batch and of each item.
          examples:
            - 7c1e5b9a-3d2f-4a6b-8e0c-1f2a3b4c5d6e
          format: uuid
          type: string
        midazAccountId:
          description: Collection account of the batch and of each item.
          examples:
            - 3f9a2c1e-5b7d-4e8f-9a0b-1c2d3e4f5a6b
          type: string
        organizationId:
          description: 'Organization the batch was recorded with: always the organization of the X-Organization-Id header.'
          examples:
            - 0f9d6c2a-1b3e-4f5a-8c7d-6e5f4a3b2c1d
          format: uuid
          type: string
        status:
          $ref: '#/components/schemas/BoletoBatchOutcome'
      required:
        - items
        - batchId
        - organizationId
        - ledgerId
        - midazAccountId
        - status
        - closed
        - finished
        - counts
        - createdAt
      type: object
    BoletoBatchSummary:
      additionalProperties: false
      properties:
        batchId:
          description: Batch identifier.
          examples:
            - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          type: string
        closed:
          description: 'Whether every item is SETTLED, CANCELED, INACTIVATED, REVERSED or FAILED: nothing else will happen to the batch, payment included. Always present. It moves back to false when a cancellation is refused and the item returns to CREATED. True implies finished.'
          type: boolean
        counts:
          $ref: '#/components/schemas/BoletoBatchCounts'
        createdAt:
          description: When the batch was created, RFC 3339 in UTC.
          examples:
            - '2026-10-14T19:34:00Z'
          format: date-time
          type: string
        finished:
          description: 'Whether no item is PENDING: the issuance of the batch is over. Always present. It never moves back to false; an overdue item keeps it false.'
          type: boolean
        ledgerId:
          description: Ledger of the batch and of each item.
          examples:
            - 7c1e5b9a-3d2f-4a6b-8e0c-1f2a3b4c5d6e
          format: uuid
          type: string
        midazAccountId:
          description: Collection account of the batch and of each item.
          examples:
            - 3f9a2c1e-5b7d-4e8f-9a0b-1c2d3e4f5a6b
          type: string
        organizationId:
          description: 'Organization the batch was recorded with: always the organization of the X-Organization-Id header.'
          examples:
            - 0f9d6c2a-1b3e-4f5a-8c7d-6e5f4a3b2c1d
          format: uuid
          type: string
        status:
          $ref: '#/components/schemas/BoletoBatchOutcome'
      required:
        - batchId
        - organizationId
        - ledgerId
        - midazAccountId
        - status
        - closed
        - finished
        - counts
        - createdAt
      type: object
    BoletoCancelFailedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        cancelFailedAt:
          description: When the failure of the cancellation was recorded, RFC 3339 in UTC.
          format: date-time
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_CANCEL_FAILED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        rejection:
          $ref: '#/components/schemas/NoticeRejection'
          description: Why the cancellation was refused, as a problem document; present only when the reason is known.
        status:
          description: The boleto is CREATED and can still be paid.
          enum:
            - CREATED
          type: string
      required:
        - event
        - status
        - cancelFailedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoCanceledNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        canceledAt:
          description: When the cancellation was recorded, RFC 3339 in UTC.
          format: date-time
          type: string
        cancellationReason:
          description: Recorded reason of the cancellation.
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_CANCELED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        status:
          description: Boleto status after the write.
          enum:
            - CANCELED
          type: string
      required:
        - event
        - status
        - canceledAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoCapabilities:
      additionalProperties: false
      properties:
        batch:
          $ref: '#/components/schemas/BoletoBatchCapability'
        cancel:
          description: Whether boletos can be cancelled at the provider.
          type: boolean
        chargeStartDates:
          description: Whether the provider registers the start date of the fine and of interest (fine.startDate and interest.startDate of POST /v1/boletos, of each item of POST /v1/boletos/batches and of POST /v1/boletos/installments). Otherwise a boleto, a batch or a series that sends either is refused with 422 PBP-0701 naming BOLETO_CHARGE_START_DATE.
          type: boolean
        documentNumber:
          description: Whether the provider registers the payee's document number (documentNumber of POST /v1/boletos and of each item of POST /v1/boletos/batches, and documentNumbers of POST /v1/boletos/installments). Otherwise a boleto, a batch or a series that sends it is refused with 422 PBP-0701 naming BOLETO_DOCUMENT_NUMBER.
          type: boolean
        earlyAcceptance:
          description: Whether the provider confirms the registration on its own initiative.
          type: boolean
        installments:
          description: Whether installment series are supported (POST /v1/boletos/installments).
          type: boolean
        instructions:
          description: Whether the provider registers the free-text instructions (instructions of POST /v1/boletos and of each item of POST /v1/boletos/batches). Otherwise a boleto or a batch that sends non-empty instructions is refused with 422 PBP-0701 naming BOLETO_INSTRUCTIONS.
          type: boolean
        instrumentBeforeRegistration:
          description: Whether the digitable line, barcode and PDF of a PENDING boleto are valid before the provider confirms the registration.
          type: boolean
        pdf:
          description: Whether the provider renders the boleto PDF (GET /v1/boletos/{id}/pdf).
          type: boolean
        pdfReadiness:
          $ref: '#/components/schemas/PdfReadiness'
        settlement:
          description: 'Who credits the payee when a boleto settles. DIRECT: this service posts the settlement credit to the ledger. HELD: the provider holds the amount and credits the payee itself. A provider that does not declare BOLETO_ISSUANCE reads DIRECT.'
          enum:
            - DIRECT
            - HELD
          examples:
            - DIRECT
          type: string
        titleSearch:
          description: Whether the provider can be searched for titles, which the reconciliation uses to settle uncertain issuances.
          type: boolean
        types:
          description: Boleto types the provider issues. A type outside the list is refused before the call (QR_CODE keeps its current PBP-0006; others PBP-0701). HYBRID may be listed while issuance of the hybrid boleto is still refused by this service.
          items:
            enum:
              - TRADITIONAL
              - QR_CODE
              - HYBRID
            type: string
          type:
            - array
            - 'null'
          uniqueItems: true
      required:
        - types
        - batch
        - installments
        - pdf
        - cancel
        - titleSearch
        - instrumentBeforeRegistration
        - earlyAcceptance
        - pdfReadiness
        - settlement
        - documentNumber
        - chargeStartDates
        - instructions
      type: object
    BoletoCreatedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        batchId:
          description: Batch; only on a batch item.
          format: uuid
          type: string
        batchPosition:
          description: Position of the item in the batch, from zero; only on a batch item.
          format: int64
          maximum: 24
          minimum: 0
          type: integer
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        discount:
          $ref: '#/components/schemas/NoticeDiscountBand'
          description: First discount band; only when the boleto has one.
        discounts:
          description: Every discount band; only when the boleto has one.
          items:
            $ref: '#/components/schemas/NoticeDiscountBand'
          maxItems: 3
          type:
            - array
            - 'null'
        documentNumber:
          description: Document number as the beneficiary sent it; only when the boleto has one.
          type: string
        dueDate:
          description: Due date, a calendar date (YYYY-MM-DD).
          examples:
            - '2026-11-30'
          format: date
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_CREATED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        fine:
          $ref: '#/components/schemas/NoticeFineTerms'
          description: Fine; only when the boleto has one.
        installmentNumber:
          description: Installment number; only on an installment.
          format: int64
          type: integer
        interest:
          $ref: '#/components/schemas/NoticeInterestTerms'
          description: Interest; only when the boleto has it.
        kind:
          description: How the boleto was issued.
          enum:
            - SINGLE
            - INSTALLMENT
            - BATCH
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        ourNumber:
          description: Our number; only when the boleto holds one after the write.
          type: string
        paymentDeadline:
          description: Last day the boleto can be paid (YYYY-MM-DD); only when the boleto has one.
          format: date
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        seriesId:
          description: Installment series; only on an installment.
          type: string
        status:
          description: Boleto status after the write.
          enum:
            - CREATED
          type: string
      required:
        - event
        - status
        - kind
        - dueDate
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoDashboardResponse:
      additionalProperties: false
      properties:
        byStatus:
          additionalProperties:
            $ref: '#/components/schemas/BoletoTypeCountAmount'
          type: object
        byType:
          additionalProperties:
            $ref: '#/components/schemas/BoletoTypeCountAmount'
          type: object
        settlementRate:
          format: double
          type: number
        totalAmount:
          type: string
        totalCanceled:
          format: int64
          type: integer
        totalFailed:
          format: int64
          type: integer
        totalInactivated:
          format: int64
          type: integer
        totalIssued:
          format: int64
          type: integer
        totalOverdue:
          description: 'Boletos past their due date and still unpaid: due before today in the Brazilian civil calendar (UTC-3), with status CREATED, or PENDING with a provider identifier (accepted by the provider and awaiting payment). A boleto due today is not overdue. No business-day calendar is applied: a boleto due on a weekend or holiday counts as overdue from the next calendar day, although it stays payable on the next business day. Every filter of the request applies.'
          format: int64
          type: integer
        totalOverdueAmount:
          description: Sum of the amount of the boletos counted in totalOverdue, as a decimal string with two decimal places.
          type: string
        totalPending:
          format: int64
          type: integer
        totalReversed:
          description: 'Boletos REVERSED: the payment was returned to the payer; the boleto will not be paid. Counted in totalIssued.'
          format: int64
          type: integer
        totalSettled:
          format: int64
          type: integer
        totalSettledAmount:
          type: string
      required:
        - totalIssued
        - totalPending
        - totalSettled
        - totalCanceled
        - totalInactivated
        - totalReversed
        - totalFailed
        - totalOverdue
        - totalAmount
        - totalSettledAmount
        - totalOverdueAmount
        - settlementRate
        - byType
        - byStatus
      type: object
    BoletoExcessPaymentNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_EXCESS_PAYMENT
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        excessPayment:
          $ref: '#/components/schemas/ExcessPaymentNotice'
          description: The payment received through the leg that did not settle the boleto.
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        status:
          description: Boleto status, still SETTLED.
          enum:
            - SETTLED
          type: string
      required:
        - event
        - status
        - excessPayment
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoFailedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        batchId:
          description: Batch; only on a batch item.
          format: uuid
          type: string
        batchPosition:
          description: Position of the item in the batch, from zero; only on a batch item.
          format: int64
          maximum: 24
          minimum: 0
          type: integer
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        errorCode:
          description: Failure code; only when one was recorded.
          type: string
        errorMessage:
          description: Reason recorded on the boleto.
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_FAILED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        failedAt:
          description: When the failure was recorded, RFC 3339 in UTC.
          format: date-time
          type: string
        installmentNumber:
          description: Installment number; only on an installment.
          format: int64
          type: integer
        kind:
          description: How the boleto was issued.
          enum:
            - SINGLE
            - INSTALLMENT
            - BATCH
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        providerReason:
          description: Stable reason from the provider's refusal catalog, when the provider refused the boleto with a catalogued reason.
          type: string
        seriesId:
          description: Installment series; only on an installment.
          type: string
        status:
          description: Boleto status after the write.
          enum:
            - FAILED
          type: string
      required:
        - event
        - status
        - kind
        - errorMessage
        - failedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoInactivatedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_INACTIVATED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        inactivatedAt:
          description: When the boleto was written off because its payment period ended, RFC 3339 in UTC.
          format: date-time
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        status:
          description: Boleto status after the write.
          enum:
            - INACTIVATED
          type: string
      required:
        - event
        - status
        - inactivatedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoOverdueNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        dueDate:
          description: Due date, a calendar date (YYYY-MM-DD).
          examples:
            - '2026-11-15'
          format: date
          type: string
        effectiveDueDate:
          description: Effective due date, the due date moved to a business day, by which the boleto became overdue (YYYY-MM-DD). Equal to or after dueDate.
          examples:
            - '2026-11-17'
          format: date
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_OVERDUE
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Identifier of the boleto's collections title.
          format: uuid
          type: string
        status:
          description: 'Boleto status, still CREATED: the overdue is only sent while the boleto is.'
          enum:
            - CREATED
          type: string
      required:
        - providerId
        - event
        - status
        - dueDate
        - effectiveDueDate
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoPaymentBlockedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        blockedAt:
          description: When the boleto registry noticed that the boleto's payment was blocked, in UTC with milliseconds. When the registry gave no such moment, it is when Payments recorded it, the same instant as occurredAt.
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_PAYMENT_BLOCKED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Identifier of the boleto's collections title.
          format: uuid
          type: string
        status:
          description: Boleto status when the notice was recorded; the block does not change it.
          enum:
            - CREATED
            - SETTLED
            - CANCELED
            - INACTIVATED
            - REVERSED
            - FAILED
          type: string
      required:
        - providerId
        - event
        - status
        - blockedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoPaymentUnblockedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_PAYMENT_UNBLOCKED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Identifier of the boleto's collections title.
          format: uuid
          type: string
        status:
          description: Boleto status when the notice was recorded; the unblock does not change it.
          enum:
            - CREATED
            - SETTLED
            - CANCELED
            - INACTIVATED
            - REVERSED
            - FAILED
          type: string
        unblockedAt:
          description: When the boleto registry noticed that the boleto's payment was unblocked, in UTC with milliseconds. When the registry gave no such moment, it is when Payments recorded it, the same instant as occurredAt.
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          type: string
      required:
        - providerId
        - event
        - status
        - unblockedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoProviderBinding:
      additionalProperties: false
      properties:
        boletoId:
          examples:
            - 123e4567-e89b-12d3-a456-426614174000
          format: uuid
          type: string
        providerAccountId:
          description: 'Provider account the boleto was issued on. Null only in these cases. An installment of a series created without ourNumbers: until the series'' first emission looks its account up at the provider. Such an installment, for good: when that lookup found no numbering account for the series'' midazAccountId, because the installation has no account discovery or the account was not yet enabled at the provider. A boleto created without ourNumber whose lookup at creation found no numbering account for its midazAccountId: until the provider''s answer to the issuance names an account; on an installation without account discovery the answer names none, and the boleto is issued on the credential''s default account.'
          examples:
            - '001234567'
          maxLength: 100
          type:
            - string
            - 'null'
        providerId:
          description: Identifier of the boleto at the provider. Null while the provider has not returned one (PENDING without identifier).
          examples:
            - 8f2a1c3d-4e5b-6a7c-8d9e-0f1a2b3c4d5e
          maxLength: 100
          type:
            - string
            - 'null'
        providerType:
          description: Provider identifier, uppercase. Records created before provider routing read BTG.
          examples:
            - BTG
          maxLength: 20
          minLength: 1
          pattern: ^[A-Z][A-Z0-9_]{0,19}$
          type: string
      required:
        - boletoId
        - providerType
        - providerId
        - providerAccountId
      type: object
    BoletoReversedNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_REVERSED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        reversedAt:
          description: When Payments applied the reversal, RFC 3339 in UTC.
          format: date-time
          type: string
        status:
          description: Boleto status after the write.
          enum:
            - REVERSED
          type: string
      required:
        - event
        - status
        - reversedAt
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoSettledNotice:
      additionalProperties: true
      properties:
        amount:
          description: Boleto amount, a decimal string with two places.
          examples:
            - '150.00'
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        boletoId:
          description: Boleto identifier.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - BOLETO
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - BOLETO_SETTLED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        occurredAt:
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts.'
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        paidVia:
          description: Leg that settled the boleto.
          enum:
            - BOLETO
            - PIX
          type: string
        providerId:
          description: Boleto identifier at the provider; absent when the provider gave none.
          type: string
        settledAmount:
          description: Amount paid, as the provider reported it.
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        settledAt:
          description: When the payment happened, as the provider reported it, RFC 3339 in UTC, in seconds.
          format: date-time
          type: string
        status:
          description: Boleto status after the write.
          enum:
            - SETTLED
          type: string
        settlement:
          $ref: '#/components/schemas/BoletoSettlement'
          description: 'New. Mode, stage and cycle when the credit became available: DIRECT/RELEASED at settlement, or HELD/RELEASED with releasedAt at release.'
          x-mint:
            post:
              - Under development
      required:
        - event
        - status
        - settledAmount
        - settledAt
        - paidVia
        - entityType
        - boletoId
        - amount
        - occurredAt
        - eventId
      type: object
    BoletoTypeCountAmount:
      additionalProperties: false
      properties:
        amount:
          type: string
        count:
          format: int64
          type: integer
      required:
        - count
        - amount
      type: object
    BulkAdoptionGroupCounts:
      additionalProperties: false
      properties:
        adoptable:
          description: 'Divergences whose holder has a single ledger account: the group the bulk adoption takes.'
          examples:
            - 1840
          format: int64
          minimum: 0
          type: integer
        ambiguousAccount:
          description: Divergences whose holder has several ledger accounts, adopted one by one naming the account.
          examples:
            - 37
          format: int64
          minimum: 0
          type: integer
        noLedgerAccount:
          description: Divergences whose holder has no ledger account, or was not found by the document.
          examples:
            - 12
          format: int64
          minimum: 0
          type: integer
      required:
        - adoptable
        - ambiguousAccount
        - noLedgerAccount
      type: object
    BulkAdoptionPreview:
      additionalProperties: false
      properties:
        adoptCount:
          description: 'How many the confirmation takes now: eligibleCount up to 5,000, the oldest first.'
          examples:
            - 1840
          format: int64
          maximum: 5000
          minimum: 0
          type: integer
        eligibleCount:
          description: 'Adoptable divergences now, equal to groups.adoptable: the confirmation''s expectedCount.'
          examples:
            - 1840
          format: int64
          minimum: 0
          type: integer
        group:
          description: Group of the page's items.
          enum:
            - ADOPTABLE
            - AMBIGUOUS_ACCOUNT
            - NO_LEDGER_ACCOUNT
          examples:
            - ADOPTABLE
          type: string
        groups:
          $ref: '#/components/schemas/BulkAdoptionGroupCounts'
          description: Count of each of the three groups, whatever group the page shows.
        inventoryRunId:
          description: Identifier of the inventory consumption.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
          format: uuid
          type: string
        items:
          description: The page's divergences, oldest first.
          items:
            $ref: '#/components/schemas/BulkAdoptionPreviewItem'
          type: array
        limit:
          description: Most divergences the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
        previewFingerprint:
          description: 'Fingerprint of the whole adoptable group of this preview, recomputed by the confirmation: SHA-256, in lower-case hex, of the UTF-8 text <inventoryRunId>\n<productType or empty>\n followed by one line <divergenceId>:<accountId>\n per adoptable divergence, in increasing divergenceId order. The confirmation''s previewFingerprint.'
          examples:
            - 9f2c4e1a7b3d5f60812a4c6e8b0d2f4a6c8e0a2b4d6f8091a3c5e7f9b1d3f5a7
          pattern: ^[0-9a-f]{64}$
          type: string
        productType:
          description: Product type filter applied; null for every type.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type:
            - string
            - 'null'
      required:
        - limit
        - inventoryRunId
        - eligibleCount
        - adoptCount
        - previewFingerprint
        - groups
        - group
        - items
      type: object
    BulkAdoptionPreviewItem:
      additionalProperties: false
      properties:
        accountId:
          description: The holder's single ledger account, in the ADOPTABLE group; null in the others.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a22
          format: uuid
          type:
            - string
            - 'null'
        adoptionBlockReason:
          description: Why the divergence is not adopted without the operator's decision; null in the ADOPTABLE group.
          enum:
            - AMBIGUOUS_ACCOUNT
            - NO_LEDGER_ACCOUNT
          examples:
            - AMBIGUOUS_ACCOUNT
          type:
            - string
            - 'null'
        detectedAt:
          description: When the divergence was detected, RFC 3339 in UTC.
          examples:
            - '2026-11-11T09:00:00Z'
          format: date-time
          type: string
        divergenceId:
          description: Identifier of the divergence.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a21
          format: uuid
          type: string
        nucleaBeneficiaryNumber:
          description: The beneficiary's number at Núclea; null when unknown.
          examples:
            - '1234567890'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        organizationId:
          description: Midaz organization of the account; null without one.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        productType:
          description: Product type of the divergent agreement at Núclea, as the beneficiary base carries it; null when the base carries none.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type:
            - string
            - 'null'
      required:
        - divergenceId
        - detectedAt
      type: object
    BulkAdoptionRequest:
      additionalProperties: false
      properties:
        expectedCount:
          description: 'The preview''s eligibleCount with the same filter: every adoptable divergence, even above 5,000. Another count than the current one is refused with 409 PBP-0822.'
          examples:
            - 1840
          format: int64
          minimum: 1
          type: integer
        previewFingerprint:
          description: The preview's previewFingerprint with the same filter, recomputed over the adoptable group now; another one is refused with 409 PBP-0822.
          examples:
            - 9f2c4e1a7b3d5f60812a4c6e8b0d2f4a6c8e0a2b4d6f8091a3c5e7f9b1d3f5a7
          pattern: ^[0-9a-f]{64}$
          type: string
        productType:
          description: Product type filter of the preview confirmed; left out for every type. Only 01 and 07 are adopted; any other is refused with 422 PBP-0801.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type: string
        reason:
          description: Reason for the bulk adoption, recorded in the audit trail. Must not carry personal data.
          examples:
            - Initial load reviewed with the treasury.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - expectedCount
        - previewFingerprint
        - reason
      type: object
    CancelBoletoBatchItemResult:
      additionalProperties: false
      properties:
        boletoId:
          description: Identifier of the item's boleto.
          format: uuid
          type: string
        cancellationId:
          description: 'Identifier of the cancellation attempt: the one that canceled the item, with CANCELED, or the one the provider accepted, with CANCELLATION_PENDING. Absent with the other results.'
          examples:
            - 0199a1b2-3c4d-7e5f-8a9b-0c1d2e3f4a5b
          format: uuid
          type: string
        errorCode:
          description: Product code of the outcome. Present with NOT_CANCELABLE (PBP-0103) and with CANCEL_FAILED.
          examples:
            - PBP-0103
          pattern: ^PBP-[0-9]{4}$
          type: string
        errorMessage:
          description: Readable reason, present with errorCode. Translate it by errorCode.
          examples:
            - boleto is SETTLED and cannot be canceled
          type: string
        position:
          description: Position of the item in the request, from 0.
          examples:
            - 0
          format: int64
          maximum: 24
          minimum: 0
          type: integer
        result:
          description: 'Outcome of the request for the item. CANCELED: this request canceled it. CANCELLATION_PENDING: the payment provider accepted the cancellation and confirms it later; the item stays CREATED until BOLETO_CANCELED or BOLETO_CANCEL_FAILED, and asking again answers it the same without a new attempt. NOT_CANCELABLE: the item could not be canceled, and status says why (SETTLED paid, CANCELED already canceled, INACTIVATED written off, REVERSED payment returned to the payer, FAILED failed, PENDING not cancelable yet); errorCode is PBP-0103, and it is not an error. CANCEL_FAILED: the cancellation was attempted and refused, with the code and message the single boleto cancellation gives; asking again retries only these and the items that became cancelable.'
          enum:
            - CANCELED
            - CANCELLATION_PENDING
            - NOT_CANCELABLE
            - CANCEL_FAILED
          examples:
            - CANCELED
          type: string
        status:
          description: 'Status of the item''s boleto after the attempt. REVERSED: the payment was returned to the payer; the boleto will not be paid.'
          enum:
            - PENDING
            - CREATED
            - SETTLED
            - CANCELED
            - INACTIVATED
            - FAILED
            - REVERSED
          examples:
            - CANCELED
          type: string
      required:
        - position
        - boletoId
        - result
        - status
      type: object
    CancelBoletoBatchRequest:
      additionalProperties: false
      properties:
        reason:
          description: 'Reason for the cancellation, recorded on every item canceled as its cancellationReason. Required: absent, blank once trimmed or longer than 500 characters is refused with 400 PBP-0001, with the same messages as POST /v1/boletos/{id}/cancel.'
          examples:
            - Cobrança emitida em duplicidade
          type: string
      required:
        - reason
      type: object
    CancelBoletoBatchResponse:
      additionalProperties: false
      properties:
        batchId:
          description: Batch identifier.
          examples:
            - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          type: string
        items:
          description: One result per item of the batch, in ascending position.
          items:
            $ref: '#/components/schemas/CancelBoletoBatchItemResult'
          type:
            - array
            - 'null'
      required:
        - batchId
        - items
      type: object
    CancelBoletoPendingResponse:
      additionalProperties: false
      properties:
        cancellationId:
          description: Id of the recorded cancellation attempt, the same as in pendingCancellation; not the key sent to the provider.
          format: uuid
          type: string
        id:
          description: Boleto identifier.
          format: uuid
          type: string
        pendingCancellation:
          $ref: '#/components/schemas/PendingCancellationResponse'
          description: The cancellation awaiting the provider's confirmation, as the boleto read shows it.
        status:
          description: The boleto stays CREATED until BOLETO_CANCELED or BOLETO_CANCEL_FAILED.
          enum:
            - CREATED
          type: string
      required:
        - id
        - status
        - cancellationId
        - pendingCancellation
      type: object
    CancelBoletoRequest:
      additionalProperties: false
      properties:
        reason:
          type: string
      required:
        - reason
      type: object
    CancelBoletoResponse:
      additionalProperties: false
      properties:
        canceledAt:
          type: string
        cancellationId:
          description: 'Id of the recorded cancellation attempt that canceled the boleto; not the key sent to the provider. Absent when the boleto was canceled without a recorded attempt: before attempts were recorded, or by the provider alone.'
          format: uuid
          type: string
        cancellationReason:
          type: string
        id:
          type: string
        ledgerId:
          description: Midaz ledger the boleto was written with. Always present.
          type: string
        organizationId:
          description: Midaz organization the boleto was written with. Always present.
          type: string
        providerId:
          type: string
        status:
          type: string
      required:
        - id
        - providerId
        - organizationId
        - ledgerId
        - status
        - canceledAt
        - cancellationReason
      type: object
    CancelPaymentRequest:
      additionalProperties: false
      properties:
        reason:
          type: string
      required:
        - reason
      type: object
    CollectionsSettings:
      additionalProperties: false
      properties:
        agreementTemplate:
          description: Default agreement template, in product type order.
          items:
            $ref: '#/components/schemas/AgreementSpec'
          maxItems: 8
          minItems: 1
          type: array
        autoEnablement:
          description: Whether a holder's agreement is enabled automatically on their first boleto.
          examples:
            - false
          type: boolean
        businessRetentionYears:
          description: 'Retention of business records, in years. The value is recorded only: no business record is purged.'
          examples:
            - 10
          format: int64
          maximum: 30
          minimum: 5
          type: integer
        ready:
          description: Whether the tenant's PCR connection is active and the agreement template holds at least one item.
          examples:
            - true
          type: boolean
        technicalRetentionDays:
          description: Retention of technical records, in days counted from each record's final state.
          examples:
            - 90
          format: int64
          maximum: 3650
          minimum: 30
          type: integer
        updatedAt:
          description: When the settings last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-09T15:04:05Z'
          format: date-time
          type: string
        updatedBy:
          $ref: '#/components/schemas/Actor'
          description: Who made the last change.
        version:
          description: Version of the settings; a replacement sends it back.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
      required:
        - agreementTemplate
        - autoEnablement
        - technicalRetentionDays
        - businessRetentionYears
        - ready
        - version
        - updatedAt
      type: object
    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
    ConfigurePaymentDeadlineRequest:
      additionalProperties: false
      properties:
        days:
          description: 'Calendar days after the due date; 0 is a deadline on the due date. Null returns to the provider''s default. Required: send null explicitly to return to the default. Above the provider''s maxDays is refused with 422 PBP-0702 reason PAYMENT_DEADLINE_ABOVE_MAXIMUM.'
          examples:
            - 10
          format: int64
          maximum: 3650
          minimum: 0
          type:
            - integer
            - 'null'
        reason:
          description: Why the deadline is changed. Recorded in the history. Blank is refused with 400 PBP-0001.
          examples:
            - Shorter collection window for this portfolio.
          maxLength: 500
          minLength: 1
          pattern: \S
          type: string
        version:
          description: The setting's current version, as read; 0 when never written.
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
      required:
        - days
        - reason
        - version
      type: object
    ConfigurePixConfigRequest:
      additionalProperties: false
      properties:
        pixKey:
          description: 'Pix key of the tenant''s collection account, the receiver of the Pix payment of the tenant''s boletos that carry a Pix QR code. Accepted formats: random key (lowercase UUID), CPF (11 digits), CNPJ (14 digits), e-mail (lowercase, at most 77 characters) and phone (+, country code and number). The operation answers 501 PBP-0127 and the key is not written.'
          examples:
            - f34f8ec2-a4b7-41b4-8200-b53a07e00bac
          maxLength: 77
          pattern: ^([0-9]{11}|[0-9]{14}|[+][1-9][0-9][0-9]{1,14}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[a-z0-9.!#$&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:[.][a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*)$
          type: string
          x-pattern-description: 'a Pix key: a random key (lowercase UUID), a CPF (11 digits), a CNPJ (14 digits), a lowercase e-mail or a phone (+, country code and number)'
        receiverAddress:
          $ref: '#/components/schemas/PixReceiverAddressRequest'
          description: Address of the holder of the account the key belongs to, the receiver of the Pix payment. A boleto that carries a Pix QR code requires it, and the account record does not provide it.
      required:
        - pixKey
        - receiverAddress
      type: object
    ConfigureProviderRouteRequest:
      additionalProperties: false
      properties:
        providerType:
          description: Provider to route the operation to, or null to leave the operation without provider. Must be installed, connected to the tenant, and declare the operation.
          examples:
            - BTG
          maxLength: 20
          minLength: 1
          pattern: ^[A-Z][A-Z0-9_]{0,19}$
          type:
            - string
            - 'null'
        reason:
          description: Why the route is changed. Recorded in the history and shown to the tenant. Blank is refused with 400 PBP-0001.
          examples:
            - 'Onboarding do tenant: emissão no BTG.'
          maxLength: 500
          minLength: 1
          pattern: \S
          type: string
        version:
          description: The operation's current version, as read; 0 for an operation never configured.
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
      required:
        - providerType
        - reason
        - version
      type: object
    ConfigureWebhookRequest:
      additionalProperties: false
      properties:
        active:
          type: boolean
        callbackUrl:
          type: string
        enabledEvents:
          description: 'Event types the configuration receives, any of: BOLETO_CREATED, BOLETO_SETTLED, BOLETO_REVERSED, BOLETO_CANCELED, BOLETO_CANCEL_FAILED, BOLETO_INACTIVATED, BOLETO_FAILED, BOLETO_EXCESS_PAYMENT, BOLETO_BATCH_FINISHED, PAYMENT_SETTLED, PAYMENT_REJECTED, PAYMENT_FAILED, PAYMENT_CANCELED, PAYMENT_SCHEDULED, PIX_KEY_CHANGED (the notice that the tenant''s Pix key changed), BOLETO_AMENDED, BOLETO_AMENDMENT_REJECTED (the notices that an amendment request of a boleto was applied or refused), BOLETO_OVERDUE, BOLETO_PAYMENT_BLOCKED, BOLETO_PAYMENT_UNBLOCKED (the notices that a boleto became overdue and that its payment was blocked or unblocked). A type outside this list is refused. The list holds at most 64 entries.'
          items:
            type: string
          maxItems: 64
          type:
            - array
            - 'null'
        secret:
          type: string
      required:
        - callbackUrl
        - secret
        - enabledEvents
      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
    ConfiguredPaymentDeadlineResponse:
      additionalProperties: false
      properties:
        aboveMaximum:
          description: 'True when the configured days are past maxDays: the provider''s maximum fell below them after they were written. Write days within maxDays, or return to the default.'
          examples:
            - false
          type: boolean
        changeId:
          description: Identifier of the history line this write recorded.
          examples:
            - 019a5c1e-2b3d-7f4a-8c5d-6e7f8a9b0c1d
          format: uuid
          type: string
        days:
          description: Calendar days after the due date of the payment deadline in force; 0 is a deadline on the due date. The tenant's days, or providerDefaultDays when it configured none.
          examples:
            - 30
          format: int64
          minimum: 0
          type: integer
        isDefault:
          description: 'True when no days are configured for the provider, or they were returned to the default: the provider''s default applies.'
          examples:
            - true
          type: boolean
        maxDays:
          description: Furthest deadline the provider accepts, in calendar days after the due date. A write above it is refused with 422 PBP-0702 reason PAYMENT_DEADLINE_ABOVE_MAXIMUM.
          examples:
            - 365
          format: int64
          minimum: 0
          type: integer
        providerDefaultDays:
          description: Default payment deadline the provider declares, in calendar days after the due date.
          examples:
            - 30
          format: int64
          minimum: 0
          type: integer
        providerType:
          description: Provider the setting belongs to.
          examples:
            - BTG
          maxLength: 20
          type: string
        updatedAt:
          description: When the setting was last written, in UTC. Null when never written.
          examples:
            - '2026-11-15T14:05:09Z'
          format: date-time
          type:
            - string
            - 'null'
        updatedByType:
          description: Kind of principal of the last write. Null when never written.
          enum:
            - USER
            - MACHINE
            - SYSTEM
          examples:
            - USER
          type:
            - string
            - 'null'
        version:
          description: Version of this (tenant, provider) setting. 0 when never written. Incremented by every accepted write, including a return to the default. A write sends it back; a stale one is refused with 409 PBP-0705.
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
      required:
        - changeId
        - providerType
        - days
        - isDefault
        - providerDefaultDays
        - maxDays
        - aboveMaximum
        - version
        - updatedAt
        - updatedByType
      type: object
    ConfiguredPixConfigResponse:
      additionalProperties: false
      properties:
        complete:
          description: Whether the configuration has every member a boleto that carries a Pix QR code needs from it; always true after a write, which requires them all. As on the read, it does not guarantee that an issuance is accepted.
          type: boolean
        pixKey:
          description: The configured Pix key.
          examples:
            - f34f8ec2-a4b7-41b4-8200-b53a07e00bac
          type: string
        updatedAt:
          description: When this write was recorded, in UTC.
          examples:
            - '2026-10-13T15:04:05Z'
          format: date-time
          type: string
        updatedBy:
          description: 'Identifier of the authenticated principal that made this write: the subject of its access token.'
          type: string
        receiverAddress:
          $ref: '#/components/schemas/PixReceiverAddressResponse'
          description: The receiver's address. Omitted when none is configured; a member that is not configured is omitted too.
          x-mint:
            post:
              - Under development
      required:
        - pixKey
        - complete
        - updatedAt
        - updatedBy
      type: object
    ConfiguredProviderRouteResponse:
      additionalProperties: false
      properties:
        changeId:
          description: Identifier of the history line this write recorded.
          examples:
            - 019a3b8e-6f1c-7d2e-8a4b-5c6d7e8f9a01
          format: uuid
          type: string
        route:
          $ref: '#/components/schemas/ProviderRouteEntry'
          description: The route of the operation as written, with its new version.
      required:
        - route
        - changeId
      type: object
    ConsultBillBeneficiaryResponse:
      additionalProperties: false
      properties:
        document:
          description: Beneficiary document, masked.
          type: string
        name:
          description: Beneficiary name.
          type: string
        personType:
          description: PF for a person, PJ for a company, null for anything else the source reported, including nothing.
          enum:
            - PF
            - PJ
            -
          type:
            - string
            - 'null'
      required:
        - name
        - document
        - personType
      type:
        - object
        - 'null'
    ConsultBillPaymentWindowResponse:
      additionalProperties: false
      properties:
        end:
          description: Closing time of the window.
          type: string
        start:
          description: Opening time of the window.
          type: string
      required:
        - start
        - end
      type:
        - object
        - 'null'
    ConsultBillReceiverBankResponse:
      additionalProperties: false
      properties:
        code:
          description: Bank code, three digits.
          type: string
        ispb:
          description: Bank ISPB.
          type: string
        name:
          description: Bank name.
          type: string
      required:
        - name
        - ispb
        - code
      type:
        - object
        - 'null'
    ConsultBillRequest:
      additionalProperties: false
      properties:
        digitableLine:
          description: 'Digitable line, digits only: 47 for a bank slip, or 48 starting with 8 for a utilities bill.'
          maxLength: 48
          minLength: 47
          pattern: ^(?:[0-79][0-9]{46}|8[0-9]{47})$
          type: string
      required:
        - digitableLine
      type: object
    ConsultBillResponse:
      additionalProperties: false
      properties:
        amount:
          description: Consulted amount, two decimal places.
          type: string
        assignor:
          description: Utility company. Utilities only.
          type:
            - string
            - 'null'
        beneficiary:
          $ref: '#/components/schemas/ConsultBillBeneficiaryResponse'
          description: Who receives the money, with the document masked.
        discount:
          description: Discount granted. Bank slip only.
          type:
            - string
            - 'null'
        dueDate:
          description: Due date. Bank slip only.
          format: date
          type:
            - string
            - 'null'
        fine:
          description: Fine charged. Bank slip only.
          type:
            - string
            - 'null'
        interest:
          description: Interest charged. Bank slip only.
          type:
            - string
            - 'null'
        limitDate:
          description: Last date the slip is payable. Bank slip only.
          format: date
          type:
            - string
            - 'null'
        maxAmount:
          description: Highest payable amount, when the source reports a band.
          type:
            - string
            - 'null'
        minAmount:
          description: Lowest payable amount, when the source reports a band.
          type:
            - string
            - 'null'
        originalAmount:
          description: Face value of the slip. Bank slip only.
          type:
            - string
            - 'null'
        payable:
          description: Whether the source accepts the bill for payment, as it reported. Bank slip only.
          type:
            - boolean
            - 'null'
        paymentWindow:
          $ref: '#/components/schemas/ConsultBillPaymentWindowResponse'
          description: Time of day the bill can be paid. Utilities only.
        receiverBank:
          $ref: '#/components/schemas/ConsultBillReceiverBankResponse'
          description: Bank that receives the payment. Bank slip only.
        segment:
          description: FEBRABAN segment the line was consulted on.
          type: string
        settlementDate:
          description: Settlement date the source reported. Utilities only; it is not a due date.
          format: date
          type:
            - string
            - 'null'
        state:
          description: Federative unit of the utility. Utilities only.
          type:
            - string
            - 'null'
        utilitySegment:
          description: The source's own segment text. Utilities only.
          type:
            - string
            - 'null'
      required:
        - segment
        - payable
        - amount
        - originalAmount
        - minAmount
        - maxAmount
        - fine
        - interest
        - discount
        - dueDate
        - limitDate
        - beneficiary
        - receiverBank
        - assignor
        - utilitySegment
        - state
        - paymentWindow
        - settlementDate
      type: object
    CreateAgreementRequest:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the organization X-Organization-Id names, whose holder is already enabled for collections.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        agreement:
          $ref: '#/components/schemas/AgreementSpec'
          description: Issuing rules of the agreement.
        ledgerId:
          description: 'Midaz ledger of the account. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6c
          type: string
        reason:
          description: Reason for the creation, recorded in the audit trail. Must not carry personal data.
          examples:
            - Boleto agreement for the account of the new branch.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - accountId
        - agreement
        - reason
      type: object
    CreateBoletoBatchItemRequest:
      additionalProperties: false
      properties:
        amount:
          description: Amount as a decimal string, at most two decimal places, greater than zero.
          examples:
            - '150.00'
          maxLength: 32
          type: string
        discount:
          $ref: '#/components/schemas/DiscountRequest'
        documentNumber:
          description: 'Payee''s own reference for the charge (seu numero), such as an invoice number: 1 to 15 printable ASCII characters (space through tilde: letters A-Z and a-z without accents, digits, space and punctuation), stored as given. Optional item by item; the same member and rule as on POST /v1/boletos. A value that is empty, longer than 15 characters or that carries any other character (an accented letter, a control character or any character outside ASCII) is refused with 400 PBP-0001; a value made only of spaces, or that carries markup, is an item problem PBP-0001, reported in 422 PBP-0123 with every other problem of the batch. When the provider that serves the issuance does not register it, the whole batch is refused with 422 PBP-0701, naming BOLETO_DOCUMENT_NUMBER in the capability member; nothing is recorded and the provider is not called.'
          examples:
            - NF-2030/0001
          maxLength: 15
          minLength: 1
          pattern: ^[ -~]{1,15}$
          type: string
        dueDate:
          description: Due date, YYYY-MM-DD.
          examples:
            - '2030-01-15'
          format: date
          type: string
        fine:
          $ref: '#/components/schemas/FineRequest'
        instructions:
          description: Instructions printed on the boleto, free text. Optional; the same member and rule as on POST /v1/boletos. When the provider that serves the issuance does not register them, non-empty instructions on any item refuse the whole batch with 422 PBP-0701, naming BOLETO_INSTRUCTIONS in the capability member; nothing is recorded and the provider is not called.
          examples:
            - Mensalidade de janeiro
          type: string
        interest:
          $ref: '#/components/schemas/InterestRequest'
        ourNumber:
          description: 'Bank-side identification of the boleto (nosso numero), chosen by the payee. Optional item by item: when absent, the number is assigned at issuance. Same form as on POST /v1/boletos: surrounding spaces are removed, a hyphen is accepted only when followed by exactly one digit, which is discarded, and leading zeros do not make a different number. Two items of the batch with the same number are an item problem PBP-0125 on both, and the batch is refused. A number already held by an active boleto of the same collection account does not refuse the batch: that item alone ends FAILED with errorCode PBP-0108, and the other items go on.'
          examples:
            - '00000000152'
          type: string
        payer:
          $ref: '#/components/schemas/PayerRequest'
        type:
          description: 'Boleto type. Only TRADITIONAL is issued in a batch: HYBRID, QR_CODE or any other value is an item problem PBP-0006, reported in 422 PBP-0123 with every other problem of the batch.'
          examples:
            - TRADITIONAL
          type: string
      required:
        - type
        - payer
        - amount
        - dueDate
      type: object
    CreateBoletoBatchRequest:
      additionalProperties: false
      properties:
        items:
          description: 'Boletos of the batch, from 1 to 25, in the order the client wants to see them. The position of each item is its index in this list, from 0: the position of the response and the index of body.items[<i>] in a refusal. A list outside 1 to 25 items, the empty list included, refuses the whole batch with 422 PBP-0122, which carries the limit and the number of items received; the batch is never split.'
          items:
            $ref: '#/components/schemas/CreateBoletoBatchItemRequest'
          type: array
        ledgerId:
          description: 'Midaz ledger the account lives in and the entry is posted to. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          type: string
        midazAccountId:
          description: Midaz account every item of the batch settles into. Its holder is the final beneficiary of every item. It must belong to the organization and the ledger, or the request is answered 404. Checked once per batch.
          type: string
      required:
        - midazAccountId
        - items
      type: object
    CreateBoletoRequest:
      additionalProperties: false
      properties:
        amount:
          description: |-
            Face value in BRL, as a decimal string with up to 2 decimal places.

            - Lerian (PCR): must be below `100000000.00`. Otherwise 422 `PBP-0006` naming the member, before anything is recorded.
          examples:
            - '100.00'
          maxLength: 32
          type: string
        discount:
          $ref: '#/components/schemas/DiscountRequest'
          description: 'One discount band, granted when the boleto is paid on or before `limitDate`. Use `discounts` for more than one. Sending `discount` and `discounts` together is refused with 422 `PBP-0006` naming `discounts`.'
        discounts:
          description: |-
            1 to 3 discount bands, in the order they apply. Each band grants its amount when the boleto is paid on or before its `limitDate`.

            - All bands have the type of the first band.
            - Each `limitDate` is after the previous one and before the due date. Otherwise 422 `PBP-0006` naming the band, as in `discounts[1].limitDate`.
            - One band is the same as `discount`. Do not send both (422 `PBP-0006` naming `discounts`).
            - More than one band, on a provider that does not register them, is refused with 422 `PBP-0701` and `capability` `BOLETO_DISCOUNT_BANDS`.
          items:
            $ref: '#/components/schemas/DiscountRequest'
          maxItems: 3
          minItems: 1
          type:
            - array
            - 'null'
        documentNumber:
          description: |-
            Your own reference for the charge (seu número), such as an invoice number. Optional. It does not have to be unique, and it is stored as sent.

            - 1 to 15 printable ASCII characters (space through tilde: letters without accents, digits, space and punctuation).
            - Empty, longer than 15 characters, only spaces, any other character (accented letter, control character, non-ASCII) or markup: 400 `PBP-0001`. A longer value is refused, never cut.
            - A provider that does not register it refuses it with 422 `PBP-0701` and `capability` `BOLETO_DOCUMENT_NUMBER`. Nothing is recorded and the provider is not called.
          examples:
            - NF-2030/0001
          maxLength: 15
          minLength: 1
          pattern: ^[ -~]{1,15}$
          type: string
        dueDate:
          description: |-
            Due date, `YYYY-MM-DD`.

            - Lerian (PCR): at most 3650 days after the issuance day. Otherwise 422 `PBP-0006` naming the member, before anything is recorded.
          examples:
            - '2030-01-15'
          format: date
          type: string
        fine:
          $ref: '#/components/schemas/FineRequest'
        instructions:
          description: |-
            Free-text instructions printed on the boleto. Optional.

            - BTG: accepted.
            - Lerian (PCR): non-empty instructions are refused with 422 `PBP-0701` and `capability` `BOLETO_INSTRUCTIONS`. Nothing is recorded and the provider is not called.
          type: string
        interest:
          $ref: '#/components/schemas/InterestRequest'
        ledgerId:
          description: 'Midaz ledger the account belongs to and the entry is posted to. Required. Absent, blank or not a canonical UUID: 400 `PBP-0026`.'
          type: string
        midazAccountId:
          description: Midaz account the boleto settles into. Its holder is the final beneficiary.
          type: string
        ourNumber:
          description: |-
            Bank identification of the boleto (nosso número), chosen by you. Optional: without it, the provider assigns the number.

            - Digits only. Surrounding spaces are removed. A hyphen is accepted only when followed by exactly one digit, which is dropped because the bank computes the check digit: `152-3` is sent as `152`; `152-` and `152-abc` are refused.
            - Leading zeros do not count: `152` and `00000000152` are the same number.
            - Maximum width, in significant digits: BTG 11, Lerian (PCR) 16. Read `numbering.maxWidth` in `GET /v1/admin/providers/capabilities`.
            - Format and width refusals: 400 `PBP-0001`. A provider that does not accept a number you choose: 422 `PBP-0701` with `capability` `CLIENT_SUPPLIED_OUR_NUMBER`.
            - A number held by an active boleto of any type of the same provider account (a hybrid issued earlier included) is refused with 422 `PBP-0108`, before the provider is called. When the holder can be read, the `detail` names it and `ourNumberHolderBoletoId` carries its id. It can be an earlier emission of the same charge: read it before you use another number. When it is an emission still without a provider answer, the `detail` says so.
            - After a 422 `PBP-0014` or a `5xx` answered once the emission was sent, the number stays held until reconciliation resolves that emission, which happens no earlier than a grace period (30 minutes by default). Meanwhile that emission can still become a live boleto: issuing the same charge with another number can leave two boletos. Refusals answered before the emission was sent hold nothing.
          examples:
            - '00000000152'
          type: string
        payer:
          $ref: '#/components/schemas/PayerRequest'
        paymentDeadline:
          description: |-
            Last day the boleto can be paid, `YYYY-MM-DD`. On or after the due date.

            - Maximum: BTG, 365 days after the due date. Lerian (PCR), no maximum. Out of range: 422 `PBP-0006` naming `paymentDeadline`. A fine or interest start date after it is refused the same way.
            - Without it: BTG uses the due date plus the days set for the tenant, or 30 days. Lerian (PCR) uses the due date plus the `paymentDeadlineDays` of the agreement the boleto is issued under.
            - A provider that does not register it refuses it with 422 `PBP-0701` and `capability` `BOLETO_PAYMENT_DEADLINE`.
          examples:
            - '2030-02-14'
          format: date
          type: string
        type:
          description: 'Boleto type. Send `TRADITIONAL`. `QR_CODE` is refused with 422 `PBP-0006`. `HYBRID` is refused with 501 `PBP-0127`: hybrid boletos (boleto with Pix) are not available.'
          examples:
            - TRADITIONAL
          type: string
      required:
        - type
        - payer
        - amount
        - dueDate
        - midazAccountId
      type: object
    CreateBoletoResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        barcode:
          type: string
        createdAt:
          type: string
        digitableLine:
          type: string
        discount:
          $ref: '#/components/schemas/DiscountResponse'
          description: The first discount band, whether it was sent as discount or first in discounts.
        discounts:
          description: Every discount band of the boleto, in the order they apply, the first included. Absent when the boleto grants no discount.
          items:
            $ref: '#/components/schemas/DiscountResponse'
          type:
            - array
            - 'null'
        documentNumber:
          description: 'Your reference for the charge (seu número), as sent. Present only when sent. It can hold quotes, `&`, `=`, `+`, `-` or `@`: encode it for where you write it, such as a spreadsheet cell or a web page.'
          type: string
        dueDate:
          type: string
        fine:
          $ref: '#/components/schemas/FineTermsResponse'
        guarantor:
          $ref: '#/components/schemas/GuarantorResponse'
          description: 'Final beneficiary (sacador avalista): the holder of the issuing account, read from the account registration at issuance. The request never chooses it, and every boleto carries it.'
        id:
          type: string
        instructions:
          type: string
        interest:
          $ref: '#/components/schemas/InterestTermsResponse'
        ledgerId:
          description: Midaz ledger the boleto was written with. Always present.
          type: string
        organizationId:
          description: Midaz organization the boleto was written with. Always present.
          type: string
        ourNumber:
          description: |-
            Bank identification of the boleto (nosso número), as the provider registered it, with leading zeros, at the provider's width. If you sent a different number, this is the one the provider issued.

            - Absent while the provider has not made it known, and on boletos issued before this field existed. Reconciliation fills it in later, with no action from you.
            - Never sent as an empty string.
          examples:
            - 00000000029
          type: string
        ourNumberDigit:
          description: 'Check digit of `ourNumber`, computed by the bank and never accepted in a request. Absent when the provider does not return it: providers return it only for numbers they assigned, and some never return it. Without it, show `ourNumber` alone, with no trailing hyphen. With it, show `{ourNumber}-{ourNumberDigit}`.'
          examples:
            - '3'
          type: string
        paymentDeadline:
          description: 'Last day the boleto can be paid, `YYYY-MM-DD`: the one you sent or, without it, the tenant setting or the provider default (Lerian (PCR): due date plus the agreement''s `paymentDeadlineDays`). Absent when the provider registers no deadline, while Lerian (PCR) has not answered the emission, and on a resend answered by a boleto recorded before the service stored the deadline.'
          examples:
            - '2030-01-31'
          format: date
          type: string
        pixLocation:
          description: Location of the dynamic Pix QR code of a hybrid boleto, whose payload is qrCode. Hybrid boletos (boleto with Pix) are not available on this service, so this member is absent.
          examples:
            - pix.example.com/qr/v2/cobv/5d9a8e91c88c43db942d01a0ad92ffc3
          type: string
        pixTxId:
          description: Identifier of the due-date Pix charge of a hybrid boleto. Hybrid boletos (boleto with Pix) are not available on this service, so this member is absent.
          examples:
            - 35dabf21d3b941e8a937409b8749f281
          type: string
        providerId:
          description: Identifier the banking provider assigned to this boleto. Absent from the 202 response, while the provider's answer is not confirmed; read the boleto with GET /v1/boletos/{id} for its current state.
          type: string
        qrCode:
          description: Pix copy-and-paste code of a hybrid boleto's Pix charge. Hybrid boletos (boleto with Pix) are not available on this service, so this member is absent.
          type: string
        status:
          type: string
        type:
          type: string
      required:
        - id
        - organizationId
        - ledgerId
        - status
        - type
        - amount
        - dueDate
        - createdAt
      type: object
    CreateInstallmentsRequest:
      additionalProperties: false
      properties:
        discount:
          $ref: '#/components/schemas/DiscountRequest'
          description: 'Discount of every installment. Its limitDate is absolute: the same date on every installment, before firstDueDate. For a discount whose date follows each installment''s due date, send discounts. Send either discount or discounts, never both: the two together are refused with 422 PBP-0006 naming discounts.'
        discounts:
          description: 'Discount bands, one to three, in the order they apply, written for the first installment: each installment gets the same number of days, between its limitDate and firstDueDate, before its own due date. Every band has the first band''s type, and each limitDate is after the previous band''s and before firstDueDate; otherwise 422 PBP-0006 naming the band, as in discounts[1].limitDate. More than one band, on a provider that does not register them, is refused with 422 PBP-0701 naming BOLETO_DISCOUNT_BANDS in the capability member.'
          items:
            $ref: '#/components/schemas/DiscountRequest'
          maxItems: 3
          minItems: 1
          type:
            - array
            - 'null'
        documentNumbers:
          description: 'Payee''s own reference for each installment (seu numero), such as an invoice number: one per installment, in installment order, at most 36. Optional: when absent or null, no installment carries one; an empty list is refused with 422 PBP-0102, as is a list of another length. Each item follows the rule of documentNumber on POST /v1/boletos: 1 to 15 printable ASCII characters (space through tilde), stored as given; an item that is empty, longer than 15 characters, made only of spaces, that carries any other character or that carries markup is refused with 400 PBP-0001 naming it as documentNumbers[<i>], counted from 0. When the provider that serves the issuance does not register it, the series is refused with 422 PBP-0701, naming BOLETO_DOCUMENT_NUMBER in the capability member; nothing is recorded and the provider is not called.'
          examples:
            -   - NF-2030/0001
                - NF-2030/0002
          items:
            maxLength: 15
            minLength: 1
            pattern: ^[ -~]{1,15}$
            type: string
          maxItems: 36
          type:
            - array
            - 'null'
        fine:
          $ref: '#/components/schemas/FineRequest'
        firstDueDate:
          description: Due date of the first installment, YYYY-MM-DD. On LERIAN each installment's due date must be at most 3650 days after the day of issuance; otherwise 422 PBP-0006 naming the member, before anything is recorded.
          examples:
            - '2030-01-15'
          format: date
          type: string
        installmentAmounts:
          description: Per-installment amounts, at most 36. When supplied, its length must match installments. On LERIAN each installment's amount must be below 100000000.00; otherwise 422 PBP-0006 naming the member, before anything is recorded.
          items:
            maxLength: 32
            type: string
          maxItems: 36
          type:
            - array
            - 'null'
        installments:
          description: Number of installments.
          examples:
            - 2
          format: int64
          type: integer
        interest:
          $ref: '#/components/schemas/InterestRequest'
        intervalDays:
          description: Days between consecutive installments.
          examples:
            - 30
          format: int64
          type: integer
        ledgerId:
          description: 'Midaz ledger the account lives in and every installment is written with. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          type: string
        midazAccountId:
          description: Midaz account the series settles into.
          type: string
        ourNumbers:
          description: 'Bank-side identification (nosso numero) chosen by the payee for each installment: one number per installment, in installment order, at most 36. All or none: when absent or null, the provider assigns every number, and an empty list is refused with 422 PBP-0102, as is a list of another length. Each item follows the rule of ourNumber on POST /v1/boletos: surrounding spaces are removed, a hyphen is accepted only when followed by exactly one digit, which is discarded, and any other character that is not a digit is refused; the accepted width, in significant digits, is set by the provider that serves the issuance and can differ between providers: read it as numbering.maxWidth of that provider in GET /v1/admin/providers/capabilities. A format or width refusal answers 400 PBP-0001 naming the item as ourNumbers[<i>], counted from 0. Two installments with the same number, leading zeros ignored, are refused with 422 PBP-0102, and the problem carries the installments, counted from 1, as duplicateInstallmentNumbers. A number already held by an active boleto of this tenant on the same provider account refuses the whole series with 422 PBP-0108 before the provider is called, and the problem carries the installment as installmentNumber and, when the holder can be read and is not a hybrid boleto, its id as ourNumberHolderBoletoId. Only a series with numbers depends on the provider account lookup: 422 PBP-0017 when the provider has no numbering account for the series'' midazAccountId (the installation has no account discovery, or the account is not yet enabled at the provider), 422 PBP-0014 when the provider refuses the lookup and 503 PBP-0015 when the provider does not answer.'
          items:
            type: string
          maxItems: 36
          type:
            - array
            - 'null'
        payer:
          $ref: '#/components/schemas/PayerRequest'
        paymentDeadline:
          description: Last day the first installment can be paid, YYYY-MM-DD; each installment gets the same number of days added to its own due date. On or after firstDueDate and at most the maximum the provider declares after it, LERIAN declaring none; otherwise 422 PBP-0006 naming paymentDeadline. Absent, each installment's deadline is its due date plus the days the tenant set for the provider or, with none set, plus the provider's default; on LERIAN, plus the paymentDeadlineDays of the agreement the installment is issued under. A provider that does not register it refuses it with 422 PBP-0701 naming BOLETO_PAYMENT_DEADLINE in the capability member.
          examples:
            - '2030-01-25'
          format: date
          type: string
        totalAmount:
          description: 'Series total as a decimal string. Optional: either this or installmentAmounts must be supplied.'
          examples:
            - '100.00'
          maxLength: 32
          type: string
        type:
          description: Boleto type applied to every installment.
          examples:
            - TRADITIONAL
          type: string
      required:
        - type
        - payer
        - installments
        - firstDueDate
        - intervalDays
        - midazAccountId
      type: object
    CreateInstallmentsResponse:
      additionalProperties: false
      properties:
        boletos:
          items:
            $ref: '#/components/schemas/InstallmentBoletoResponse'
          type:
            - array
            - 'null'
        closed:
          description: 'Whether no installment of the series can still be paid: true when every installment is SETTLED, CANCELED, INACTIVATED, REVERSED or FAILED. Always present. It can return to false when the provider reverts the cancellation of an installment.'
          type: boolean
        installmentsCount:
          format: int64
          type: integer
        ledgerId:
          description: Midaz ledger the installments were written with. Always present.
          type: string
        organizationId:
          description: Midaz organization the installments were written with. Always present, and always the organization of the X-Organization-Id header.
          type: string
        seriesId:
          type: string
        status:
          description: 'Emission outcome of the series, derived from its installments on every read. CREATED: some installment has no emission outcome yet. COMPLETED: every installment has an outcome and none is FAILED. PARTIAL_FAILURE: every installment has an outcome and some, not all, are FAILED; those carry errorMessage. FAILED: every installment is FAILED. It does not depend on payment, cancellation or write-off, and it can move from COMPLETED to PARTIAL_FAILURE or FAILED when the provider later refuses an accepted installment: a client waiting for the final outcome reads closed.'
          enum:
            - CREATED
            - COMPLETED
            - PARTIAL_FAILURE
            - FAILED
          type: string
        totalAmount:
          type: string
      required:
        - seriesId
        - organizationId
        - ledgerId
        - status
        - closed
        - totalAmount
        - installmentsCount
        - boletos
      type: object
    DARFResponse:
      additionalProperties: false
      properties:
        fineAmount:
          type: string
        interestAmount:
          type: string
        mainAmount:
          type: string
        name:
          type: string
        personType:
          type: string
        referenceDate:
          type: string
        taxId:
          type: string
        treasuryRevenueCode:
          type: string
        type:
          type: string
      required:
        - personType
        - taxId
        - name
        - referenceDate
        - treasuryRevenueCode
        - type
        - mainAmount
        - interestAmount
        - fineAmount
      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
    DisconnectProviderResponse:
      additionalProperties: false
      properties:
        disconnectedAt:
          description: 'When the provider was disconnected, in UTC: the disconnect in force.'
          examples:
            - '2026-11-30T18:00:00Z'
          format: date-time
          type: string
        outcome:
          description: DISCONNECTED, this call put the pair in the disconnected state; ALREADY_DISCONNECTED, the pair was already disconnected (the revocation is still re-applied).
          enum:
            - DISCONNECTED
            - ALREADY_DISCONNECTED
          type: string
        providerType:
          description: Provider disconnected.
          examples:
            - LERIAN
          type: string
        revokedConnections:
          description: Webhook connections of the provider that could still serve a delivery and no longer can. Zero is a success.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
      required:
        - providerType
        - outcome
        - revokedConnections
        - disconnectedAt
      type: object
    DiscountRequest:
      additionalProperties: false
      properties:
        amount:
          description: |-
            Decimal string greater than zero.

            - `FIXED`: BRL, up to 2 decimal places, below the boleto amount (each installment's own amount on installments).
            - `PERCENTAGE`: percent (`2.5` means 2.5%), below 100, up to 6 decimal places. Lerian (PCR): up to 5.
            - More places, or at or above the ceiling: 422 `PBP-0006` naming it.
          maxLength: 32
          type: string
        limitDate:
          description: 'Last day the discount applies, `YYYY-MM-DD`. On or after the issuance day (Brazilian calendar) and before the due date: before `dueDate` on a single boleto, before `firstDueDate` on installments. Outside that window: 422 `PBP-0006`.'
          examples:
            - '2029-12-31'
          format: date
          type: string
        type:
          description: '`FIXED` (BRL, up to 2 decimal places) or `PERCENTAGE` (percent of the face value, up to 6 decimal places, 5 on Lerian (PCR)). Granted when the boleto is paid on or before `limitDate`. Required when a discount is sent, together with `amount` and `limitDate`: absent, empty or unlisted is refused with 422 `PBP-0006`.'
          type: string
      required:
        - amount
        - limitDate
      type: object
    DiscountResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        limitDate:
          type: string
        type:
          type: string
      required:
        - type
        - amount
        - limitDate
      type: object
    DivergenceField:
      additionalProperties: false
      properties:
        local:
          description: Value collections holds; null when collections holds none.
          examples:
            - '01'
          maxLength: 128
          type:
            - string
            - 'null'
        name:
          description: 'Attribute that differs, an agreement or situation attribute: productType, branchType, branchNumber, accountType, accountNumber, agreementCode, situation or nucleaSituation. Never a document or a name.'
          examples:
            - productType
          maxLength: 64
          type: string
        nuclea:
          description: Value the beneficiary base holds; null when the base holds none.
          examples:
            - '03'
          maxLength: 128
          type:
            - string
            - 'null'
      required:
        - name
      type: object
    EnableAccountRequest:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account to enable, of the organization X-Organization-Id names.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        agreements:
          description: The account's own agreement list, one per product type, used instead of the tenant's default agreement template. Left out, the default template.
          items:
            $ref: '#/components/schemas/AgreementSpec'
          maxItems: 8
          minItems: 1
          type: array
        ledgerId:
          description: 'Midaz ledger of the account. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6c
          type: string
        reason:
          description: Reason for the enablement, recorded in the audit trail. Must not carry personal data.
          examples:
            - Enablement of the account of the new portfolio.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - accountId
        - reason
      type: object
    EnablementBatch:
      additionalProperties: false
      properties:
        adopted:
          description: Items whose registration change was accepted and whose agreement became ACTIVE (BULK_ADOPTION; 0 in an enablement).
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
        completedAt:
          description: When the last item ended, RFC 3339 in UTC; null while the batch is PROCESSING.
          examples:
            - '2026-11-11T10:30:00Z'
          format: date-time
          type:
            - string
            - 'null'
        createdAt:
          description: When the batch was accepted, RFC 3339 in UTC.
          examples:
            - '2026-11-11T10:00:00Z'
          format: date-time
          type: string
        enabled:
          description: Items whose holder was accepted (ENABLEMENT; 0 in a bulk adoption).
          examples:
            - 4900
          format: int64
          minimum: 0
          type: integer
        failed:
          description: Items that ended with an error.
          examples:
            - 20
          format: int64
          minimum: 0
          type: integer
        id:
          description: Identifier of the batch.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a21
          format: uuid
          type: string
        inventoryRunId:
          description: Inventory the bulk adoption adopts from; null for an enablement.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a31
          format: uuid
          type:
            - string
            - 'null'
        kind:
          description: 'ENABLEMENT: an enablement of accounts (createEnablementBatch). BULK_ADOPTION: a bulk adoption of the MISSING_LOCALLY divergences of an inventory.'
          enum:
            - ENABLEMENT
            - BULK_ADOPTION
          examples:
            - ENABLEMENT
          type: string
        pending:
          description: Items still in progress, including those HELD_BY_ALERT and the adoptions waiting for the Núclea to accept the registration change (DDA0502).
          examples:
            - 80
          format: int64
          minimum: 0
          type: integer
        productTypeFilter:
          description: Product type the bulk adoption is limited to; null for every product type, and for an enablement.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type:
            - string
            - 'null'
        state:
          description: PROCESSING while an item is in progress; then COMPLETED when every item succeeded, or COMPLETED_WITH_ERRORS when some item failed.
          enum:
            - PROCESSING
            - COMPLETED
            - COMPLETED_WITH_ERRORS
          examples:
            - PROCESSING
          type: string
        totalItems:
          description: Items of the batch.
          examples:
            - 5000
          format: int64
          maximum: 5000
          minimum: 1
          type: integer
      required:
        - id
        - kind
        - state
        - totalItems
        - enabled
        - adopted
        - pending
        - failed
        - createdAt
      type: object
    EnablementBatchItem:
      additionalProperties: false
      properties:
        accountId:
          description: Account the item enables (ENABLEMENT), or the holder's single account the divergence is adopted on (BULK_ADOPTION); null when the item adopts nothing.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type:
            - string
            - 'null'
        adoptionBlockReason:
          description: 'BULK_ADOPTION only: why the item did not adopt, FAILED with PBP-0824. AMBIGUOUS_ACCOUNT: the holder has several accounts in the ledger. NO_LEDGER_ACCOUNT: none. Null otherwise.'
          enum:
            - AMBIGUOUS_ACCOUNT
            - NO_LEDGER_ACCOUNT
            -
          examples:
            - AMBIGUOUS_ACCOUNT
          type:
            - string
            - 'null'
        agreementId:
          description: Agreement the adoption created (BULK_ADOPTION only).
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a51
          format: uuid
          type:
            - string
            - 'null'
        beneficiaryId:
          description: Beneficiary the item enabled or adopted on, once processed.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a61
          format: uuid
          type:
            - string
            - 'null'
        divergenceId:
          description: Divergence the item adopts (BULK_ADOPTION only).
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a41
          format: uuid
          type:
            - string
            - 'null'
        error:
          description: Why the item FAILED; null otherwise.
          oneOf:
            - $ref: '#/components/schemas/EnablementBatchItemError'
            - type: 'null'
        organizationId:
          description: Midaz organization of the account; null for a divergence without an account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        state:
          description: PENDING while in progress. ENABLED and HELD_BY_ALERT only in an enablement; ADOPTED only in a bulk adoption. FAILED carries error.
          enum:
            - PENDING
            - ENABLED
            - ADOPTED
            - HELD_BY_ALERT
            - FAILED
          examples:
            - FAILED
          type: string
      required:
        - state
      type: object
    EnablementBatchItemError:
      additionalProperties: false
      properties:
        code:
          description: Product error code the operation the item stands for would have answered.
          examples:
            - PBP-0805
          pattern: ^PBP-[0-9]{4}$
          type: string
        detail:
          description: Explanation of the error, when one was recorded.
          examples:
            - Agreement Not Usable
          type: string
        status:
          description: HTTP status that operation would have answered.
          examples:
            - 422
          format: int64
          type: integer
      required:
        - code
      type: object
    EnablementBatchItemList:
      additionalProperties: false
      properties:
        items:
          description: The page's items, oldest first.
          items:
            $ref: '#/components/schemas/EnablementBatchItem'
          type: array
        limit:
          description: Most items the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    EnablementBatchItemRequest:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account to enable, of the organization X-Organization-Id names. An account is named at most once in a batch.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        agreements:
          description: The account's own agreement list, used instead of the tenant's default agreement template. Left out, the default template.
          items:
            $ref: '#/components/schemas/AgreementSpec'
          maxItems: 8
          minItems: 1
          type: array
        ledgerId:
          description: Midaz ledger of the account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6c
          format: uuid
          type: string
      required:
        - ledgerId
        - accountId
      type: object
    EnablementBatchRequest:
      additionalProperties: false
      properties:
        items:
          description: Accounts to enable, 1 to 5,000. A larger list is split into several batches.
          items:
            $ref: '#/components/schemas/EnablementBatchItemRequest'
          maxItems: 5000
          minItems: 1
          type: array
        reason:
          description: Reason for the enablement, recorded in the audit trail. Must not carry personal data.
          examples:
            - Enablement of the accounts of the new portfolio.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - items
        - reason
      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
    Evidence:
      additionalProperties: false
      properties:
        description:
          description: What the evidence shows. Holds no file and no personal data.
          examples:
            - Extrato STR com o crédito do NUOp informado.
          maxLength: 1000
          minLength: 5
          type: string
        reference:
          description: 'Where the evidence is: a document, a ticket or a statement.'
          examples:
            - CHAMADO-2026-11-0042
          maxLength: 256
          type: string
      required:
        - description
      type: object
    ExcessPaymentNotice:
      additionalProperties: false
      properties:
        amount:
          description: Amount paid, a decimal string with two places.
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        detectedAt:
          description: When Payments recorded the excess.
          format: date-time
          type: string
        paidAt:
          description: When the payer paid, as the provider reports it; without an instant from the provider, when Payments observed the payment.
          format: date-time
          type: string
        paidVia:
          description: Leg the payment came through.
          enum:
            - BOLETO
            - PIX
          type: string
        providerReference:
          description: Reference of the payment at the provider; absent when the provider sent none.
          type: string
      required:
        - paidVia
        - amount
        - paidAt
        - detectedAt
      type: object
    ExcessPaymentResponse:
      additionalProperties: false
      properties:
        amount:
          description: Amount received, as a decimal string with two decimal places.
          examples:
            - '10.00'
          type: string
        detectedAt:
          description: When the service recorded this payment as an excess payment.
          format: date-time
          type: string
        paidAt:
          description: When the payer made this payment, as the payment provider reports it. When the provider reports no instant, it is the moment the service observed the payment.
          format: date-time
          type: string
        paidVia:
          description: 'Leg this payment arrived by: always the leg that did not settle the boleto.'
          enum:
            - BOLETO
            - PIX
          type: string
        providerReference:
          description: 'Reference of this payment at the payment provider: the end-to-end identifier of a Pix payment, or the authorization identifier of a boleto payment. Absent when the provider sent none.'
          type: string
      required:
        - paidVia
        - amount
        - paidAt
        - detectedAt
      type: object
    FailureReason:
      additionalProperties: false
      properties:
        class:
          description: 'REQUEST: the PCR refused what the client asked for; on a beneficiary, also a refusal of the operator, of the Núclea or of collections itself. COLLECTIONS_DEFECT: a defect of collections or of its configuration, the client is not at fault. INSTITUTION: a refusal caused by the institution''s PCR installation. TRANSIENT: an answer, or the lack of one, that a later attempt may change. When an answer of the PCR decided the class, its code did, never the HTTP status. BENEFICIARY_REJECTED (before the title was sent, its agreement left registration without being accepted: the Núclea refused it, accepted it with its beneficiary refused or unfit, or its close was requested) and WITHDRAWN_AT_PCR (withdrawn at the PCR for a reason of its own, given in withdrawalReason) carry no answer of the PCR; only a title is answered with either, never a command or a beneficiary.'
          enum:
            - REQUEST
            - COLLECTIONS_DEFECT
            - INSTITUTION
            - TRANSIENT
            - BENEFICIARY_REJECTED
            - WITHDRAWN_AT_PCR
          examples:
            - COLLECTIONS_DEFECT
          type: string
        message:
          description: 'Reason written by collections, never the PCR''s own text: in Portuguese, the message for a code of the PCR''s catalogue or for a class; in English, every other text, collections'' own. On a command''s last answer: the message for the code of the PCR''s catalogue in pcrCode or, when the answer carried no code of the catalogue or no answer arrived, for the class; the note that a check at the PCR could not tell whether a command it never answered took effect; or the reason the command was given up before it was sent. On a beneficiary: the message of the PCR''s refusal, as on a command, or a text of collections'' own naming the refusal (the holder''s data incomplete, the operator''s rejection, or the Núclea''s refusal with its EDDA codes); empty when the operator closed the command the beneficiary waited on. On a title: the message of the refusal that failed it, as on a command, the Núclea''s refusal with its EDDA codes, the reason its beneficiary was refused, or, withdrawn at the PCR, a text of collections'' own naming the withdrawalReason.'
          examples:
            - Código de barras inválido.
          maxLength: 500
          type: string
        pcrCode:
          description: 'Code of the PCR''s catalogue that decided the class. Null when no code decided it: no answer arrived or the answer carried none, the refusal is the operator''s, the Núclea''s or collections'' own, and always in BENEFICIARY_REJECTED and WITHDRAWN_AT_PCR.'
          examples:
            - PCR-0032
          pattern: ^PCR-[0-9]{4}$
          type:
            - string
            - 'null'
        withdrawalReason:
          description: 'Why the PCR withdrew the boleto, only with the class WITHDRAWN_AT_PCR. PENDING_CANCELLED: its pending registration was cancelled. PENDING_DEADLINE_EXPIRED: the pending registration''s deadline ran out. VALIDITY_LOST: the boleto lost its validity before the grade opened. Null in every other class, so always null on a command''s last answer and on a beneficiary''s reason.'
          enum:
            - PENDING_CANCELLED
            - PENDING_DEADLINE_EXPIRED
            - VALIDITY_LOST
            -
          examples:
            - PENDING_DEADLINE_EXPIRED
          type:
            - string
            - 'null'
      required:
        - class
        - message
      type: object
    FineRequest:
      additionalProperties: false
      properties:
        amount:
          description: |-
            Decimal string greater than zero.

            - `FIXED`: BRL, up to 2 decimal places.
            - `PERCENTAGE`: percent (`2.5` means 2.5%), up to 6 decimal places.
            - More places: 422 `PBP-0006` naming `fine.amount`.
            - Lerian (PCR): `PERCENTAGE` up to 5 decimal places and at most 100; `FIXED` below the boleto amount. Otherwise 422 `PBP-0006` naming the member, before anything is recorded.
          maxLength: 32
          type: string
        startDate:
          description: |-
            First day the fine is charged, `YYYY-MM-DD`. Optional. Without it, the day after the due date.

            - After the due date and on or before the payment deadline. Otherwise 422 `PBP-0006` naming `fine.startDate` (in a batch, an item problem `PBP-0006`).
            - Not a calendar date, or `0001-01-01` or earlier: 400 `PBP-0001` (in `POST /v1/boletos/batches`, an item problem `PBP-0001` reported in 422 `PBP-0123`).
            - Lerian (PCR), without `paymentDeadline`: the deadline is the due date plus the agreement's `paymentDeadlineDays`, and a later day is refused with 422 `PBP-0006`.
            - `POST /v1/boletos/installments`: the day for the first installment. Installment k (from 1) takes that day plus (k - 1) times `intervalDays`.
            - A provider that does not register it refuses it with 422 `PBP-0701` and `capability` `BOLETO_CHARGE_START_DATE`. Nothing is recorded.
          examples:
            - '2030-01-16'
          format: date
          type: string
        type:
          description: '`FIXED` (BRL, up to 2 decimal places) or `PERCENTAGE` (percent of the face value, up to 6 decimal places, 5 on Lerian (PCR)). Charged once, when the boleto is paid after the due date. Required when a fine is sent: absent, empty or unlisted is refused with 422 `PBP-0006`.'
          type: string
      required:
        - amount
      type: object
    FineResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        type:
          type: string
      required:
        - type
        - amount
      type: object
    FineTermsResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        startDate:
          description: First day the fine applies, `YYYY-MM-DD`. Present only when sent at issuance; absent, it applies from the day after the due date. On an installment, the installment's own day, shifted from the first installment's.
          type: string
        type:
          type: string
      required:
        - type
        - amount
      type: object
    GetBoletoResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        barcode:
          type: string
        batchId:
          description: Batch the boleto was created in, as one of its items. Present only on a boleto of kind BATCH, absent on every other kind.
          examples:
            - 0192a3b4-c5d6-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          type: string
        batchPosition:
          description: 'Position of the boleto in its batch, zero-based: the position of its item in the batch request. Present only on a boleto of kind BATCH, absent on every other kind.'
          examples:
            - 3
          format: int64
          maximum: 24
          minimum: 0
          type: integer
        cancelable:
          description: 'Whether cancelling this boleto would effect a cancellation at the provider. Always present. Derived from the boleto''s state, not from any request field: true only for a CREATED boleto that carries a providerId. An already-canceled boleto reads false even though POST /v1/boletos/{id}/cancel answers it 200 as an idempotent replay.'
          type: boolean
        canceledAt:
          type: string
        cancellationReason:
          type: string
        createdAt:
          type: string
        digitableLine:
          type: string
        discount:
          $ref: '#/components/schemas/DiscountResponse'
          description: The first discount band, whether it was sent as discount or first in discounts.
        discounts:
          description: Every discount band of the boleto, in the order they apply, the first included. Absent when the boleto grants no discount.
          items:
            $ref: '#/components/schemas/DiscountResponse'
          type:
            - array
            - 'null'
        documentNumber:
          description: 'Payee''s own reference of the charge (seu numero), as recorded. Present only when informed at issuance; an installment of a series carries its own, from documentNumbers. Answered as the payee sent it, so it can hold quotes, &, =, +, - or @: encode it for the place it is written to, such as a spreadsheet cell or a web page.'
          type: string
        dueDate:
          type: string
        errorMessage:
          type: string
        excessPayments:
          description: Payments a SETTLED hybrid boleto received after it was settled, by the leg that did not settle it. Hybrid boletos (boleto with Pix) are not available on this service and no read or list shows one, so this member is absent.
          items:
            $ref: '#/components/schemas/ExcessPaymentResponse'
          maxItems: 10
          type: array
        failedAt:
          type: string
        fine:
          $ref: '#/components/schemas/FineTermsResponse'
        guarantor:
          $ref: '#/components/schemas/GuarantorResponse'
          description: 'Final beneficiary (sacador avalista) of the boleto: the holder of the issuing account, read from that account''s registration data at issuance. It is a snapshot: a later change to the registration does not change it. Absent on boletos issued before the final beneficiary was derived.'
        id:
          type: string
        inactivatedAt:
          type: string
        installmentLabel:
          type: string
        instructions:
          type: string
        interest:
          $ref: '#/components/schemas/InterestTermsResponse'
        kind:
          description: 'Issuance form of the boleto: SINGLE for a standalone boleto, INSTALLMENT for an installment of a series, BATCH for an item of a batch, which carries batchId and batchPosition.'
          type: string
        ledgerId:
          description: Midaz ledger the boleto was written with. Always present.
          type: string
        midazAccountId:
          description: 'Midaz account the boleto was issued for: the midazAccountId it was created with. The settlement credit of a settled boleto is posted to this account. Always present.'
          type: string
        midazOperationId:
          type: string
        organizationId:
          description: Midaz organization the boleto was written with. Always present, and always the organization of the X-Organization-Id header.
          type: string
        ourNumber:
          description: 'Bank-side identification of the boleto (nosso numero), as assigned by the provider, with leading zeros, at the width of the provider the boleto was issued at. How it becomes known depends on that provider: either it is read from the barcode, in the instrument''s form, and is absent while the provider has not produced a valid barcode; or the provider returns it in its answer to the issuance, and it is present while the boleto has no barcode or digitable line yet. When the payee supplied ourNumber on issuance, this field still reports the provider''s value and not the value supplied: if the two differ, the value here is the one the provider issued, and the divergence is recorded by the service. Optional: absent for boletos issued before this field existed, and absent while the provider has not made it known. Absence means not yet known; the periodic reconciliation fills it in once the provider makes it known, with no action needed from the client; it is never sent as an empty string.'
          examples:
            - 00000000029
          type: string
        ourNumberDigit:
          description: 'Check digit of ourNumber, computed by the bank and never accepted in a request. Optional: absent whenever the provider the boleto was issued at did not return it, in which case ourNumber is presented alone, with no trailing hyphen. It is absent in particular when the payee supplied ourNumber: a provider returns the digit only for numbers it assigned itself, and some providers never return it. When present, the canonical presentation is {ourNumber}-{ourNumberDigit}.'
          examples:
            - '3'
          type: string
        paidVia:
          description: 'Leg by which the boleto was paid: BOLETO for a payment of its barcode or digitable line. Present only on a SETTLED boleto, absent on every other status. PIX, a payment of a hybrid boleto''s Pix QR code, is not served: hybrid boletos (boleto with Pix) are not available on this service, and no read or list shows one.'
          enum:
            - BOLETO
            - PIX
          type: string
        payer:
          $ref: '#/components/schemas/PayerResponse'
        paymentDeadline:
          description: 'Last day the boleto can be paid, YYYY-MM-DD: the one informed at issuance or, without it, the due date plus the tenant''s setting for the provider or, with no setting, the provider''s own default, batch items included; on LERIAN, the due date plus the agreement''s paymentDeadlineDays. Absent on boletos issued before the service recorded the deadline, when the provider registers no deadline, and while LERIAN has not answered the emission.'
          examples:
            - '2030-01-31'
          format: date
          type: string
        pendingAmendment:
          $ref: '#/components/schemas/PendingAmendmentResponse'
          description: 'The amendment request awaiting the provider''s outcome. The terms above stay the ones in force until the provider confirms it. Absent when there is none: only a CREATED boleto can have one.'
        pendingCancellation:
          $ref: '#/components/schemas/PendingCancellationResponse'
          description: The cancellation attempt awaiting the provider's answer, including while a provider that answers at once is being called; the boleto stays CREATED until the answer. Absent when there is none.
        pixLocation:
          description: Location of the dynamic Pix QR code of a hybrid boleto, whose payload is qrCode. Hybrid boletos (boleto with Pix) are not available on this service, so this member is absent.
          examples:
            - pix.example.com/qr/v2/cobv/5d9a8e91c88c43db942d01a0ad92ffc3
          type: string
        pixTxId:
          description: Identifier of the due-date Pix charge of a hybrid boleto. Hybrid boletos (boleto with Pix) are not available on this service, so this member is absent.
          examples:
            - 35dabf21d3b941e8a937409b8749f281
          type: string
        providerId:
          description: Identifier the payment provider assigned to this boleto. Quote it when you contact the provider about this boleto.
          type: string
        providerReason:
          description: 'Only on a FAILED installment of a series that its provider refused from its own refusal catalog: the stable reason of the rule the request broke, which tells apart the rules one code covers (for example PAYMENT_DEADLINE_BEFORE_DUE with PBP-0832). That installment''s BOLETO_FAILED carries the code as errorCode and this reason as providerReason. Absent on every other boleto, a single boleto included: the emission request is answered with its refusal.'
          examples:
            - PAYMENT_DEADLINE_BEFORE_DUE
          pattern: ^[A-Z][A-Z0-9_]{0,63}$
          type: string
        qrCode:
          description: Pix copy-and-paste code of a hybrid boleto's Pix charge. Hybrid boletos (boleto with Pix) are not available on this service, so this member is absent.
          type: string
        reversedAt:
          description: 'When the boleto became REVERSED: the payment was returned to the payer; the boleto will not be paid. RFC 3339 in UTC. Present only on a REVERSED boleto, absent on every other status.'
          examples:
            - '2026-11-10T17:00:00Z'
          type: string
        seriesId:
          type: string
        settledAmount:
          type: string
        settledAt:
          type: string
        status:
          type: string
        type:
          type: string
        updatedAt:
          type: string
        settlement:
          $ref: '#/components/schemas/BoletoSettlement'
          description: 'How the paid amount reaches the beneficiary''s account. Present only when status is SETTLED, absent on every other status. status does not change with it: a paid boleto stays SETTLED at every stage, after a reversal or a chargeback included. Boletos settled before this member existed read mode DIRECT, state RELEASED and cycle 1.'
          x-mint:
            post:
              - Under development
        baseSituation:
          $ref: '#/components/schemas/BaseSituation'
          description: 'Situation of the title at the base (CIP/Nuclea), alongside status, which keeps today''s rules. Present on every boleto that reached the base; absent on PENDING and FAILED, which never did. It follows status (SETTLED as PAID, CANCELED as CANCELLED, INACTIVATED as LAPSED, every other status as OPEN, REVERSED included), with exceptions recorded by the collections module: a paid title reopened at the base reads OPEN while status stays SETTLED, which is terminal; if that reopened title is then canceled or lapses, it reads CANCELLED or LAPSED and status still stays SETTLED (and a canceled one that reopens again reads OPEN); a canceled title reopened at the base reads OPEN and status goes back from CANCELED to CREATED, the transition that already exists, so the boleto can be paid again. Boletos written before this member existed are filled from their status.'
          x-mint:
            post:
              - Under development
      required:
        - id
        - organizationId
        - ledgerId
        - midazAccountId
        - type
        - kind
        - status
        - cancelable
        - amount
        - dueDate
        - payer
        - createdAt
        - updatedAt
      type: object
    GetInstallmentsResponse:
      additionalProperties: false
      properties:
        boletos:
          items:
            $ref: '#/components/schemas/InstallmentBoletoResponse'
          type:
            - array
            - 'null'
        closed:
          description: 'Whether no installment of the series can still be paid: true when every installment is SETTLED, CANCELED, INACTIVATED, REVERSED or FAILED. Always present. It can return to false when the provider reverts the cancellation of an installment.'
          type: boolean
        installmentsCount:
          format: int64
          type: integer
        ledgerId:
          description: Midaz ledger the installments were written with. Always present.
          type: string
        organizationId:
          description: Midaz organization the installments were written with. Always present, and always the organization of the X-Organization-Id header.
          type: string
        seriesId:
          type: string
        status:
          description: 'Emission outcome of the series, derived from its installments on every read. CREATED: some installment has no emission outcome yet. COMPLETED: every installment has an outcome and none is FAILED. PARTIAL_FAILURE: every installment has an outcome and some, not all, are FAILED; those carry errorMessage. FAILED: every installment is FAILED. It does not depend on payment, cancellation or write-off, and it can move from COMPLETED to PARTIAL_FAILURE or FAILED when the provider later refuses an accepted installment: a client waiting for the final outcome reads closed.'
          enum:
            - CREATED
            - COMPLETED
            - PARTIAL_FAILURE
            - FAILED
          type: string
        totalAmount:
          type: string
      required:
        - seriesId
        - organizationId
        - ledgerId
        - status
        - closed
        - totalAmount
        - installmentsCount
        - boletos
      type: object
    GetPaymentResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        canceledAt:
          type: string
        cancellationReason:
          type: string
        createdAt:
          type: string
        darf:
          $ref: '#/components/schemas/DARFResponse'
        description:
          type: string
        digitableLine:
          type: string
        dueDate:
          description: 'Due date, YYYY-MM-DD. A DARF payment carries the one its creation request named, if any. A BANKSLIP payment carries the slip''s due date as the payment provider''s pre-payment consult reported it: absent when the consult reported none, and on bank-slip payments created before the due date was recorded. UTILITIES payments do not carry it.'
          type: string
        errorMessage:
          type: string
        failedAt:
          type: string
        failureCode:
          description: 'The product error code a FAILED payment was recorded with, when its failure has one. PBP-0211: the payment provider provably never received the payment, nothing was paid, and its reservation is cancelled. PBP-0212: the payment provider refused the payment because it arrived outside the hours it accepts payments, nothing was paid, and its reservation is cancelled. PBP-0014: the payment provider refused what it was sent. Absent on every other status, and on a failure recorded without a code. Treat the list as open.'
          examples:
            - PBP-0211
          type: string
        id:
          type: string
        ledgerId:
          description: Midaz ledger the payment was written with. Always present.
          type: string
        midazAccountId:
          description: 'Midaz account the payment is debited from: the midazAccountId the payment was created with. Always present.'
          type: string
        midazOperationId:
          type: string
        organizationId:
          description: Midaz organization the payment was written with. Always present, and always the organization of the X-Organization-Id header.
          type: string
        payee:
          $ref: '#/components/schemas/PayeeResponse'
        providerId:
          description: Identifier the payment provider assigned to this payment. Quote it, together with providerRequestId, when you contact the provider about this payment. Absent while the payment is UNCONFIRMED, and on a payment that failed before the provider acknowledged it.
          type: string
        providerRequestId:
          description: 'Reference this API sends to the payment provider when it instructs this payment, exactly as sent. Which of providerId and providerRequestId the provider accepts for a lookup depends on the provider and on the payment type, so quote both when you contact the provider. It is recorded when the payment is created, before the instruction, so it is present on a payment the provider never received too: one FAILED with failureCode PBP-0211, or FAILED without a code after the ledger refused its funds. The provider holds no payment under it then, and a payment retried under the same Idempotency-Key after a refusal for funds carries the same reference as the refused attempt. Absent when the payment carries no such reference.'
          type: string
        rejectedAt:
          type: string
        rejectionReason:
          type: string
        settledAmount:
          type: string
        settledAt:
          type: string
        status:
          description: |-
            The payment's current status: UNCONFIRMED, CREATED, SCHEDULED, PENDING_APPROVAL, APPROVED, EXECUTED, SETTLED, REJECTED, FAILED or CANCELED. UNCONFIRMED means the outcome at the payment provider is not known yet: every payment starts there, and one whose initiation was answered 202 stays there until it resolves. Treat the list as open: a value added later must not break a client.

            Planned: status gains RETURNED, reached only by the Lerian-provider payment flow; PENDING_APPROVAL also means the payment waits for the antifraud partner's final decision.
          type: string
        type:
          type: string
        updatedAt:
          type: string
        requestedAmount:
          description: The `amount` the creation request named, when it named one. `amount` is the amount reserved and paid, which for such a payment equals it. Absent when the request named none.
          examples:
            - '100.00'
          type: string
          x-mint:
            post:
              - Under development
        antifraud:
          $ref: '#/components/schemas/PaymentAntifraudAnalysis'
          x-mint:
            post:
              - Under development
        return:
          $ref: '#/components/schemas/PaymentReturn'
          x-mint:
            post:
              - Under development
        scheduledDate:
          $ref: '#/components/schemas/RequestedScheduledDate'
          x-mint:
            post:
              - Under development
        effectiveScheduledDate:
          $ref: '#/components/schemas/EffectiveScheduledDate'
          x-mint:
            post:
              - Under development
        effectiveAfterDueDate:
          $ref: '#/components/schemas/EffectiveAfterDueDate'
          x-mint:
            post:
              - Under development
        executedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: |-
            Planned. Instant the scheduled payment was executed on its day, when the provider accepted the payment call. Null until the execution happens, and stays null for a scheduled payment canceled or failed before it reached the provider.

            - There is no separate scheduling instant: a scheduled payment is created in `SCHEDULED`, so `createdAt` is that instant.
            - Do not confuse with `effectiveScheduledDate`: `executedAt` is when it ran, `effectiveScheduledDate` is when it was due to run.
          examples:
            - '2026-09-14T06:00:47Z'
          x-mint:
            post:
              - Under development
        failureReason:
          $ref: '#/components/schemas/ScheduleFailureReason'
          x-mint:
            post:
              - Under development
      required:
        - id
        - organizationId
        - ledgerId
        - midazAccountId
        - type
        - status
        - amount
        - createdAt
        - updatedAt
      type: object
    GuarantorResponse:
      additionalProperties: false
      properties:
        address:
          $ref: '#/components/schemas/AddressResponse'
          description: 'Never filled for the final beneficiary: the issuing account''s registration data carries no address for it. Kept so the shape of this component does not change.'
        document:
          description: CPF or CNPJ of the final beneficiary, the issuing account's holder, as registered. Answered whole, never masked, wherever this component appears.
          type: string
        name:
          description: Name of the final beneficiary, the issuing account's holder, as registered and in full. The printed boleto may abbreviate it; this member never does.
          type: string
      required:
        - name
        - document
      type: object
    InitiateDARFPaymentRequest:
      additionalProperties: false
      properties:
        description:
          description: Optional free-text description carried on the payment.
          type: string
        dueDate:
          description: Optional due date, YYYY-MM-DD.
          examples:
            - '2026-05-10'
          format: date
          type: string
        fineAmount:
          description: Fine amount as a decimal string, up to two decimal places. Must be non-negative.
          examples:
            - '5.00'
          maxLength: 32
          type: string
        history:
          description: Optional free-text history carried on the payment.
          type: string
        interestAmount:
          description: Interest amount as a decimal string, up to two decimal places. Must be non-negative.
          examples:
            - '10.00'
          maxLength: 32
          type: string
        ledgerId:
          description: 'Midaz ledger the account lives in and the entry is posted to. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          type: string
        mainAmount:
          description: Principal amount as a decimal string, up to two decimal places. Must be positive.
          examples:
            - '100.00'
          maxLength: 32
          type: string
        midazAccountId:
          description: 'Midaz account the payment settles from. The TAXPAYER of the DARF is the registered owner of this account, read from the Midaz CRM: the request does not state one. A holder whose registered name exceeds 80 bytes cannot be paid on this rail: the name is never shortened to fit, and the refusal is 422 PBP-0207.'
          type: string
        referenceDate:
          description: Tax period reference date, YYYY-MM-DD.
          examples:
            - '2026-04-01'
          format: date
          type: string
        referenceNumber:
          description: Optional reference number carried to the tax authority.
          format: int64
          type: integer
        totalIncomeAmount:
          description: Optional total income amount as a decimal string.
          maxLength: 32
          type: string
        totalIncomePercent:
          description: Optional total income percentage as a decimal string.
          maxLength: 32
          type: string
        treasuryRevenueCode:
          description: 'Federal revenue code (código da receita) of the DARF: the four digits of the code, zero-padded, for example 0086. A value in the provider''s prefixed form, such as TRC_0086, is also accepted. At most 20 characters. The code is not checked against the revenue code catalogue by this API; the payment provider refuses an unknown code.'
          examples:
            - 0086
          type: string
        type:
          description: 'DARF type: S for Simples, N for Normal.'
          examples:
            - S
          type: string
        scheduledDate:
          $ref: '#/components/schemas/RequestedScheduledDate'
          x-mint:
            post:
              - Under development
      required:
        - referenceDate
        - treasuryRevenueCode
        - type
        - mainAmount
        - interestAmount
        - fineAmount
        - midazAccountId
      type: object
    InitiateDARFPaymentResponse:
      additionalProperties: false
      properties:
        createdAt:
          type: string
        id:
          type: string
        ledgerId:
          description: Midaz ledger the payment was written with. Always present.
          type: string
        organizationId:
          description: Midaz organization the payment was written with. Always present.
          type: string
        providerId:
          description: 'Identifier the payment provider assigned to this payment. Quote it, together with providerRequestId, when you contact the provider about this payment. Absent while the payment is UNCONFIRMED (the 202 answer): the provider has acknowledged nothing yet. Read the payment by id later to obtain it.'
          type: string
        providerRequestId:
          description: Reference this API sent to the payment provider when it instructed the payment, exactly as sent. Which of providerId and providerRequestId the provider accepts for a lookup depends on the provider and on the payment type, so quote both when you contact the provider. Absent when the payment carries no such reference.
          type: string
        status:
          description: 'The payment''s status when this answer was produced. CREATED on a 201 for a new payment; UNCONFIRMED on a 202, while the outcome at the payment provider is unknown. A request already on record is answered with the payment''s status at that moment, which may be any status a payment takes. A replay of the same Idempotency-Key serves the stored answer, whose status may since have changed: read the payment by id for its current state.'
          type: string
        totalAmount:
          type: string
        type:
          type: string
        scheduledDate:
          $ref: '#/components/schemas/RequestedScheduledDate'
          x-mint:
            post:
              - Under development
        effectiveScheduledDate:
          $ref: '#/components/schemas/EffectiveScheduledDate'
          x-mint:
            post:
              - Under development
        effectiveAfterDueDate:
          $ref: '#/components/schemas/EffectiveAfterDueDate'
          x-mint:
            post:
              - Under development
      required:
        - id
        - type
        - status
        - totalAmount
        - createdAt
        - organizationId
        - ledgerId
      type: object
    InitiatePaymentRequest:
      additionalProperties: false
      properties:
        description:
          description: Free-text description carried on the payment.
          type: string
        digitableLine:
          description: Bankslip or utilities digitable line, digits only.
          examples:
            - 00190500954014481606906809350314337370000000100
          type: string
        ledgerId:
          description: 'Midaz ledger the account lives in and the entry is posted to. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          type: string
        midazAccountId:
          description: 'Midaz account the payment settles from. Who PAYS is the registered owner of this account, read from the Midaz CRM: the request does not state a payer.'
          type: string
        amount:
          description: 'Optional amount to pay, a decimal string with two decimal places, for a slip that accepts partial or divergent payment. Absent: the amount the pre-payment consult calculates for today is paid, as before. Present: the provider must pay an informed amount (else 422 PBP-0701, capability PAYMENT_AMOUNT_INFORMED) and the slip must accept it (else 422 PBP-0217); the accepted amount is the one reserved, reported to the clearing base and debited. Exactly two decimal places and greater than zero: zero (0.00) is refused by the pattern with 400 PBP-0001. Part of the request identity: the same Idempotency-Key with another amount is 422 PBP-0013.'
          examples:
            - '100.00'
          maxLength: 32
          pattern: ^(0\.(0[1-9]|[1-9][0-9])|[1-9][0-9]{0,15}\.[0-9]{2})$
          type: string
          x-mint:
            post:
              - Under development
        channel:
          description: |-
            Optional channel through which the payer paid the slip. Absent: the tenant's default payment channel
            (INTERNET unless Lerian recorded another one at the tenant's request; the default can never be DDA). The value is fixed when the request is received and recorded with the payment. A value
            outside the enum is refused with 400 PBP-0001. DDA requires a bankslip presented to this payer through DDA (receiverBoletoId,
            delivered with the DDA payer flow); without it, 422 PBP-0220. Part of the request identity: the same Idempotency-Key with another
            channel is 422 PBP-0013.

            A provider that reports the channel to the clearing base sends the code below; a provider that does not (BTG) ignores it. Codes
            of the `CanPgto` domain, Manual de Leiautes da Plataforma Centralizada de Recebíveis (PCR), MAPX-OP016-2009 V63, §10.1:

            | channel | CanPgto | Manual description |
            |---|---|---|
            | BRANCH | 1 | Agências – Postos tradicionais |
            | ATM | 2 | Terminal de Autoatendimento |
            | INTERNET | 3 | Internet (home / office banking) |
            | BANKING_AGENT | 5 | Correspondente bancário |
            | CALL_CENTER | 6 | Central de atendimento (Call Center) |
            | ELECTRONIC_FILE | 7 | Arquivo Eletrônico |
            | DDA | 8 | DDA |
            | DIGITAL_BANKING_AGENT | 9 | Correspondente bancário digital |

            Code 4 (PIX) is not accepted: a slip paid through Pix is the BolePix flow, not this operation.
          enum:
            - BRANCH
            - ATM
            - INTERNET
            - BANKING_AGENT
            - CALL_CENTER
            - ELECTRONIC_FILE
            - DDA
            - DIGITAL_BANKING_AGENT
          examples:
            - INTERNET
          type: string
          x-mint:
            post:
              - Under development
        paymentMethod:
          description: |-
            Optional means of payment the payer used. Absent: the tenant's default payment method (ACCOUNT_DEBIT
            unless Lerian recorded another one at the tenant's request). The value is fixed when the request is received and recorded with the payment. A value outside the
            enum is refused with 400 PBP-0001. The payment is always debited from `midazAccountId`; this member only states the means reported
            to the clearing base. Part of the request identity: the same Idempotency-Key with another paymentMethod is 422 PBP-0013.

            A provider that reports the means of payment to the clearing base sends the code below; a provider that does not (BTG) ignores it.
            Codes of the `MeioPgto` domain, Manual de Leiautes da Plataforma Centralizada de Recebíveis (PCR), MAPX-OP016-2009 V63, §10.36:

            | paymentMethod | MeioPgto | Manual description |
            |---|---|---|
            | CASH | 1 | Espécie |
            | ACCOUNT_DEBIT | 2 | Débito em conta |
            | CREDIT_CARD | 3 | Cartão de crédito |
            | CHECK | 4 | Cheque |
          enum:
            - CASH
            - ACCOUNT_DEBIT
            - CREDIT_CARD
            - CHECK
          examples:
            - ACCOUNT_DEBIT
          type: string
          x-mint:
            post:
              - Under development
        receiverBoletoId:
          type: string
          format: uuid
          description: Presented boleto being paid. With channel DDA it must be presented to the holder of midazAccountId, and digitableLine must be that boleto's line; otherwise 422 PBP-0220, the payment code also returned when channel DDA comes without receiverBoletoId.
          x-mint:
            post:
              - Under development
        scheduledDate:
          $ref: '#/components/schemas/RequestedScheduledDate'
          x-mint:
            post:
              - Under development
      required:
        - digitableLine
        - midazAccountId
      type: object
    InitiatePaymentResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        createdAt:
          type: string
        digitableLine:
          type: string
        dueDate:
          type: string
        id:
          type: string
        ledgerId:
          description: Midaz ledger the payment was written with. Always present.
          type: string
        organizationId:
          description: Midaz organization the payment was written with. Always present.
          type: string
        providerId:
          description: 'Identifier the payment provider assigned to this payment. Quote it, together with providerRequestId, when you contact the provider about this payment. Absent while the payment is UNCONFIRMED (the 202 answer): the provider has acknowledged nothing yet. Read the payment by id later to obtain it.'
          type: string
        providerRequestId:
          description: Reference this API sent to the payment provider when it instructed the payment, exactly as sent. Which of providerId and providerRequestId the provider accepts for a lookup depends on the provider and on the payment type, so quote both when you contact the provider. Absent when the payment carries no such reference.
          type: string
        status:
          description: 'The payment''s status when this answer was produced. CREATED on a 201 for a new payment; UNCONFIRMED on a 202, while the outcome at the payment provider is unknown. A request already on record is answered with the payment''s status at that moment, which may be any status a payment takes. A replay of the same Idempotency-Key serves the stored answer, whose status may since have changed: read the payment by id for its current state.'
          type: string
        type:
          type: string
        scheduledDate:
          $ref: '#/components/schemas/RequestedScheduledDate'
          x-mint:
            post:
              - Under development
        effectiveScheduledDate:
          $ref: '#/components/schemas/EffectiveScheduledDate'
          x-mint:
            post:
              - Under development
        effectiveAfterDueDate:
          $ref: '#/components/schemas/EffectiveAfterDueDate'
          x-mint:
            post:
              - Under development
        amountIsEstimated:
          type: boolean
          description: |-
            Planned. `true` when `amount` is the value looked up at acceptance and not the final value; `false` in an immediate payment, where the instruction was already sent with that value.

            - In a scheduled payment it is `true` from creation. The final value is the one the execution on the scheduled day uses; read it with `GET /v1/payments/{id}` once `executedAt` is set.
          examples:
            - true
          x-mint:
            post:
              - Under development
      required:
        - id
        - type
        - status
        - digitableLine
        - amount
        - createdAt
        - organizationId
        - ledgerId
      type: object
    InstallmentBoletoResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        dueDate:
          type: string
        errorMessage:
          type: string
        id:
          type: string
        installmentLabel:
          type: string
        installmentNumber:
          format: int64
          type: integer
        ourNumber:
          description: 'Bank-side identification of the boleto (nosso numero), as assigned by the provider, with leading zeros, at the width of the provider the boleto was issued at. How it becomes known depends on that provider: either it is read from the barcode, in the instrument''s form, and is absent while the provider has not produced a valid barcode; or the provider returns it in its answer to the issuance, and it is present while the boleto has no barcode or digitable line yet. When the payee supplied ourNumber on issuance, this field still reports the provider''s value and not the value supplied: if the two differ, the value here is the one the provider issued, and the divergence is recorded by the service. Optional: absent for boletos issued before this field existed, and absent while the provider has not made it known. Absence means not yet known; the periodic reconciliation fills it in once the provider makes it known, with no action needed from the client; it is never sent as an empty string.'
          examples:
            - 00000000029
          type: string
        ourNumberDigit:
          description: 'Check digit of ourNumber, computed by the bank and never accepted in a request. Optional: absent whenever the provider the boleto was issued at did not return it, in which case ourNumber is presented alone, with no trailing hyphen. It is absent in particular when the payee supplied ourNumber: a provider returns the digit only for numbers it assigned itself, and some providers never return it. When present, the canonical presentation is {ourNumber}-{ourNumberDigit}.'
          examples:
            - '3'
          type: string
        providerReason:
          description: 'Only on a FAILED installment of a series that its provider refused from its own refusal catalog: the stable reason of the rule the request broke, which tells apart the rules one code covers (for example PAYMENT_DEADLINE_BEFORE_DUE with PBP-0832). That installment''s BOLETO_FAILED carries the code as errorCode and this reason as providerReason. Absent on every other boleto, a single boleto included: the emission request is answered with its refusal.'
          examples:
            - PAYMENT_DEADLINE_BEFORE_DUE
          pattern: ^[A-Z][A-Z0-9_]{0,63}$
          type: string
        status:
          description: 'Status of the installment''s boleto, the same GET /v1/boletos/{id} answers. REVERSED: the payment was returned to the payer; the boleto will not be paid.'
          enum:
            - PENDING
            - CREATED
            - SETTLED
            - CANCELED
            - INACTIVATED
            - FAILED
            - REVERSED
          type: string
      required:
        - id
        - installmentNumber
        - installmentLabel
        - amount
        - dueDate
        - status
      type: object
    InterestRequest:
      additionalProperties: false
      properties:
        amount:
          description: |-
            Decimal string greater than zero.

            - `DAILY_FIXED`: BRL per calendar day, up to 2 decimal places.
            - `DAILY_PERCENTAGE` and `MONTHLY_PERCENTAGE`: percent (`1` means 1%), up to 6 decimal places.
            - Refused amounts: 422 `PBP-0006` naming `interest.amount`.
            - Lerian (PCR): percentages up to 5 decimal places. A `DAILY_PERCENTAGE` is registered as 30 times its value per month, which must have up to 2 decimal places: `0.001` is 0.03 a month; `0.0333` (0.999 a month) is refused. `DAILY_FIXED` below `1000000000000`; `MONTHLY_PERCENTAGE`, or 30 times a `DAILY_PERCENTAGE`, below `1000000000`.
          maxLength: 32
          type: string
        startDate:
          description: |-
            First day interest accrues, `YYYY-MM-DD`. Optional. Without it, the day after the due date.

            - After the due date and on or before the payment deadline. Otherwise 422 `PBP-0006` naming `interest.startDate` (in a batch, an item problem `PBP-0006`).
            - Not a calendar date, or `0001-01-01` or earlier: 400 `PBP-0001` (in `POST /v1/boletos/batches`, an item problem `PBP-0001` reported in 422 `PBP-0123`).
            - Lerian (PCR), without `paymentDeadline`: the deadline is the due date plus the agreement's `paymentDeadlineDays`, and a later day is refused with 422 `PBP-0006`.
            - `POST /v1/boletos/installments`: the day for the first installment. Installment k (from 1) takes that day plus (k - 1) times `intervalDays`.
            - A provider that does not register it refuses it with 422 `PBP-0701` and `capability` `BOLETO_CHARGE_START_DATE`. Nothing is recorded.
          examples:
            - '2030-01-16'
          format: date
          type: string
        type:
          description: |-
            Accrued for each calendar day the boleto is paid late. Required when interest is sent: absent, empty or unlisted is refused with 422 `PBP-0006`.

            - `DAILY_FIXED`: BRL per day late, up to 2 decimal places.
            - `DAILY_PERCENTAGE`: percent of the face value per day late, up to 6 decimal places (5 on Lerian (PCR), where 30 times it must have up to 2).
            - `MONTHLY_PERCENTAGE`: percent of the face value per month, accrued per calendar day over a 30-day month, up to 6 decimal places (5 on Lerian (PCR)).
          type: string
      required:
        - amount
      type: object
    InterestResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        type:
          type: string
      required:
        - type
        - amount
      type: object
    InterestTermsResponse:
      additionalProperties: false
      properties:
        amount:
          type: string
        startDate:
          description: First day interest accrues, `YYYY-MM-DD`. Present only when sent at issuance; absent, it accrues from the day after the due date. On an installment, the installment's own day, shifted from the first installment's.
          type: string
        type:
          type: string
      required:
        - type
        - amount
      type: object
    InventoryRun:
      additionalProperties: false
      properties:
        completedAt:
          description: When the consumption completed, RFC 3339 in UTC; null while it has not.
          examples:
            - '2026-11-10T12:01:00Z'
          format: date-time
          type:
            - string
            - 'null'
        consumedAt:
          description: When collections started consuming the inventory, RFC 3339 in UTC.
          examples:
            - '2026-11-10T12:00:00Z'
          format: date-time
          type: string
        divergences:
          description: Divergences the consumption opened.
          examples:
            - 3
          format: int64
          minimum: 0
          type: integer
        id:
          description: Identifier of the consumption.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a11
          format: uuid
          type: string
        imported:
          description: Beneficiaries of the base adopted on their own because they matched an enablement in progress. Every other registration made outside collections becomes a MISSING_LOCALLY divergence.
          examples:
            - 12
          format: int64
          minimum: 0
          type: integer
        pcrInventoryRunId:
          description: Identifier of the inventory at the PCR.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a10
          format: uuid
          type: string
        pcrRanAt:
          description: When the PCR ran the inventory, RFC 3339 in UTC.
          examples:
            - '2026-11-10T11:00:00Z'
          format: date-time
          type: string
        state:
          description: 'Where the consumption is. PROCESSING: comparing the inventory with the agreements. COMPLETED: finished, with its divergences opened. FAILED: the read or the comparison failed; it is tried again.'
          enum:
            - PROCESSING
            - COMPLETED
            - FAILED
          examples:
            - COMPLETED
          type: string
      required:
        - id
        - pcrInventoryRunId
        - pcrRanAt
        - state
        - consumedAt
      type: object
    InventoryRunList:
      additionalProperties: false
      properties:
        items:
          description: The page's consumptions, the most recent first.
          items:
            $ref: '#/components/schemas/InventoryRun'
          type: array
        lastConsumedAt:
          description: When the most recent completed consumption ended, RFC 3339 in UTC; null while none has completed. The reference to tell whether the reconciliation is late.
          examples:
            - '2026-11-10T12:01:00Z'
          format: date-time
          type:
            - string
            - 'null'
        limit:
          description: Most consumptions the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    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
    LedgerCounterpartyChange:
      additionalProperties: false
      properties:
        assetCode:
          description: Asset of the counterparty that changed.
          examples:
            - BRL
          maxLength: 10
          minLength: 3
          type: string
        changedAt:
          description: When the change was made, in UTC.
          examples:
            - '2026-11-07T14:05:09Z'
          format: date-time
          type: string
        changedBy:
          description: Identifier of the principal (subject of its token).
          examples:
            - user:4b1d2c3e-5f6a-7b8c-9d0e-1f2a3b4c5d6e
          maxLength: 255
          minLength: 1
          type: string
        changedByType:
          description: Kind of principal that made the change.
          enum:
            - USER
            - MACHINE
            - SYSTEM
          examples:
            - USER
          type: string
        id:
          description: Identifier of the change.
          examples:
            - 019a5c1e-2b3d-7f4a-8c5d-6e7f8a9b0c1d
          format: uuid
          type: string
        ledgerId:
          description: Midaz ledger of the counterparty that changed.
          examples:
            - 0199a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a6c
          maxLength: 100
          type: string
        newAccountAlias:
          description: Account after the change.
          examples:
            - '@siloc-a-liquidar'
          maxLength: 100
          type: string
        previousAccountAlias:
          description: Account before the change; null on the first write, when the default @external/<asset> applied.
          examples:
            - '@external/BRL'
          maxLength: 100
          type:
            - string
            - 'null'
        providerType:
          description: Provider whose counterparty changed.
          examples:
            - BTG
          maxLength: 20
          type: string
        reason:
          description: Reason given with the change.
          examples:
            - Contrapartida do provider Lerian passa para a conta transitória do SILOC.
          maxLength: 500
          minLength: 1
          type: string
        traceId:
          description: Trace of the request that made the change, for audit.
          examples:
            - 4bf92f3577b34da6a3ce929d0e0e4736
          maxLength: 64
          type: string
      required:
        - id
        - ledgerId
        - providerType
        - assetCode
        - previousAccountAlias
        - newAccountAlias
        - changedByType
        - changedBy
        - reason
        - changedAt
      type: object
    LedgerCounterpartyHistoryPage:
      additionalProperties: false
      properties:
        items:
          description: Changes of the page, the most recent first. A tenant with no change answers an empty list.
          items:
            $ref: '#/components/schemas/LedgerCounterpartyChange'
          type:
            - array
            - 'null'
        limit:
          description: Changes per page.
          examples:
            - 20
          format: int64
          maximum: 100
          minimum: 1
          type: integer
        page:
          description: Page number, one-based.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
        total:
          description: Number of changes of the tenant's ledger counterparties. A page past the last change answers an empty items list.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    LedgerCounterpartyList:
      additionalProperties: false
      properties:
        items:
          description: One item per configured (ledger, provider, asset), plus the BRL default item (ledgerId null) of each installed provider connected to the tenant, ordered by provider, asset and ledger, with the default item first.
          items:
            $ref: '#/components/schemas/LedgerCounterparty'
          type:
            - array
            - 'null'
      required:
        - items
      type: object
    LinkPooledAccountRequest:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the final customer.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a41
          format: uuid
          type: string
        agreementId:
          description: ACTIVE agreement of the pooled account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a42
          format: uuid
          type: string
        ledgerId:
          description: 'Midaz ledger of the account. Required: absent, blank or not a canonical UUID is refused with 400 PBP-0026.'
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a44
          type: string
        reason:
          description: Reason for the link, recorded in the audit trail. Must not carry personal data.
          examples:
            - Merchant account issues under the marketplace's pooled account.
          maxLength: 500
          minLength: 10
          type: string
      required:
        - accountId
        - agreementId
        - reason
      type: object
    ListBoletoAmendmentsResponse:
      additionalProperties: false
      properties:
        items:
          description: The requests of the page, newest first.
          items:
            $ref: '#/components/schemas/BoletoAmendmentResponse'
          type:
            - array
            - 'null'
        limit:
          description: Items per page.
          examples:
            - 20
          format: int64
          type: integer
        page:
          description: Page number, one-based.
          examples:
            - 1
          format: int64
          type: integer
        total:
          description: Number of requests of the boleto.
          examples:
            - 3
          format: int64
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    ListBoletoBatchesResponse:
      additionalProperties: false
      properties:
        items:
          description: Batches of the page, most recent first.
          items:
            $ref: '#/components/schemas/BoletoBatchSummary'
          type:
            - array
            - 'null'
        limit:
          description: Items per page.
          examples:
            - 20
          format: int64
          type: integer
        page:
          description: Page number, one-based.
          examples:
            - 1
          format: int64
          type: integer
        total:
          description: Number of batches of the organization that match the filter.
          examples:
            - 42
          format: int64
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    ListBoletosResponse:
      additionalProperties: false
      properties:
        items:
          items:
            $ref: '#/components/schemas/GetBoletoResponse'
          type:
            - array
            - 'null'
        limit:
          format: int64
          type: integer
        page:
          format: int64
          type: integer
        total:
          format: int64
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    ListPaymentsResponse:
      additionalProperties: false
      properties:
        items:
          items:
            $ref: '#/components/schemas/GetPaymentResponse'
          type:
            - array
            - 'null'
        limit:
          format: int64
          type: integer
        page:
          format: int64
          type: integer
        total:
          format: int64
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    ListPixKeyHistoryResponse:
      additionalProperties: false
      properties:
        items:
          description: Changes of the page, the most recent first. A tenant with no change answers an empty list.
          items:
            $ref: '#/components/schemas/PixKeyHistoryItem'
          type:
            - array
            - 'null'
        limit:
          description: Changes per page.
          examples:
            - 20
          format: int64
          type: integer
        page:
          description: Page number, one-based.
          examples:
            - 1
          format: int64
          type: integer
        total:
          description: Number of changes of the tenant's Pix key. A page past the last change answers an empty items list and 0.
          examples:
            - 3
          format: int64
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    MarketAlert:
      additionalProperties: false
      properties:
        reportedAt:
          description: When the situation began, RFC 3339 in UTC.
          examples:
            - '2026-11-10T09:30:00Z'
          format: date-time
          type: string
        situation:
          description: 'Situation the other institution reported: UNDER_REVIEW or UNFIT holds a new enablement for the operator''s decision.'
          enum:
            - FIT
            - UNDER_REVIEW
            - UNFIT
          examples:
            - UNDER_REVIEW
          type: string
      required:
        - situation
        - reportedAt
      type: object
    NotEmittedNotice:
      additionalProperties: true
      type: object
    NoticeAmendmentChanges:
      additionalProperties: false
      properties:
        amount:
          description: New amount, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        discounts:
          description: New discount bands; an empty list is no band.
          items:
            $ref: '#/components/schemas/NoticeDiscountBand'
          maxItems: 3
          type: array
        documentNumber:
          description: New document number; null removes it.
          type:
            - string
            - 'null'
        dueDate:
          description: New due date (YYYY-MM-DD).
          format: date
          type: string
        fine:
          $ref: '#/components/schemas/NoticeFineChange'
          description: New fine; null exempts the boleto from the fine.
        interest:
          $ref: '#/components/schemas/NoticeInterestChange'
          description: New interest; null exempts the boleto from interest.
        paymentDeadline:
          description: New last day the boleto can be paid (YYYY-MM-DD).
          format: date
          type: string
      type: object
    NoticeDiscountBand:
      additionalProperties: false
      properties:
        amount:
          description: Discount amount or percentage, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        limitDate:
          description: Last day the discount applies (YYYY-MM-DD).
          format: date
          type: string
        type:
          description: How the discount is granted.
          enum:
            - FIXED
            - PERCENTAGE
          type: string
      required:
        - type
        - amount
        - limitDate
      type: object
    NoticeEffectiveTerms:
      additionalProperties: false
      properties:
        amount:
          description: Amount in force, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        discounts:
          description: Discount bands in force; an empty list when the boleto has no band.
          items:
            $ref: '#/components/schemas/NoticeDiscountBand'
          maxItems: 3
          type:
            - array
            - 'null'
        documentNumber:
          description: Document number in force.
          type: string
        dueDate:
          description: Due date in force (YYYY-MM-DD).
          format: date
          type: string
        fine:
          $ref: '#/components/schemas/NoticeFineTerms'
          description: Fine in force.
        interest:
          $ref: '#/components/schemas/NoticeInterestTerms'
          description: Interest in force.
        paymentDeadline:
          description: Last day the boleto can be paid (YYYY-MM-DD).
          format: date
          type: string
      required:
        - amount
        - dueDate
        - discounts
      type: object
    NoticeFineChange:
      additionalProperties: false
      properties:
        amount:
          description: Fine amount or percentage, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        startDate:
          description: Day the fine starts to apply (YYYY-MM-DD); absent, it applies from the day after the due date.
          format: date
          type: string
        type:
          description: How the fine is charged.
          enum:
            - FIXED
            - PERCENTAGE
          type: string
      required:
        - type
        - amount
      type:
        - object
        - 'null'
    NoticeFineTerms:
      additionalProperties: false
      properties:
        amount:
          description: Fine amount or percentage, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        startDate:
          description: Day the fine starts to apply (YYYY-MM-DD); absent, it applies from the day after the due date.
          format: date
          type: string
        type:
          description: How the fine is charged.
          enum:
            - FIXED
            - PERCENTAGE
          type: string
      required:
        - type
        - amount
      type: object
    NoticeInterestChange:
      additionalProperties: false
      properties:
        amount:
          description: Interest amount or percentage, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        startDate:
          description: Day the interest starts to accrue (YYYY-MM-DD); absent, it accrues from the day after the due date.
          format: date
          type: string
        type:
          description: How the interest accrues.
          enum:
            - DAILY_FIXED
            - DAILY_PERCENTAGE
            - MONTHLY_PERCENTAGE
          type: string
      required:
        - type
        - amount
      type:
        - object
        - 'null'
    NoticeInterestTerms:
      additionalProperties: false
      properties:
        amount:
          description: Interest amount or percentage, a decimal string.
          maxLength: 32
          pattern: ^[0-9]+(\.[0-9]{1,6})?$
          type: string
        startDate:
          description: Day the interest starts to accrue (YYYY-MM-DD); absent, it accrues from the day after the due date.
          format: date
          type: string
        type:
          description: How the interest accrues.
          enum:
            - DAILY_FIXED
            - DAILY_PERCENTAGE
            - MONTHLY_PERCENTAGE
          type: string
      required:
        - type
        - amount
      type: object
    NoticeRejection:
      additionalProperties: false
      properties:
        code:
          description: Stable error code.
          examples:
            - PBP-0014
          pattern: ^[A-Z]{3}-[0-9]{4}$
          type: string
        detail:
          description: Explanation of the refusal.
          type: string
        providerReason:
          description: Stable reason from the provider's refusal catalog, when the provider gave one.
          type: string
        status:
          description: HTTP status of the refusal.
          format: int64
          type: integer
        title:
          description: Short summary of the refusal.
          type: string
      required:
        - title
        - status
        - detail
        - code
      type: object
    NumberingCapabilities:
      additionalProperties: false
      properties:
        acceptsClientSupplied:
          description: Whether the payee may choose the nosso número. False exactly when mode is PROVIDER_ONLY.
          type: boolean
        echoIsAuthoritative:
          description: Whether the provider's echo of the number proves what the instrument carries.
          type: boolean
        maxWidth:
          description: Digits the instrument holds for a payee-chosen number; meaningful only when acceptsClientSupplied.
          examples:
            - 11
          format: int64
          minimum: 0
          type: integer
        mode:
          description: 'PAYEE_OR_PROVIDER: the provider accepts a nosso número chosen by the payee or numbers the boleto itself. PROVIDER_ONLY: the provider always numbers, and a nosso número sent by the client is refused with 422 PBP-0701. A provider that does not declare BOLETO_ISSUANCE reads PROVIDER_ONLY.'
          enum:
            - PAYEE_OR_PROVIDER
            - PROVIDER_ONLY
          examples:
            - PAYEE_OR_PROVIDER
          type: string
      required:
        - mode
        - acceptsClientSupplied
        - maxWidth
        - echoIsAuthoritative
      type: object
    NumberingRule:
      additionalProperties: false
      properties:
        rangeEnd:
          description: Last nosso número of the range, not below rangeStart. Up to 16 digits; answered always at 16 positions, padded with leading zeros.
          examples:
            - 0000000099999999
          pattern: ^[0-9]{1,16}$
          type: string
        rangeStart:
          description: First nosso número of the range, at least 1. Up to 16 digits; answered always at 16 positions, padded with leading zeros.
          examples:
            - '0000000001234567'
          pattern: ^[0-9]{1,16}$
          type: string
      required:
        - rangeStart
        - rangeEnd
      type: object
    PayeeResponse:
      additionalProperties: false
      properties:
        name:
          type: string
        taxId:
          type: string
      type: object
    PayerRequest:
      additionalProperties: false
      properties:
        address:
          $ref: '#/components/schemas/AddressRequest'
        document:
          description: Payer CPF or CNPJ, digits only.
          type: string
        name:
          description: Payer full name.
          type: string
      required:
        - document
        - name
      type: object
    PayerResponse:
      additionalProperties: false
      properties:
        address:
          $ref: '#/components/schemas/AddressResponse'
        document:
          type: string
        name:
          type: string
      required:
        - name
        - document
      type: object
    PaymentCapabilities:
      additionalProperties: false
      properties:
        segments:
          description: Barcode segments the provider pays and consults. Empty for a provider that pays neither.
          items:
            enum:
              - BANKSLIP
              - UTILITIES
            type: string
          type:
            - array
            - 'null'
          uniqueItems: true
      required:
        - segments
      type: object
    PaymentDashboardResponse:
      additionalProperties: false
      properties:
        byStatus:
          additionalProperties:
            $ref: '#/components/schemas/PaymentTypeCountAmount'
          type: object
        byType:
          additionalProperties:
            $ref: '#/components/schemas/PaymentTypeCountAmount'
          type: object
        totalAmount:
          type: string
        totalApproved:
          format: int64
          type: integer
        totalCanceled:
          format: int64
          type: integer
        totalCreated:
          format: int64
          type: integer
        totalExecuted:
          format: int64
          type: integer
        totalFailed:
          format: int64
          type: integer
        totalPendingApproval:
          format: int64
          type: integer
        totalRejected:
          format: int64
          type: integer
        totalScheduled:
          description: Number of payments in the SCHEDULED state. Payments initiated through this API execute immediately and are not created in this state, so a non-zero value reflects a SCHEDULED state reported by the payment provider. These payments are also counted under byStatus.SCHEDULED.
          format: int64
          type: integer
        totalSettled:
          format: int64
          type: integer
        totalSettledAmount:
          type: string
        totalUnconfirmed:
          description: 'Payments in the UNCONFIRMED state: the outcome at the payment provider is not known yet. A payment whose initiation was answered 202 is counted here until it resolves. The same rows are also counted under byStatus.UNCONFIRMED.'
          format: int64
          type: integer
      required:
        - totalUnconfirmed
        - totalCreated
        - totalScheduled
        - totalSettled
        - totalFailed
        - totalRejected
        - totalCanceled
        - totalPendingApproval
        - totalApproved
        - totalExecuted
        - totalAmount
        - totalSettledAmount
        - byType
        - byStatus
      type: object
    PaymentDeadline:
      additionalProperties: false
      properties:
        aboveMaximum:
          description: 'True when the configured days are past maxDays: the provider''s maximum fell below them after they were written. Write days within maxDays, or return to the default.'
          examples:
            - false
          type: boolean
        days:
          description: Calendar days after the due date of the payment deadline in force; 0 is a deadline on the due date. The tenant's days, or providerDefaultDays when it configured none.
          examples:
            - 30
          format: int64
          minimum: 0
          type: integer
        isDefault:
          description: 'True when no days are configured for the provider, or they were returned to the default: the provider''s default applies.'
          examples:
            - true
          type: boolean
        maxDays:
          description: Furthest deadline the provider accepts, in calendar days after the due date. A write above it is refused with 422 PBP-0702 reason PAYMENT_DEADLINE_ABOVE_MAXIMUM.
          examples:
            - 365
          format: int64
          minimum: 0
          type: integer
        providerDefaultDays:
          description: Default payment deadline the provider declares, in calendar days after the due date.
          examples:
            - 30
          format: int64
          minimum: 0
          type: integer
        providerType:
          description: Provider the setting belongs to.
          examples:
            - BTG
          maxLength: 20
          type: string
        updatedAt:
          description: When the setting was last written, in UTC. Null when never written.
          examples:
            - '2026-11-15T14:05:09Z'
          format: date-time
          type:
            - string
            - 'null'
        updatedByType:
          description: Kind of principal of the last write. Null when never written.
          enum:
            - USER
            - MACHINE
            - SYSTEM
          examples:
            - USER
          type:
            - string
            - 'null'
        version:
          description: Version of this (tenant, provider) setting. 0 when never written. Incremented by every accepted write, including a return to the default. A write sends it back; a stale one is refused with 409 PBP-0705.
          examples:
            - 0
          format: int64
          minimum: 0
          type: integer
      required:
        - providerType
        - days
        - isDefault
        - providerDefaultDays
        - maxDays
        - aboveMaximum
        - version
        - updatedAt
        - updatedByType
      type: object
    PaymentDeadlineChange:
      additionalProperties: false
      properties:
        changedAt:
          description: When the change was made, in UTC.
          examples:
            - '2026-11-15T14:05:09Z'
          format: date-time
          type: string
        changedBy:
          description: Identifier of the principal (subject of its token).
          examples:
            - user:4b1d2c3e-5f6a-7b8c-9d0e-1f2a3b4c5d6e
          maxLength: 255
          minLength: 1
          type: string
        changedByType:
          description: Kind of principal that made the change.
          enum:
            - USER
            - MACHINE
            - SYSTEM
          examples:
            - USER
          type: string
        id:
          description: Identifier of the change.
          examples:
            - 019a5c1e-2b3d-7f4a-8c5d-6e7f8a9b0c1d
          format: uuid
          type: string
        newDays:
          description: Days after the change; null on a return to the provider's default.
          examples:
            - 10
          format: int64
          minimum: 0
          type:
            - integer
            - 'null'
        previousDays:
          description: Days before the change; null when the provider's default applied.
          examples:
            - 30
          format: int64
          minimum: 0
          type:
            - integer
            - 'null'
        providerType:
          description: Provider whose default payment deadline changed.
          examples:
            - BTG
          maxLength: 20
          type: string
        reason:
          description: Reason given with the change.
          examples:
            - Shorter collection window for this portfolio.
          maxLength: 500
          minLength: 1
          type: string
        traceId:
          description: Trace of the request that made the change, for audit.
          examples:
            - 4bf92f3577b34da6a3ce929d0e0e4736
          maxLength: 64
          type: string
        version:
          description: Version the change left the setting at.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
      required:
        - id
        - providerType
        - previousDays
        - newDays
        - version
        - changedByType
        - changedBy
        - reason
        - changedAt
      type: object
    PaymentDeadlineHistoryPage:
      additionalProperties: false
      properties:
        items:
          description: Changes of the page, the most recent first. A tenant with no change answers an empty list.
          items:
            $ref: '#/components/schemas/PaymentDeadlineChange'
          type:
            - array
            - 'null'
        limit:
          description: Changes per page.
          examples:
            - 20
          format: int64
          maximum: 100
          minimum: 1
          type: integer
        page:
          description: Page number, one-based.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
        total:
          description: Number of changes of the tenant's default payment deadlines. A page past the last change answers an empty items list.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
      required:
        - items
        - page
        - limit
        - total
      type: object
    PaymentDeadlineList:
      additionalProperties: false
      properties:
        items:
          description: One item per provider installed on this deployment that registers a payment deadline and leaves its default to this setting, configured or not, ordered by provider.
          items:
            $ref: '#/components/schemas/PaymentDeadline'
          type:
            - array
            - 'null'
      required:
        - items
      type: object
    PaymentNotice:
      additionalProperties: true
      properties:
        amount:
          description: Payment amount, a decimal string with two places.
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        canceledAt:
          description: When the payment was canceled, RFC 3339 in UTC.
          format: date-time
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - PAYMENT
          type: string
        errorMessage:
          description: Why the payment failed.
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - PAYMENT_SETTLED
            - PAYMENT_REJECTED
            - PAYMENT_FAILED
            - PAYMENT_CANCELED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        failedAt:
          description: When the payment failed, RFC 3339 in UTC.
          format: date-time
          type: string
        paymentId:
          description: Payment identifier.
          format: uuid
          type: string
        providerId:
          description: Payment identifier at the provider; absent when the provider gave none.
          type: string
        rejectedAt:
          description: When the payment was rejected, RFC 3339 in UTC.
          format: date-time
          type: string
        rejectionReason:
          description: Why the payment was rejected.
          type: string
        scheduledDate:
          description: When the payment is scheduled for, RFC 3339 in UTC.
          format: date-time
          type: string
        settledAmount:
          description: Amount settled, as the provider reported it.
          pattern: ^[0-9]+\.[0-9]{2}$
          type: string
        settledAt:
          description: When the payment was settled, RFC 3339 in UTC.
          format: date-time
          type: string
        status:
          description: Payment status after the write.
          enum:
            - SETTLED
            - REJECTED
            - FAILED
            - CANCELED
          type: string
      required:
        - event
        - entityType
        - paymentId
        - status
        - amount
        - eventId
      type: object
    PaymentProviderBinding:
      additionalProperties: false
      properties:
        paymentId:
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        providerId:
          description: Identifier of the payment at the provider. Null while UNCONFIRMED without a provider answer.
          examples:
            - a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d
          maxLength: 100
          type:
            - string
            - 'null'
        providerType:
          description: Provider identifier, uppercase. Records created before provider routing read BTG.
          examples:
            - BTG
          maxLength: 20
          minLength: 1
          pattern: ^[A-Z][A-Z0-9_]{0,19}$
          type: string
      required:
        - paymentId
        - providerType
        - providerId
      type: object
    PaymentTypeCountAmount:
      additionalProperties: false
      properties:
        amount:
          type: string
        count:
          format: int64
          type: integer
      required:
        - count
        - amount
      type: object
    PcrCommand:
      additionalProperties: false
      properties:
        attempts:
          description: How many times the command was sent.
          examples:
            - 4
          format: int64
          minimum: 0
          type: integer
        createdAt:
          description: When the command was recorded, RFC 3339 in UTC.
          examples:
            - '2026-11-10T12:00:00Z'
          format: date-time
          type: string
        id:
          description: Identifier of the command.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a03
          format: uuid
          type: string
        idempotencyKey:
          description: Idempotency key the command's sends carry. A retryable refusal of the PCR, which the PCR records under the key and repeats to any resend under it, replaces the key for the next send; the PCR keeps each key from its first send for a retention it sets, 24 hours by default.
          examples:
            - f47ac10b-58cc-4372-a567-0e02b2c3d479
          format: uuid
          type: string
        lastResponse:
          $ref: '#/components/schemas/FailureReason'
          description: The last answer that did not accept the command, or the lack of one, classified by the PCR's code and never by the HTTP status. Absent before the first such answer and once the command is accepted.
        nextAttemptAt:
          description: 'When the next attempt is due, RFC 3339 in UTC: after a closed grade, its next opening; while a send waits for its answer, the earliest it is sent again if none arrives. Null when no attempt is scheduled: the command has an outcome or is held for the operator.'
          examples:
            - '2026-11-10T12:05:00Z'
          format: date-time
          type:
            - string
            - 'null'
        organizationId:
          description: Midaz organization of the related account; null when there is none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        state:
          description: 'Where the command is. PENDING: not sent yet, or held for the operator after an answer no resend can fix (then nextAttemptAt is null). SENT: sent, without a final outcome yet. UNCONFIRMED: a title registration the PCR accepted and then reported it could not submit; it ends with the late registration or when the operator settles it. ACCEPTED: accepted by the PCR, or its effect confirmed at the PCR. REJECTED_FINAL: refused for good. AWAITING_GRADE: refused because the PCR''s grade was closed; the next attempt is at its next opening. ABANDONED: closed by the operator.'
          enum:
            - PENDING
            - SENT
            - UNCONFIRMED
            - ACCEPTED
            - REJECTED_FINAL
            - AWAITING_GRADE
            - ABANDONED
          examples:
            - AWAITING_GRADE
          type: string
        targetId:
          description: 'Identifier of the resource the command acts on, of the kind targetType names: a title, a beneficiary, an agreement, a boleto payment the institution received as the receiving institution (RECEIVER_PAYMENT), or a divergence between the PCR''s beneficiary base and the agreements (AGREEMENT_DIVERGENCE).'
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type: string
        targetType:
          description: Kind of resource the command acts on.
          enum:
            - TITLE
            - BENEFICIARY
            - AGREEMENT
            - RECEIVER_PAYMENT
            - AGREEMENT_DIVERGENCE
          examples:
            - TITLE
          type: string
        titleId:
          description: Collections title the command relates to; null when it relates to none.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type:
            - string
            - 'null'
        type:
          description: What the command asks the PCR to do.
          enum:
            - REGISTER_TITLE
            - AMEND_TITLE
            - WRITE_OFF_BY_DESTINATARIA
            - REGISTER_BENEFICIARY
            - UPDATE_BENEFICIARY
            - EXCLUDE_BENEFICIARY_RELATIONSHIP
            - RECEIVER_WRITE_OFF
            - CANCEL_RECEIVER_WRITE_OFF
            - QUERY_BENEFICIARY_BASE
          examples:
            - REGISTER_TITLE
          type: string
        updatedAt:
          description: When the command last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-10T12:00:01Z'
          format: date-time
          type: string
      required:
        - id
        - type
        - targetType
        - targetId
        - state
        - idempotencyKey
        - attempts
        - createdAt
      type: object
    PcrCommandList:
      additionalProperties: false
      properties:
        items:
          description: The page's commands, oldest first.
          items:
            $ref: '#/components/schemas/PcrCommand'
          type: array
        limit:
          description: Most commands the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    PcrConnection:
      additionalProperties: false
      properties:
        bankCode:
          description: 'Number code of the institution: positions 1 to 3 of the barcode and the bank code printed on the boleto.'
          examples:
            - '699'
          pattern: ^[0-9]{3}$
          type: string
        bankCodeCheckDigit:
          description: Check digit printed after the bank code in the header of the boleto document, as informed by the institution, never computed; null when not informed.
          examples:
            - '7'
          pattern: ^[0-9X]$
          type:
            - string
            - 'null'
        baseUrl:
          description: Address of the institution's PCR API.
          examples:
            - https://pcr.instituicao.internal
          format: uri
          maxLength: 2048
          type: string
        connectionToken:
          description: Token of the connection's current notice route; changes at every rotation. Null before the first subscription completes. The signing key is never answered.
          examples:
            - pcn_8Qe2xV7kLm4Rt9Wb1Zc3Hy
          pattern: ^[A-Za-z0-9_-]{22,64}$
          readOnly: true
          type:
            - string
            - 'null'
        id:
          description: Identifier of the connection.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a00
          format: uuid
          type: string
        institutionName:
          description: Name of the institution printed in the header of the boleto document; null when not informed.
          examples:
            - Banco da Instituição S.A.
          maxLength: 60
          minLength: 1
          type:
            - string
            - 'null'
        ispb:
          description: ISPB of the institution.
          examples:
            - '12345678'
          maxLength: 8
          minLength: 8
          pattern: ^[0-9A-Z]{8}$
          type: string
        licenseState:
          description: State of the institution's PCR license. UNKNOWN while the PCR does not expose it; INVALID refuses the commands to that PCR.
          enum:
            - VALID
            - INVALID
            - UNKNOWN
          examples:
            - UNKNOWN
          type: string
        noticeEndpointPath:
          description: Path of the notice route of the current token. Null before the first subscription completes.
          examples:
            - /v1/webhooks/pcr/pcn_8Qe2xV7kLm4Rt9Wb1Zc3Hy
          maxLength: 128
          readOnly: true
          type:
            - string
            - 'null'
        noticeEndpointUrl:
          description: Full address of the notice route of the current token, the one registered in the PCR subscription. Null before the first subscription completes.
          examples:
            - https://payments.instituicao.internal/v1/webhooks/pcr/pcn_8Qe2xV7kLm4Rt9Wb1Zc3Hy
          format: uri
          maxLength: 2048
          readOnly: true
          type:
            - string
            - 'null'
        subscription:
          $ref: '#/components/schemas/PcrNoticeSubscription'
          description: The notice subscription at the PCR.
        updatedAt:
          description: When the connection last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-09T15:04:05Z'
          format: date-time
          type: string
        updatedBy:
          $ref: '#/components/schemas/Actor'
          description: Who made the last change.
        version:
          description: Version of the connection; a replacement sends it back.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
      required:
        - id
        - baseUrl
        - ispb
        - bankCode
        - connectionToken
        - noticeEndpointPath
        - noticeEndpointUrl
        - licenseState
        - subscription
        - version
        - updatedAt
      type: object
    PcrNotice:
      additionalProperties: false
      properties:
        appliedAt:
          description: When the effect of the notice was applied, RFC 3339 in UTC, only in APPLIED; null in every other state.
          examples:
            - '2026-11-10T12:00:01Z'
          format: date-time
          type:
            - string
            - 'null'
        conflictReason:
          description: 'Why the notice contradicts the state of its title, only in CONFLICT; null in every other state. LATE_REGISTRATION: a registration notice received after its title was already closed, failed or withdrawn.'
          enum:
            - LATE_REGISTRATION
            -
          examples:
            - LATE_REGISTRATION
          type:
            - string
            - 'null'
        connectionId:
          description: Connection to the PCR the notice arrived through.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a20
          format: uuid
          type: string
        correlation:
          $ref: '#/components/schemas/PcrNoticeCorrelation'
          description: What the notice carries to be matched with a title, and the title it was matched with.
        eventId:
          description: 'Identifier of the PCR''s event, the same in every delivery of it: a notice is stored once per connection and event.'
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a31
          format: uuid
          type: string
        id:
          description: Identifier of the notice.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a30
          format: uuid
          type: string
        occurredAt:
          description: When the event occurred at the PCR, RFC 3339 in UTC.
          examples:
            - '2026-11-10T11:59:58Z'
          format: date-time
          type: string
        organizationId:
          description: Midaz organization of the title the notice was matched with; null while it is matched with none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        receivedAt:
          description: When collections received and stored the notice, RFC 3339 in UTC. The list is ordered by it, and from and to bound it.
          examples:
            - '2026-11-10T12:00:00Z'
          format: date-time
          type: string
        state:
          description: 'Where the notice stands. RECEIVED: stored and not applied yet. APPLIED: its effect was applied, at appliedAt. PENDING_ASSOCIATION: no title takes it yet, why is in stateReason; collections keeps it and never discards it on its own. CONFLICT: it contradicts the state of its title and is not applied silently, why is in conflictReason. DISCARDED: kept without effect, why is in stateReason.'
          enum:
            - RECEIVED
            - APPLIED
            - PENDING_ASSOCIATION
            - CONFLICT
            - DISCARDED
          examples:
            - APPLIED
          type: string
        stateReason:
          description: 'Why the notice is pending association or discarded; null in every other state. NOTICE_NOT_CORRELATED: it matches no title of the connection, or cannot be applied to the one it names. EVENT_TYPE_NOT_CONSUMED: collections does not consume its type. STALE_VERSION: a registration notice older than the version already applied. DISCARDED_BY_OPERATOR: an operator discarded it. WRITTEN_OFF_AT_NUCLEA: a late registration resolved by a write-off requested at the Núclea.'
          enum:
            - NOTICE_NOT_CORRELATED
            - EVENT_TYPE_NOT_CONSUMED
            - STALE_VERSION
            - DISCARDED_BY_OPERATOR
            - WRITTEN_OFF_AT_NUCLEA
            -
          examples:
            - NOTICE_NOT_CORRELATED
          type:
            - string
            - 'null'
        type:
          description: The PCR's event type name. A type collections does not consume is stored and discarded at receipt, never refused.
          examples:
            - boleto.writeoff_received
          maxLength: 64
          pattern: ^[a-z]+\.[a-z_]+$
          type: string
      required:
        - id
        - eventId
        - connectionId
        - type
        - occurredAt
        - receivedAt
        - state
      type: object
    PcrNoticeCorrelation:
      additionalProperties: false
      properties:
        externalId:
          description: The externalId the notice names, on the boleto notices; null when it names none.
          examples:
            - 9b2e6d4c-1a0e-4f11-8c3d-5f2b8a8e3c1d
          format: uuid
          type:
            - string
            - 'null'
        pcrBoletoId:
          description: The PCR's identifier of the boleto the notice names; null when it names none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a21
          format: uuid
          type:
            - string
            - 'null'
        pcrWriteOffId:
          description: The PCR's identifier of the write-off the notice names; null when it names none.
          examples:
            - '20261110000000123'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        registrationSequence:
          description: 'Sequence number of the registration update of the boleto the notice carries (numSeqAtlzCadTit), as text: it orders the registration notices of a title. Null when it carries none.'
          examples:
            - '123'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        registrationVersion:
          description: Reference of the registration update of the boleto the notice carries (numRefAtlCadTit); null when it carries none.
          examples:
            - '7'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        titleId:
          description: Collections title the notice was matched with; null while it is matched with none.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type:
            - string
            - 'null'
      type: object
    PcrNoticeList:
      additionalProperties: false
      properties:
        items:
          description: The page's notices, oldest first.
          items:
            $ref: '#/components/schemas/PcrNotice'
          type: array
        limit:
          description: Most notices the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    PcrNoticeSubscription:
      additionalProperties: false
      properties:
        eventTypes:
          description: Event types subscribed, each the PCR's event type name, such as boleto.writeoff_received; empty before the first subscription.
          items:
            type: string
          maxItems: 64
          type: array
          uniqueItems: true
        includePii:
          description: 'Always false: the notices carry no personal data.'
          examples:
            - false
          type: boolean
        lastSyncError:
          $ref: '#/components/schemas/Detail'
          description: 'The problem the last synchronization failed with, as its route answered it: the PCR''s code in details.pcrCode when the PCR refused it. Absent when it did not fail.'
        lastSyncedAt:
          description: When the subscription was last synchronized with the PCR, RFC 3339 in UTC; null before the first.
          examples:
            - '2026-11-09T15:04:05Z'
          format: date-time
          type:
            - string
            - 'null'
        pcrState:
          description: State of the subscription as the PCR reports it; null before the first subscription.
          enum:
            - ACTIVE
            - PAUSED
            - FAILING
            -
          examples:
            - ACTIVE
          type:
            - string
            - 'null'
        pendingOperation:
          description: 'A creation or rotation started and not finished: a retry within 24 hours finishes it with the same secret. Null when nothing is pending.'
          enum:
            - CREATE
            - ROTATE
            -
          examples:
            - CREATE
          type:
            - string
            - 'null'
        pendingSince:
          description: When the pending change started, RFC 3339 in UTC; after 24 hours the PCR no longer returns the same secret and a new rotation is needed. Null when nothing is pending.
          examples:
            - '2026-11-09T15:04:05Z'
          format: date-time
          type:
            - string
            - 'null'
        previousConnectionValidUntil:
          description: End of the window in which the previous token and signing key are still served after a rotation, RFC 3339 in UTC; null outside a rotation.
          examples:
            - '2026-11-10T15:04:05Z'
          format: date-time
          type:
            - string
            - 'null'
        secretRotatedAt:
          description: When a signing secret was last stored, at the creation or at a rotation, RFC 3339 in UTC; null before the first.
          examples:
            - '2026-11-09T15:04:05Z'
          format: date-time
          type:
            - string
            - 'null'
        subscriptionId:
          description: Identifier of the subscription at the PCR; null before the first subscription.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a01
          format: uuid
          type:
            - string
            - 'null'
        syncState:
          description: 'How the subscription at the PCR compares with what collections expects. NOT_SUBSCRIBED: no subscription. SYNCED: address, event types and state match. DIVERGENT: the PCR holds it differently, for example paused or changed in the PCR''s own console. SYNC_FAILED: the last attempt failed (lastSyncError).'
          enum:
            - NOT_SUBSCRIBED
            - SYNCED
            - DIVERGENT
            - SYNC_FAILED
          examples:
            - NOT_SUBSCRIBED
          type: string
        url:
          description: Address registered at the PCR; null before the first subscription.
          examples:
            - https://payments.instituicao.internal/v1/webhooks/pcr/pcn_8Qe2xV7kLm4Rt9Wb1Zc3Hy
          format: uri
          maxLength: 2048
          type:
            - string
            - 'null'
      required:
        - syncState
        - eventTypes
        - includePii
      type: object
    PcrWebhookDelivery:
      additionalProperties: false
      properties:
        attempts:
          description: How many times the PCR attempted the delivery.
          examples:
            - 8
          format: int64
          minimum: 0
          type: integer
        eventId:
          description: Identifier of the event, the same in every delivery of it.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a11
          format: uuid
          type: string
        eventType:
          description: The PCR's event type name.
          examples:
            - boleto.writeoff_received
          maxLength: 64
          pattern: ^[a-z]+[.][a-z_]+$
          type: string
        id:
          description: Identifier of the delivery at the PCR, the one redeliverPcrNotice takes.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a10
          format: uuid
          type: string
        lastAttemptAt:
          description: When the PCR last attempted the delivery, RFC 3339 in UTC; null before the first attempt.
          examples:
            - '2026-11-10T13:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        lastError:
          description: Last error of the delivery as the PCR recorded it; null when there is none.
          examples:
            - timeout
          maxLength: 1024
          type:
            - string
            - 'null'
        lastStatusCode:
          description: Last HTTP status the notice intake answered; null when no answer arrived.
          examples:
            - 401
          format: int64
          maximum: 599
          minimum: 100
          type:
            - integer
            - 'null'
        nextAttemptAt:
          description: When the PCR attempts the delivery next, RFC 3339 in UTC; null when no attempt is scheduled.
          examples:
            - '2026-11-10T13:05:00Z'
          format: date-time
          type:
            - string
            - 'null'
        noticeId:
          description: 'Notice stored by collections with the same eventId, while it is kept: then no redelivery is needed. Null when no notice with that eventId arrived, and also once a notice that arrived and was applied or discarded is purged past the tenant''s technicalRetentionDays. A null noticeId alone does not call for a redelivery; a FAILED state does.'
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a12
          format: uuid
          type:
            - string
            - 'null'
        state:
          description: 'State of the delivery at the PCR. PENDING: not attempted yet. DELIVERED: the notice intake acknowledged it. RETRYING: the PCR attempts it again. FAILED: the PCR gave up after its attempts; redeliverPcrNotice asks for it again.'
          enum:
            - PENDING
            - DELIVERED
            - RETRYING
            - FAILED
          examples:
            - FAILED
          type: string
      required:
        - id
        - eventId
        - eventType
        - state
        - attempts
      type: object
    PcrWebhookDeliveryList:
      additionalProperties: false
      properties:
        items:
          description: The page's deliveries, in the PCR's order.
          items:
            $ref: '#/components/schemas/PcrWebhookDelivery'
          type: array
        limit:
          description: Most deliveries the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 1100
          type:
            - string
            - 'null'
        prevCursor:
          description: 'Always null: the PCR''s list is read forwards only. To go back, request the first page again.'
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    PdfReadiness:
      additionalProperties: false
      properties:
        initialBackoffMs:
          description: First wait of the exponential backoff, in milliseconds.
          examples:
            - 200
          format: int64
          minimum: 0
          type: integer
        maxBackoffMs:
          description: Longest single wait, in milliseconds.
          examples:
            - 2000
          format: int64
          minimum: 0
          type: integer
        maxTotalWaitMs:
          description: Longest total wait inside one request, in milliseconds.
          examples:
            - 4000
          format: int64
          minimum: 0
          type: integer
      required:
        - initialBackoffMs
        - maxBackoffMs
        - maxTotalWaitMs
      type: object
    PendingAmendmentResponse:
      additionalProperties: false
      properties:
        id:
          description: Amendment request identifier.
          format: uuid
          type: string
        requestedAt:
          description: When the request was recorded, in UTC.
          format: date-time
          type: string
        requestedChanges:
          $ref: '#/components/schemas/BoletoAmendmentTerms'
          description: 'The members the request changes, with their final values, in normalized form: null exempts a fine or interest, or removes the seu numero.'
      required:
        - id
        - requestedAt
        - requestedChanges
      type: object
    PendingCancellationResponse:
      additionalProperties: false
      properties:
        cancellationId:
          description: Id of the recorded cancellation attempt; not the key sent to the provider.
          format: uuid
          type: string
        requestedAt:
          description: When the attempt was recorded, in UTC.
          format: date-time
          type: string
      required:
        - cancellationId
        - requestedAt
      type: object
    PixConfigResponse:
      additionalProperties: false
      properties:
        complete:
          description: 'True when the key and the four members of the address are present, which is what a boleto that carries a Pix QR code needs from this configuration. It does not guarantee that an issuance is accepted: the receiver''s name and document are not part of this configuration, they come from the record of the collection account when a boleto is issued. A CPF or CNPJ key is checked against the document of that account''s holder; the other key types are not verified.'
          type: boolean
        pixKey:
          description: 'The configured Pix key. It is not masked: it is public data, carried in the Pix QR code of every boleto that pays it.'
          examples:
            - f34f8ec2-a4b7-41b4-8200-b53a07e00bac
          type: string
        receiverAddress:
          $ref: '#/components/schemas/PixReceiverAddressResponse'
          description: The receiver's address. Omitted when none is configured; a member that is not configured is omitted too.
        updatedAt:
          description: When the configuration was last written with POST /v1/admin/pix-config, in UTC. Omitted for a configuration never written with it.
          examples:
            - '2026-10-13T15:04:05Z'
          format: date-time
          type: string
        updatedBy:
          description: 'Identifier of the authenticated principal that made that write: the subject of its access token. Omitted like updatedAt.'
          type: string
      required:
        - pixKey
        - complete
      type: object
    PixKeyChangedNotice:
      additionalProperties: true
      properties:
        changeId:
          description: Identifier of the change.
          format: uuid
          type: string
        changedAt:
          description: When the key was changed, RFC 3339 in UTC.
          format: date-time
          type: string
        changedBy:
          description: Who changed the key.
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - PIX_CONFIG
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - PIX_KEY_CHANGED
          type: string
        eventId:
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        firstConfiguration:
          description: True when no key was configured before.
          type: boolean
        holderCheck:
          description: How the new key was checked against the holder of the issuing account.
          enum:
            - VERIFIED
            - UNVERIFIED
            - NOT_VERIFIABLE
          type: string
        keyType:
          description: Type of the key now configured.
          enum:
            - CPF
            - CNPJ
            - EMAIL
            - PHONE
            - EVP
            - UNKNOWN
          type: string
        previousKeyType:
          description: Type of the key replaced; only when a key was configured before.
          type: string
      required:
        - event
        - entityType
        - changeId
        - changedAt
        - changedBy
        - keyType
        - firstConfiguration
        - holderCheck
        - eventId
      type: object
    PixKeyHistoryItem:
      additionalProperties: false
      properties:
        changedAt:
          description: 'When the change was made, in UTC: the updatedAt POST /v1/admin/pix-config recorded for it.'
          examples:
            - '2026-10-31T14:05:09Z'
          format: date-time
          type: string
        changedBy:
          description: 'Identifier of the authenticated principal that made the change: the subject of its access token.'
          type: string
        firstConfiguration:
          description: 'True when the change was the tenant''s first key: there was no key before it.'
          type: boolean
        holderCheck:
          description: 'How the key the change set was held to the holder of the collection account. VERIFIED: a CPF or CNPJ key checked against the document of that account''s holder. UNVERIFIED: a CPF or CNPJ key written without that check. NOT_VERIFIABLE: a random, e-mail or phone key, whose owner no record tells.'
          enum:
            - VERIFIED
            - UNVERIFIED
            - NOT_VERIFIABLE
          examples:
            - VERIFIED
          type: string
        id:
          description: Identifier of the change. It is the changeId of the PIX_KEY_CHANGED notice that announced it.
          examples:
            - 019a3b8e-6f1c-7d2e-8a4b-5c6d7e8f9a01
          format: uuid
          type: string
        key:
          description: 'The key the change set, masked by its type: a CPF key shows its middle six digits (***.456.789-**), an e-mail key its first character and its domain (j***@example.com), and a phone key its country code and its last four digits (+55*******1234). A CNPJ key and a random key are shown whole. A key of type UNKNOWN is shown as ***.'
          examples:
            - '***.456.789-**'
          type: string
        keyType:
          description: Type of the key the change set. EVP is a random key; UNKNOWN is a key in none of the Pix key formats.
          enum:
            - CPF
            - CNPJ
            - EMAIL
            - PHONE
            - EVP
            - UNKNOWN
          examples:
            - CPF
          type: string
        previousKey:
          description: The key the change replaced, masked as key is. Omitted on the tenant's first configuration, when there was no key.
          examples:
            - f34f8ec2-a4b7-41b4-8200-b53a07e00bac
          type: string
        previousKeyType:
          description: Type of the key the change replaced. Omitted on the tenant's first configuration, when there was no key.
          enum:
            - CPF
            - CNPJ
            - EMAIL
            - PHONE
            - EVP
            - UNKNOWN
          examples:
            - EVP
          type: string
      required:
        - id
        - changedAt
        - changedBy
        - keyType
        - key
        - firstConfiguration
        - holderCheck
      type: object
    PixReceiverAddressRequest:
      additionalProperties: false
      properties:
        city:
          description: City.
          examples:
            - SAO PAULO
          minLength: 1
          type: string
        state:
          description: State code (UF), two upper-case letters.
          enum:
            - AC
            - AL
            - AM
            - AP
            - BA
            - CE
            - DF
            - ES
            - GO
            - MA
            - MG
            - MS
            - MT
            - PA
            - PB
            - PE
            - PI
            - PR
            - RJ
            - RN
            - RO
            - RR
            - RS
            - SC
            - SE
            - SP
            - TO
          examples:
            - SP
          type: string
        street:
          description: Street and number, on one line.
          examples:
            - Avenida Paulista 1000
          minLength: 1
          type: string
        zipCode:
          description: 'CEP with 8 digits and no hyphen: 01310-100 is refused with 400 PBP-0001.'
          examples:
            - '01310100'
          pattern: ^[0-9]{8}$
          type: string
          x-pattern-description: a CEP of 8 digits, without hyphen
      required:
        - street
        - city
        - state
        - zipCode
      type: object
    PixReceiverAddressResponse:
      additionalProperties: false
      properties:
        city:
          description: City.
          examples:
            - SAO PAULO
          type: string
        state:
          description: State code (UF).
          examples:
            - SP
          type: string
        street:
          description: Street and number.
          examples:
            - Avenida Paulista 1000
          type: string
        zipCode:
          description: CEP with 8 digits.
          examples:
            - '01310100'
          type: string
      type: object
    PooledAccountLink:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the final customer, which issues under the pooled account's agreement.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a41
          format: uuid
          type: string
        agreementId:
          description: Agreement of the pooled account the account issues under.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a42
          format: uuid
          type: string
        enabledAt:
          description: When the account was linked, RFC 3339 in UTC.
          examples:
            - '2026-11-11T10:00:00Z'
          format: date-time
          type: string
        enabledBy:
          $ref: '#/components/schemas/Actor'
          description: Who linked the account.
        id:
          description: Identifier of the link.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a40
          format: uuid
          type: string
        organizationId:
          description: Midaz organization of the linked account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type: string
        pooledAccountId:
          description: Pooled account that owns the agreement.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a43
          format: uuid
          type: string
        removedAt:
          description: When the link was undone, RFC 3339 in UTC; null while it is ACTIVE.
          examples:
            - '2026-11-12T10:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        state:
          description: 'ACTIVE: the account issues under the agreement. REMOVED: the link was undone; it does not come back.'
          enum:
            - ACTIVE
            - REMOVED
          examples:
            - ACTIVE
          type: string
      required:
        - id
        - organizationId
        - accountId
        - agreementId
        - pooledAccountId
        - state
        - enabledBy
        - enabledAt
      type: object
    PooledAccountLinkPage:
      additionalProperties: false
      properties:
        items:
          description: The page's links, oldest first.
          items:
            $ref: '#/components/schemas/PooledAccountLink'
          type: array
        limit:
          description: Most links the page holds.
          examples:
            - 20
          format: int64
          type: integer
        page:
          description: Number of the page, from 1.
          examples:
            - 1
          format: int64
          type: integer
        total:
          description: How many links the filters select.
          examples:
            - 3
          format: int64
          type: integer
      required:
        - page
        - limit
        - total
        - items
      type: object
    PreflightAccountingFlowResponse:
      additionalProperties: false
      properties:
        ambiguousRoutes:
          description: Route codes of the flow carried by more than one ledger route, when the flow is ambiguous.
          items:
            type: string
          type: array
        flow:
          description: Canonical flow code.
          examples:
            - BOLETO_IN
          type: string
        malformedReason:
          description: Which part of that route diverges, when the flow is malformed.
          type: string
        malformedRoute:
          description: First route code of the flow that diverges from the contract, when the flow is malformed.
          type: string
        missingActions:
          description: Actions the malformed route does not declare, when the reason is action_coverage.
          items:
            type: string
          type: array
        missingRoutes:
          description: Route codes of the flow absent from the ledger, when the flow is incomplete.
          items:
            type: string
          type: array
        status:
          description: complete, absent, incomplete, ambiguous or malformed.
          examples:
            - complete
          type: string
      required:
        - flow
        - status
        - missingRoutes
        - ambiguousRoutes
        - missingActions
      type: object
    PreflightAccountingRoutesResponse:
      additionalProperties: false
      properties:
        accountingRoutesEnabled:
          description: 'Whether ACCOUNTING_ROUTES_ENABLED is on in this deployment. Reported, not obeyed: the verdict is judged as if it were on.'
          type: boolean
        flows:
          description: One entry per canonical flow, in the order BOLETO_IN, PAYMENT_OUT, DARF_OUT. Empty when the route inventory could not be read.
          items:
            $ref: '#/components/schemas/PreflightAccountingFlowResponse'
          type: array
        ledgerId:
          description: Ledger the preflight read, in canonical form.
          type: string
        organizationId:
          description: Organization the preflight read, in canonical form.
          type: string
        ready:
          description: 'Whether the plugin can post against this ledger as far as accounting routes are concerned. It is the verdict on the whole ledger: a complete flow in a ledger that is not ready does not post.'
          type: boolean
        reason:
          description: Class of the verdict, from a closed vocabulary of accounting_routes_* reasons. Absent for a ledger that holds every canonical route.
          type: string
        unrecognisedMarkers:
          description: Ledger routes carrying a plugin marker the contract does not know.
          format: int64
          type: integer
        validateRoutes:
          description: The ledger's validateRoutes setting, or null when the settings could not be read.
          type:
            - boolean
            - 'null'
      required:
        - organizationId
        - ledgerId
        - accountingRoutesEnabled
        - ready
        - validateRoutes
        - unrecognisedMarkers
        - flows
      type: object
    ProviderCapabilities:
      additionalProperties: false
      properties:
        boleto:
          $ref: '#/components/schemas/BoletoCapabilities'
        numbering:
          $ref: '#/components/schemas/NumberingCapabilities'
        operations:
          description: Operation types the provider can be routed to. A route write for an operation outside this list is refused with 422 PBP-0702 CAPABILITY_MISSING.
          items:
            enum:
              - BOLETO_ISSUANCE
              - BANKSLIP_PAYMENT
              - BARCODE_BILL_PAYMENT
              - DARF_PAYMENT
            type: string
          type:
            - array
            - 'null'
          uniqueItems: true
        payment:
          $ref: '#/components/schemas/PaymentCapabilities'
        providerType:
          description: Provider identifier, uppercase, the same in every table and answer.
          examples:
            - BTG
          maxLength: 20
          minLength: 1
          pattern: ^[A-Z][A-Z0-9_]{0,19}$
          type: string
        webhook:
          $ref: '#/components/schemas/WebhookCapabilities'
      required:
        - providerType
        - operations
        - boleto
        - numbering
        - payment
        - webhook
      type: object
    ProviderCapabilitiesList:
      additionalProperties: false
      properties:
        items:
          description: One entry per provider connected to the tenant and installed on this deployment, ordered by providerType. Empty when none.
          items:
            $ref: '#/components/schemas/ProviderCapabilities'
          type:
            - array
            - 'null'
      required:
        - items
      type: object
    ProviderConnectRequest:
      additionalProperties: false
      type: object
    ProviderConnectResponse:
      additionalProperties: false
      properties:
        account_verified:
          type: boolean
        company_id:
          type: string
        provider_account_id:
          type: string
        provider_type:
          type: string
        status:
          type: string
        webhook_subscription_registered:
          description: 'Whether the subscription pointing the provider at webhook_url was written at the provider. ABSENT means no per-tenant webhook connection was issued, so there was nothing to register. TRUE means the provider holds webhook_url and the signing key the service generated for this connection. FALSE means the connect succeeded and webhook_url is valid, but the provider was not told where to deliver events, so deliveries to webhook_url may not arrive yet. Depending on the cause, the registration is retried automatically or needs an operator. Do not reconnect: that rotates the connection again. If deliveries do not start, call POST /v1/admin/providers/webhooks/{provider_type}/resubscribe or contact support.'
          type: boolean
        webhook_url:
          type: string
      required:
        - status
        - provider_type
        - account_verified
      type: object
    ProviderDisconnectBlockedProblem:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - properties:
            openOperations:
              properties:
                boletoBatches:
                  description: Batches with a submission not finalized.
                  format: int64
                  minimum: 0
                  type: integer
                boletos:
                  description: Boletos PENDING or CREATED.
                  format: int64
                  minimum: 0
                  type: integer
                payments:
                  description: Payments in a live status.
                  format: int64
                  minimum: 0
                  type: integer
                pendingNotices:
                  description: Inbound notices accepted and not yet processed.
                  format: int64
                  minimum: 0
                  type: integer
              required:
                - boletos
                - boletoBatches
                - payments
                - pendingNotices
              type: object
            reason:
              description: 'Present only on the reconnect refusal: the revocation of the last disconnect has not completed.'
              enum:
                - REVOCATION_PENDING
              type: string
            routedOperations:
              description: Operations of the route that point to the provider. Empty when only open operations block.
              items:
                enum:
                  - BOLETO_ISSUANCE
                  - BANKSLIP_PAYMENT
                  - BARCODE_BILL_PAYMENT
                  - DARF_PAYMENT
                type: string
              type: array
              uniqueItems: true
          type: object
      description: Problem document of the disconnect and reconnect 409. On the disconnect, `openOperations` and `routedOperations` are present only when code is PBP-0703. On the reconnect, PBP-0703 carries `reason` instead.
    ProviderDisconnectionRequest:
      additionalProperties: false
      properties:
        reason:
          description: Why the provider is disconnected or reconnected. Recorded in the disconnect history, also when the call is refused. Must not carry personal data or secrets.
          examples:
            - Contrato com o provider encerrado em 30/11.
          maxLength: 500
          minLength: 1
          pattern: \S
          type: string
      required:
        - reason
      type: object
    ProviderRouteChange:
      additionalProperties: false
      properties:
        changedAt:
          description: When the change was made, in UTC.
          examples:
            - '2026-11-06T09:12:00Z'
          format: date-time
          type: string
        changedBy:
          description: Identifier of the principal (subject of its token), or migration:<version> / system:bootstrap for seeds.
          examples:
            - migration:000071
          maxLength: 255
          minLength: 1
          type: string
        changedByType:
          description: Kind of principal that made the change.
          enum:
            - USER
            - MACHINE
            - SYSTEM
          examples:
            - USER
          type: string
        id:
          description: Identifier of the change.
          examples:
            - 019a3b8e-6f1c-7d2e-8a4b-5c6d7e8f9a01
          format: uuid
          type: string
        newProviderType:
          description: Provider after the change; null when the change removed the provider.
          examples:
            - BTG
          maxLength: 20
          type:
            - string
            - 'null'
        operationType:
          description: Operation whose provider changed.
          enum:
            - BOLETO_ISSUANCE
            - BANKSLIP_PAYMENT
            - BARCODE_BILL_PAYMENT
            - DARF_PAYMENT
          examples:
            - BOLETO_ISSUANCE
          type: string
        previousProviderType:
          description: Provider before the change; null when the operation had none.
          examples:
            - BTG
          maxLength: 20
          type:
            - string
            - 'null'
        reason:
          description: Reason given with the change; a fixed text for seeds.
          examples:
            - 'Onboarding do tenant: emissão no BTG.'
          maxLength: 500
          minLength: 1
          type: string
        traceId:
          description: Trace of the request that made the change, for audit. Absent for seeds without a trace.
          examples:
            - 4bf92f3577b34da6a3ce929d0e0e4736
          maxLength: 64
          type: string
      required:
        - id
        - operationType
        - previousProviderType
        - newProviderType
        - changedByType
        - changedBy
        - reason
        - changedAt
      type: object
    ProviderRouteEntry:
      additionalProperties: false
      properties:
        operationType:
          description: 'Operation type the provider is routed to. BOLETO_ISSUANCE: issuing boletos. BANKSLIP_PAYMENT: paying a 47-digit boleto. BARCODE_BILL_PAYMENT: paying a 48-digit bill starting with 8. DARF_PAYMENT: paying a DARF without barcode.'
          enum:
            - BOLETO_ISSUANCE
            - BANKSLIP_PAYMENT
            - BARCODE_BILL_PAYMENT
            - DARF_PAYMENT
          examples:
            - BOLETO_ISSUANCE
          type: string
        providerType:
          description: Provider of the operation; null when the operation has no provider.
          examples:
            - BTG
          maxLength: 20
          type:
            - string
            - 'null'
        status:
          description: ROUTED when the operation has a provider; NO_PROVIDER when it has none and every new operation of the type is refused with 422 PBP-0700.
          enum:
            - ROUTED
            - NO_PROVIDER
          examples:
            - ROUTED
          type: string
        updatedAt:
          description: When the route of this operation was last written, in UTC. Null when never configured.
          examples:
            - '2026-11-05T10:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        updatedBy:
          description: Identifier of the principal of the last write (subject of its token, or migration:<version> / system:bootstrap for seeds). Null when never configured.
          examples:
            - migration:000071
          maxLength: 255
          type:
            - string
            - 'null'
        updatedByType:
          description: 'Kind of principal of the last write: USER, a person; MACHINE, a machine credential; SYSTEM, the service itself. Null when never configured.'
          enum:
            - USER
            - MACHINE
            - SYSTEM
            -
          examples:
            - SYSTEM
          type:
            - string
            - 'null'
        version:
          description: Version of this (tenant, operation) route. 0 when never configured. Incremented by every accepted write and never reused, also after a removal. A write sends it back; a stale one is refused with 409 PBP-0705.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
      required:
        - operationType
        - status
        - providerType
        - version
      type: object
    ProviderRouteHistoryPage:
      additionalProperties: false
      properties:
        items:
          description: Changes of the page, the most recent first. A tenant with no change answers an empty list.
          items:
            $ref: '#/components/schemas/ProviderRouteChange'
          type:
            - array
            - 'null'
        limit:
          description: Changes per page.
          examples:
            - 20
          format: int64
          maximum: 100
          minimum: 1
          type: integer
        page:
          description: Page number, one-based.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
        total:
          description: Number of changes of the tenant's route. A page past the last change answers an empty items list.
          examples:
            - 5
          format: int64
          minimum: 0
          type: integer
      required:
        - items
        - page
        - limit
        - total
      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.
    ProviderRouteSet:
      additionalProperties: false
      properties:
        routes:
          description: Exactly the four operation types, always in the order BOLETO_ISSUANCE, BANKSLIP_PAYMENT, BARCODE_BILL_PAYMENT, DARF_PAYMENT, configured or not.
          items:
            $ref: '#/components/schemas/ProviderRouteEntry'
          maxItems: 4
          minItems: 4
          type:
            - array
            - 'null'
      required:
        - routes
      type: object
    PutCollectionsSettingsRequest:
      additionalProperties: false
      properties:
        agreementTemplate:
          description: Default agreement template, one item per product type.
          items:
            $ref: '#/components/schemas/AgreementSpec'
          maxItems: 8
          minItems: 1
          type: array
        autoEnablement:
          description: Whether a holder's agreement is enabled automatically on their first boleto.
          examples:
            - false
          type: boolean
        businessRetentionYears:
          default: 10
          description: 'Retention of business records, in years. The value is recorded only: no business record is purged.'
          examples:
            - 10
          format: int64
          maximum: 30
          minimum: 5
          type: integer
        reason:
          description: Reason for the change, recorded in the audit trail. Must not carry personal data.
          examples:
            - Default agreement template for the new portfolio.
          maxLength: 500
          minLength: 10
          type: string
        technicalRetentionDays:
          default: 90
          description: Retention of technical records, in days counted from each record's final state.
          examples:
            - 90
          format: int64
          maximum: 3650
          minimum: 30
          type: integer
        version:
          description: Version last read. Left out only to create the settings.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
      required:
        - agreementTemplate
        - autoEnablement
        - reason
      type: object
    PutPcrConnectionRequest:
      additionalProperties: false
      properties:
        bankCode:
          description: 'Number code of the institution: positions 1 to 3 of the barcode and the bank code printed on the boleto. 000 is refused with 422 PBP-0006, and 988, an institution without a number code of its own, with 422 PBP-0801. Once a title of the connection got a composed barcode, a change is refused with 422 PBP-0802; a title withdrawn before it was sent does not count.'
          examples:
            - '699'
          pattern: ^[0-9]{3}$
          type: string
        bankCodeCheckDigit:
          description: 'Check digit printed after the bank code in the header of the boleto document: one digit or X, as informed by the institution, never computed nor checked against bankCode. Optional; left out, it is stored null, and while it is null the document of a boleto issued through the LERIAN provider (GET /v1/boletos/{id}/pdf) is refused with 422 PBP-0800.'
          examples:
            - '7'
          pattern: ^[0-9X]$
          type: string
        baseUrl:
          description: Address of the institution's PCR API. Must match one of the PCR destinations the platform allows the tenant, by scheme, host and port; any other is refused with 422 PBP-0818.
          examples:
            - https://pcr.instituicao.internal
          format: uri
          maxLength: 2048
          pattern: ^https://
          type: string
        institutionName:
          description: 'Name of the institution printed in the header of the boleto document: 1 to 60 characters, not blank and without control characters; a blank name or one with a control character is refused with 422 PBP-0006. Optional; left out, it is stored null, and while it is null the document of a boleto issued through the LERIAN provider (GET /v1/boletos/{id}/pdf) is refused with 422 PBP-0800.'
          examples:
            - Banco da Instituição S.A.
          maxLength: 60
          minLength: 1
          type: string
        ispb:
          description: ISPB of the institution, 8 digits or capital letters.
          examples:
            - '12345678'
          maxLength: 8
          minLength: 8
          pattern: ^[0-9A-Z]{8}$
          type: string
        reason:
          description: Reason for the change, recorded in the audit trail. Must not carry personal data.
          examples:
            - Connection to the institution's PCR.
          maxLength: 500
          minLength: 10
          type: string
        version:
          description: Version last read. Left out only to create the connection.
          examples:
            - 1
          format: int64
          minimum: 1
          type: integer
      required:
        - baseUrl
        - ispb
        - bankCode
        - reason
      type: object
    QueueItem:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the target; null when the target has none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type:
            - string
            - 'null'
        ageSeconds:
          description: How long the item has been in its queue at the instant of the read, in whole seconds, counted from enteredAt.
          examples:
            - 5400
          format: int64
          minimum: 0
          type: integer
        amount:
          description: Amount of the write-off, of the credit entry or of the title, in reais, as a decimal string with two decimal places; null when the target has none.
          examples:
            - '1000.00'
          maxLength: 32
          pattern: ^[0-9]{1,15}(\.[0-9]{1,2})?$
          type:
            - string
            - 'null'
        availableActions:
          description: The operationIds of the operations that act on this item, only operations this instance serves; empty when none acts on one item.
          examples:
            -   - correctAgreementDivergence
                - adoptAgreementDivergence
          items:
            enum:
              - approveEnablement
              - rejectEnablement
              - correctAgreementDivergence
              - adoptAgreementDivergence
              - previewBulkAdoption
              - bulkAdoptInventoryRunDivergences
            type: string
          maxItems: 4
          type: array
        boletoId:
          description: Boleto of the host the target's title registers; null when the target has no title.
          examples:
            - 9b2e6d4c-1a0e-4f11-8c3d-5f2b8a8e3c1d
          format: uuid
          type:
            - string
            - 'null'
        enteredAt:
          description: When the item entered its queue, RFC 3339 in UTC; the order and the age count from it. A write-off not settled in its cycle, from when it was held, and one waiting for its STR credit, from the instant it could be released; a command held without a next attempt, from when it was held, and one resent to the PCR automatically, from when it was created; a credit entry, from when it was stalled; a notice, from when it was received; a beneficiary, from when its state changed, from the last write of its row when its relationship exclusion was refused, and from when its base situation became UNFIT when it is UNFIT; an agreement, from when its state changed; a divergence, from when it was detected.
          examples:
            - '2026-11-10T13:00:00Z'
          format: date-time
          type: string
        holderId:
          description: Holder of the target, the person in the platform's people registry; null when the target has none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
          format: uuid
          type:
            - string
            - 'null'
        id:
          description: 'Identifier of the item: the same for the same queue and target, so the item keeps it while its target stays in the queue.'
          examples:
            - b3d1f0a2-6c4e-5b8a-9f2d-1e0c7a5b3d9f
          format: uuid
          type: string
        lastAutomaticCheck:
          description: The last automatic check of the write-off's settlement at the PCR, only in NOT_SETTLED_IN_CYCLE; null in every other queue.
          oneOf:
            - $ref: '#/components/schemas/AutomaticSettlementCheck'
            - type: 'null'
        organizationId:
          description: Midaz organization of the target; null when the target has none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type:
            - string
            - 'null'
        queue:
          description: Queue of the item.
          enum:
            - STR_RELEASE_PENDING
            - NOT_SETTLED_IN_CYCLE
            - STUCK_PCR_COMMAND
            - STUCK_CREDIT_ENTRY
            - UNMATCHED_NOTICE
            - CONFLICTING_NOTICE
            - BENEFICIARY_REJECTED
            - ENABLEMENT_HELD_BY_ALERT
            - AGREEMENT_CLOSURE_EXCEPTION
            - AGREEMENT_DIVERGENCE
          examples:
            - AGREEMENT_DIVERGENCE
          type: string
        reasonCode:
          description: Why the item is in its queue; each reason belongs to one queue.
          enum:
            - STR_CREDIT_NOT_CONFIRMED
            - NOT_SETTLED_IN_CYCLE
            - SETTLEMENT_OVERDUE
            - PCR_NO_RESPONSE
            - PCR_INSTITUTION_REFUSAL
            - PCR_COLLECTIONS_DEFECT
            - SUBMISSION_UNCONFIRMED
            - LEDGER_REFUSED
            - INSUFFICIENT_FUNDS
            - LEDGER_NO_RESPONSE
            - NOTICE_NOT_CORRELATED
            - LATE_REGISTRATION
            - BENEFICIARY_REJECTED
            - BENEFICIARY_UNFIT
            - RELATIONSHIP_EXCLUSION_REFUSED
            - MARKET_ALERT_UNFIT
            - MARKET_ALERT_UNDER_REVIEW
            - MARKET_ALERT_FIT
            - AGREEMENT_CLOSURE_REFUSED
            - MISSING_IN_NUCLEA
            - MISSING_LOCALLY
            - ATTRIBUTE_MISMATCH
            - SITUATION_MISMATCH
          examples:
            - ATTRIBUTE_MISMATCH
          type: string
        reasonMessage:
          description: 'Why the item is in its queue, in words: a text collections wrote for the case (the command''s message, the reason of the beneficiary''s refusal, the detail of the write-off''s automatic check, the refusal by the host''s own checks that a credit entry stalled without an outcome got last, by its closed code), or the reason''s fixed message when it wrote none. It carries no personal data.'
          examples:
            - An attribute of the agreement differs between Núclea's base and the local record.
          maxLength: 500
          type: string
        targetId:
          description: Identifier of the resource the item is.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type: string
        targetType:
          description: Kind of resource the item is, in the vocabulary the audit trail names its targets with.
          enum:
            - TITLE
            - WRITE_OFF
            - CREDIT_ENTRY
            - PCR_COMMAND
            - PCR_NOTICE
            - BENEFICIARY
            - ENABLEMENT_BATCH
            - AGREEMENT
            - AGREEMENT_DIVERGENCE
            - POOLED_ACCOUNT_LINK
            - PCR_CONNECTION
            - PCR_SUBSCRIPTION
            - PCR_WEBHOOK_DELIVERY
            - COLLECTIONS_SETTINGS
            - ACCOUNT
          examples:
            - AGREEMENT_DIVERGENCE
          type: string
        titleId:
          description: Collections title of the target; null when the target has none.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae8
          format: uuid
          type:
            - string
            - 'null'
      required:
        - id
        - queue
        - targetType
        - targetId
        - reasonCode
        - reasonMessage
        - enteredAt
        - ageSeconds
        - availableActions
      type: object
    QueueItemList:
      additionalProperties: false
      properties:
        items:
          description: The page's items, oldest first.
          items:
            $ref: '#/components/schemas/QueueItem'
          type: array
        limit:
          description: Most items the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    QueueSummary:
      additionalProperties: false
      properties:
        availableActions:
          description: The operationIds of the operations that act on this queue's cases, only operations this instance serves; empty for a queue that is only followed.
          examples:
            -   - approveEnablement
                - rejectEnablement
          items:
            enum:
              - approveEnablement
              - rejectEnablement
              - correctAgreementDivergence
              - adoptAgreementDivergence
              - previewBulkAdoption
              - bulkAdoptInventoryRunDivergences
            type: string
          maxItems: 4
          type: array
        depth:
          description: How many items the queue holds.
          examples:
            - 3
          format: int64
          minimum: 0
          type: integer
        oldestEnteredAt:
          description: When the queue's oldest item entered it, RFC 3339 in UTC; null when the queue is empty.
          examples:
            - '2026-11-10T13:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        overAgeLimit:
          description: 'How many items reached the queue''s age limit: their age, counted from enteredAt, is at or over it. The limit is a per-tenant operational parameter of each queue.'
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
        queue:
          description: The queue.
          enum:
            - STR_RELEASE_PENDING
            - NOT_SETTLED_IN_CYCLE
            - STUCK_PCR_COMMAND
            - STUCK_CREDIT_ENTRY
            - UNMATCHED_NOTICE
            - CONFLICTING_NOTICE
            - BENEFICIARY_REJECTED
            - ENABLEMENT_HELD_BY_ALERT
            - AGREEMENT_CLOSURE_EXCEPTION
            - AGREEMENT_DIVERGENCE
          examples:
            - AGREEMENT_DIVERGENCE
          type: string
      required:
        - queue
        - depth
        - oldestEnteredAt
        - overAgeLimit
        - availableActions
      type: object
    QueueSummaryList:
      additionalProperties: false
      properties:
        items:
          description: One summary per delivered queue, in the contract's order.
          items:
            $ref: '#/components/schemas/QueueSummary'
          maxItems: 32
          type: array
      required:
        - items
      type: object
    ReconnectProviderResponse:
      additionalProperties: false
      properties:
        credentialActive:
          description: Whether the tenant has an active credential of the provider after the immediate credential sync. Always false for a provider that does not connect through a credential.
          type: boolean
        outcome:
          description: RECONNECTED, this call took the provider out of the disconnected state; ALREADY_CONNECTED, the provider was not disconnected.
          enum:
            - RECONNECTED
            - ALREADY_CONNECTED
          type: string
        providerType:
          description: Provider reconnected.
          examples:
            - LERIAN
          type: string
        reconnectedAt:
          description: When the provider was reconnected, in UTC. Null on ALREADY_CONNECTED when the provider was never disconnected.
          examples:
            - '2026-12-02T13:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
      required:
        - providerType
        - outcome
        - credentialActive
        - reconnectedAt
      type: object
    RepresentQuarantinedWebhookResponse:
      additionalProperties: false
      properties:
        dedupKey:
          type: string
        priorVerdict:
          type: string
        providerEventType:
          type: string
        providerType:
          type: string
        receivedAt:
          type: string
        representedAt:
          type: string
        retryCountBefore:
          format: int64
          type: integer
        status:
          type: string
        webhookId:
          type: string
      required:
        - webhookId
        - dedupKey
        - providerType
        - providerEventType
        - status
        - retryCountBefore
        - receivedAt
        - representedAt
      type: object
    ResubscribeWebhookSubscriptionRequest:
      additionalProperties: false
      properties:
        acknowledge_revoking:
          description: 'OPTIONAL, and it forces a write that would otherwise be refused. Name EXACTLY the resources the 409 reported, each one spelled as the refusal printed it (a bare entity name, or an entity/EVENT pair where only an event under a declared entity is at risk) and the re-registration proceeds and REMOVES them from the provider''s subscription. The set is re-measured at the provider on this call and compared against what you sent: a name you left out, or a name the provider is not holding outside the declared set, is refused with another 409 that says which. Comparison is exact per name (no case folding, no trimming) and insensitive to order; repeats are collapsed. Omit the field, or send an empty list, to get the ordinary refusal. It is NOT a conditional write: the provider offers none, so it cannot close the window between this service''s read and its write. What it closes is the window between the refusal you read and the call you sent.'
          examples:
            -   - PaymentSlip
                - PaymentSlipPay/SOME_EVENT
          items:
            type: string
          type:
            - array
            - 'null'
      type: object
    ResubscribeWebhookSubscriptionResource:
      additionalProperties: false
      properties:
        entity:
          type: string
        event_names:
          items:
            type: string
          type:
            - array
            - 'null'
      required:
        - entity
        - event_names
      type: object
    ResubscribeWebhookSubscriptionResponse:
      additionalProperties: false
      properties:
        provider_type:
          type: string
        resources:
          items:
            $ref: '#/components/schemas/ResubscribeWebhookSubscriptionResource'
          type:
            - array
            - 'null'
        status:
          type: string
        webhook_url:
          type: string
      required:
        - status
        - provider_type
        - webhook_url
        - resources
      type: object
    RevokeWebhookConnectionResponse:
      additionalProperties: false
      properties:
        provider_type:
          type: string
        revoked_connections:
          format: int64
          type: integer
        status:
          type: string
      required:
        - status
        - provider_type
        - revoked_connections
      type: object
    Title:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account that issues the title.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        agreementId:
          description: Agreement the title is issued under.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
          format: uuid
          type: string
        amount:
          description: Amount of the title in reais, as a decimal string with two decimal places.
          examples:
            - '1000.00'
          maxLength: 32
          pattern: ^[0-9]{1,15}(\.[0-9]{1,2})?$
          type: string
        barcode:
          description: The 44 digits of the barcode, only while the title is REGISTERED; null in every other state.
          examples:
            - '23791000000001000000000000000000123456700000'
          pattern: ^[0-9]{44}$
          type:
            - string
            - 'null'
        baseSituation:
          description: 'Situation of the title at Núclea''s base. OPEN: not written off. PAID: written off by its payment. CANCELLED: written off by the institution that issued it. LAPSED: written off by lapse, after its payment deadline passed.'
          enum:
            - OPEN
            - PAID
            - CANCELLED
            - LAPSED
          examples:
            - OPEN
          type: string
        blockState:
          description: Whether the payment of the title is blocked; only a notice of the PCR changes it.
          enum:
            - UNBLOCKED
            - BLOCKED
          examples:
            - UNBLOCKED
          type: string
        boletoId:
          description: Boleto of the host the title registers; it is the externalId sent to the PCR.
          examples:
            - 9b2e6d4c-1a0e-4f11-8c3d-5f2b8a8e3c1d
          format: uuid
          type: string
        connectionId:
          description: Connection to the PCR the title is registered through.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a01
          format: uuid
          type: string
        createdAt:
          description: When the title was issued, RFC 3339 in UTC.
          examples:
            - '2026-11-03T14:00:00Z'
          format: date-time
          type: string
        creditDelayBusinessDays:
          description: 'Business days, counted from a write-off, before its credit is released, copied from the agreement at issue: a later change of the agreement does not change it.'
          examples:
            - 0
          format: int64
          maximum: 30
          minimum: 0
          readOnly: true
          type: integer
        creditState:
          description: 'Where the credit of the title''s write-offs is. NONE: no entry, because the title has no write-off or its write-off moves no money. TO_RELEASE: credit waiting for its release. RELEASED: credit released to the account. REVERSED: credit reversed before its release. CHARGEBACK_PENDING: a reversal after the release that the ledger refused, waiting to be processed again. CHARGED_BACK: credit reversed after its release.'
          enum:
            - NONE
            - TO_RELEASE
            - RELEASED
            - REVERSED
            - CHARGEBACK_PENDING
            - CHARGED_BACK
          examples:
            - NONE
          type: string
        digitableLine:
          description: The 47 digits of the digitable line, only while the title is REGISTERED; null in every other state.
          examples:
            - '23790000090000000000000000012345670000000100000'
          pattern: ^[0-9]{47}$
          type:
            - string
            - 'null'
        documentNumber:
          description: Number the beneficiary gives the title (NumDocTit), printed as its document number; not unique. Null when the title has none.
          examples:
            - NF-2026/000123
          maxLength: 15
          minLength: 1
          pattern: ^[ -~]{1,15}$
          type:
            - string
            - 'null'
        dueDate:
          description: Due date of the title.
          examples:
            - '2026-11-10'
          format: date
          type: string
        failureReason:
          description: Why the title FAILED; null in every other state.
          oneOf:
            - $ref: '#/components/schemas/FailureReason'
            - type: 'null'
        held:
          description: Whether a write-off of the title has its credit release held.
          examples:
            - false
          type: boolean
        id:
          description: Identifier of the title.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type: string
        nucleaTitleNumber:
          description: Number Núclea gave the title when it registered it (NumIdentcTit); null before.
          examples:
            - '2026110300000000001'
          pattern: ^[0-9]{19}$
          type:
            - string
            - 'null'
        organizationId:
          description: Midaz organization of the account that issues the title.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type: string
        originalTitleId:
          description: Title this one corrects; null when it corrects none.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5aa1
          format: uuid
          type:
            - string
            - 'null'
        ourNumber:
          description: Nosso número of the title, answered at 16 digits.
          examples:
            - '0000000001234567'
          pattern: ^[0-9]{1,16}$
          type: string
        overdueNotifiedAt:
          description: When the title's overdue notice was recorded, the day after its effective due date (the due date moved to the next business day of the SILOC calendar), RFC 3339 in UTC; null while no overdue notice was recorded for the current due date. Set once per due date; an amendment that moves the due date clears it.
          examples:
            - '2026-11-11T09:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        paymentDeadline:
          description: 'Last day the title can be paid: the one given at issue, or the due date plus the agreement''s paymentDeadlineDays.'
          examples:
            - '2026-12-10'
          format: date
          type:
            - string
            - 'null'
        pcrBoletoId:
          description: Identifier the PCR gave the boleto when it accepted the registration; null until the PCR gave one.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a91
          format: uuid
          type:
            - string
            - 'null'
        pooledAccountLinkId:
          description: Link to the pooled account the title is issued under; null when it is issued under the agreement of its own account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a81
          format: uuid
          type:
            - string
            - 'null'
        portfolio:
          description: 'Portfolio of the title, its agreement''s: 01 Simples, 02 Vinculada, 03 Caucionada, 04 Descontada, 05 Vendor, 06 Cessão.'
          enum:
            - '01'
            - '02'
            - '03'
            - '04'
            - '05'
            - '06'
          examples:
            - '01'
          type: string
        registrationSequence:
          description: Last update sequence of the boleto applied (numSeqAtlzCadTit), which orders the notices. Null before the registration.
          examples:
            - '12'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        registrationState:
          description: 'Where the title is in its issue and registration. AWAITING_BENEFICIARY: issued under an agreement Núclea has not accepted yet, and not sent until it is. PENDING_SUBMISSION: not yet accepted by the PCR. SUBMITTED: accepted by the PCR, without Núclea''s answer yet. SUBMISSION_FAILED: accepted by the PCR, which then reported it could not submit it; not final, a late registration still takes it to REGISTERED. REGISTERED: registered at Núclea. FAILED: will not be registered; failureReason says why. WITHDRAWN: withdrawn before it was sent; it never reached the PCR.'
          enum:
            - AWAITING_BENEFICIARY
            - PENDING_SUBMISSION
            - SUBMITTED
            - SUBMISSION_FAILED
            - REGISTERED
            - FAILED
            - WITHDRAWN
          examples:
            - REGISTERED
          type: string
        registrationVersion:
          description: Current version of the boleto at the PCR (numRefAtlCadTit), sent back on its changes and write-offs; it does not order the notices. Null before the registration.
          examples:
            - '7'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        releasePolicy:
          description: 'When the credit of the title''s write-offs is released, copied from the agreement at issue: a later change of the agreement does not change it.'
          enum:
            - AFTER_CANCELLATION_WINDOW
            - AT_SETTLEMENT
          examples:
            - AFTER_CANCELLATION_WINDOW
          readOnly: true
          type: string
        speciesCode:
          description: Species of the title, its agreement's, answered at two digits.
          examples:
            - '02'
          pattern: ^[0-9]{1,2}$
          type: string
        submittedAt:
          description: When the PCR accepted the registration, RFC 3339 in UTC; null before, and on a title that never reached the PCR.
          examples:
            - '2026-11-03T14:05:00Z'
          format: date-time
          type:
            - string
            - 'null'
        updatedAt:
          description: When the title last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-03T14:05:00Z'
          format: date-time
          type: string
      required:
        - id
        - boletoId
        - connectionId
        - agreementId
        - accountId
        - organizationId
        - ourNumber
        - amount
        - dueDate
        - creditDelayBusinessDays
        - releasePolicy
        - registrationState
        - baseSituation
        - creditState
        - blockState
        - held
        - createdAt
        - updatedAt
      type: object
    TitleList:
      additionalProperties: false
      properties:
        items:
          description: The page's titles, oldest first.
          items:
            $ref: '#/components/schemas/Title'
          type: array
        limit:
          description: Most titles the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    UpdateAgreementRequest:
      additionalProperties: false
      properties:
        chargebackRiskAcknowledged:
          description: 'The client acknowledges that, under AT_SETTLEMENT, a cancellation confirmed after the release is charged back from the account''s default balance, which may no longer hold the amount. Required true with AT_SETTLEMENT: a change to AT_SETTLEMENT without it, or one that sends false while the agreement keeps AT_SETTLEMENT, is refused with 422 PBP-0006. Recorded false under AFTER_CANCELLATION_WINDOW. Left out, the agreement keeps its acknowledgement.'
          examples:
            - true
          type: boolean
        creditDelayBusinessDays:
          description: Business days before the agreement's credit is released, counted from the write-off's movement day. Applies to the boletos issued after the change.
          examples:
            - 2
          format: int64
          maximum: 30
          minimum: 0
          type: integer
        numbering:
          $ref: '#/components/schemas/NumberingRule'
          description: New nosso número range of the agreement. It must hold the counter's next value.
        paymentDeadlineDays:
          description: Calendar days after the due date up to the default payment deadline of the boletos issued after the change.
          examples:
            - 45
          format: int64
          maximum: 365
          minimum: 1
          type: integer
        portfolio:
          description: 'Portfolio of the agreement: 01 Simples, 02 Vinculada, 03 Caucionada, 04 Descontada, 05 Vendor, 06 Cessão. Only 01 is issued; 02 to 06 are refused with 422 PBP-0801.'
          enum:
            - '01'
            - '02'
            - '03'
            - '04'
            - '05'
            - '06'
          examples:
            - '01'
          type: string
        reason:
          description: Reason for the change, recorded in the audit trail. Must not carry personal data.
          examples:
            - Payment deadline extended at the client's request.
          maxLength: 500
          minLength: 10
          type: string
        releasePolicy:
          description: 'When the credit of a paid boleto of the agreement is released. AFTER_CANCELLATION_WINDOW waits until the write-off''s cancellation deadline, and any margin the platform adds to it, has passed. AT_SETTLEMENT releases it once the payment is settled and the credit date is reached, without waiting for the deadline: a cancellation confirmed after the release is then charged back from the account''s default balance. A change to AT_SETTLEMENT sends chargebackRiskAcknowledged true in the same request. Applies to the boletos issued after the change. Left out, the agreement keeps its policy.'
          enum:
            - AFTER_CANCELLATION_WINDOW
            - AT_SETTLEMENT
          examples:
            - AT_SETTLEMENT
          type: string
        speciesCode:
          description: Species of the boleto, one or two digits, 1 to 30 or 99; 31, 32 and 33 are refused with 422 PBP-0801.
          examples:
            - '02'
          pattern: ^[0-9]{1,2}$
          type: string
        version:
          description: Version last read.
          examples:
            - 3
          format: int64
          minimum: 1
          type: integer
      required:
        - version
        - reason
      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
    WebhookCapabilities:
      additionalProperties: false
      properties:
        inbound:
          description: Whether the provider posts notices to this service.
          type: boolean
        resubscribe:
          description: Whether POST /v1/admin/providers/webhooks/{provider_type}/resubscribe is accepted for it; otherwise 422 PBP-0701.
          type: boolean
      required:
        - inbound
        - resubscribe
      type: object
    WebhookConfigResponse:
      additionalProperties: false
      properties:
        active:
          type: boolean
        callbackUrl:
          type: string
        createdAt:
          type: string
        enabledEvents:
          description: 'Event types the configuration receives, any of: BOLETO_CREATED, BOLETO_SETTLED, BOLETO_REVERSED, BOLETO_CANCELED, BOLETO_CANCEL_FAILED, BOLETO_INACTIVATED, BOLETO_FAILED, BOLETO_EXCESS_PAYMENT, BOLETO_BATCH_FINISHED, PAYMENT_SETTLED, PAYMENT_REJECTED, PAYMENT_FAILED, PAYMENT_CANCELED, PAYMENT_SCHEDULED, PIX_KEY_CHANGED (the notice that the tenant''s Pix key changed), BOLETO_AMENDED, BOLETO_AMENDMENT_REJECTED (the notices that an amendment request of a boleto was applied or refused), BOLETO_OVERDUE, BOLETO_PAYMENT_BLOCKED, BOLETO_PAYMENT_UNBLOCKED (the notices that a boleto became overdue and that its payment was blocked or unblocked). A type outside this list is refused.'
          items:
            type: string
          type:
            - array
            - 'null'
        id:
          type: string
        secret:
          description: 'Always the literal "[REDACTED]": the signing secret is never returned by this API.'
          examples:
            - '[REDACTED]'
          type: string
        updatedAt:
          type: string
      required:
        - id
        - callbackUrl
        - secret
        - enabledEvents
        - active
        - createdAt
        - updatedAt
      type: object
    WebhookEventType:
      description: |-
        The notice types a configuration can enable in enabledEvents, in the order Payments lists them. Treat the list as open: a type added later never reaches a configuration that did not enable it.

        PLANNED: BOLETO_PAID, BOLETO_SETTLEMENT_REVERSED, BOLETO_SETTLEMENT_CHARGED_BACK, BOLETO_REOPENED_FROM_PAID, BOLETO_REOPENED_FROM_CANCELED, BOLETO_REOPENED_TITLE_CANCELED, BOLETO_REOPENED_TITLE_LAPSED, BOLETO_REOPENED_PAID_AGAIN, PAYMENT_UNDER_REVIEW, PAYMENT_RETURNED, CNAB_RETURN_AVAILABLE, ELECTRONIC_PAYER_REGISTERED, ELECTRONIC_PAYER_REJECTED, ELECTRONIC_PAYER_UPDATED, ELECTRONIC_PAYER_UPDATE_REJECTED, ELECTRONIC_PAYER_EXCLUDED, ELECTRONIC_PAYER_THIRD_PARTY_CHANGED, ELECTRONIC_PAYER_THIRD_PARTY_REJECTED, ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED, RECEIVER_BOLETO_NOTICED, RECEIVER_BOLETO_UPDATED, RECEIVER_BOLETO_WRITTEN_OFF, RECEIVER_BOLETO_PARTIALLY_PAID, RECEIVER_BOLETO_WRITEOFF_REVERSED, RECEIVER_BOLETO_LAPSED, RECEIVER_BOLETO_ACCEPTANCE_CHANGED, RECEIVER_BOLETO_ACCEPTANCE_REJECTED, RECEIVER_BOLETO_THIRD_PARTY_NOTICED are not in the catalogue in force; until they are delivered, enabledEvents refuses them with 400 PBP-0402.
      enum:
        - BOLETO_CREATED
        - BOLETO_SETTLED
        - BOLETO_REVERSED
        - BOLETO_CANCELED
        - BOLETO_CANCEL_FAILED
        - BOLETO_INACTIVATED
        - BOLETO_FAILED
        - BOLETO_EXCESS_PAYMENT
        - BOLETO_BATCH_FINISHED
        - PAYMENT_SETTLED
        - PAYMENT_REJECTED
        - PAYMENT_FAILED
        - PAYMENT_CANCELED
        - PAYMENT_SCHEDULED
        - PIX_KEY_CHANGED
        - BOLETO_AMENDED
        - BOLETO_AMENDMENT_REJECTED
        - BOLETO_OVERDUE
        - BOLETO_PAYMENT_BLOCKED
        - BOLETO_PAYMENT_UNBLOCKED
        - BOLETO_PAID
        - BOLETO_SETTLEMENT_REVERSED
        - BOLETO_SETTLEMENT_CHARGED_BACK
        - BOLETO_REOPENED_FROM_PAID
        - BOLETO_REOPENED_FROM_CANCELED
        - BOLETO_REOPENED_TITLE_CANCELED
        - BOLETO_REOPENED_TITLE_LAPSED
        - BOLETO_REOPENED_PAID_AGAIN
        - PAYMENT_UNDER_REVIEW
        - PAYMENT_RETURNED
        - CNAB_RETURN_AVAILABLE
        - ELECTRONIC_PAYER_REGISTERED
        - ELECTRONIC_PAYER_REJECTED
        - ELECTRONIC_PAYER_UPDATED
        - ELECTRONIC_PAYER_UPDATE_REJECTED
        - ELECTRONIC_PAYER_EXCLUDED
        - ELECTRONIC_PAYER_THIRD_PARTY_CHANGED
        - ELECTRONIC_PAYER_THIRD_PARTY_REJECTED
        - ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED
        - RECEIVER_BOLETO_NOTICED
        - RECEIVER_BOLETO_UPDATED
        - RECEIVER_BOLETO_WRITTEN_OFF
        - RECEIVER_BOLETO_PARTIALLY_PAID
        - RECEIVER_BOLETO_WRITEOFF_REVERSED
        - RECEIVER_BOLETO_LAPSED
        - RECEIVER_BOLETO_ACCEPTANCE_CHANGED
        - RECEIVER_BOLETO_ACCEPTANCE_REJECTED
        - RECEIVER_BOLETO_THIRD_PARTY_NOTICED
      type: string
    CreateCnabAgreementRequest:
      additionalProperties: false
      properties:
        collectionsAgreementId:
          description: The Lerian-provider collections agreement this CNAB agreement files for.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
          format: uuid
          type: string
        ledgerId:
          description: Midaz ledger the titles' entries go to; must be the collections agreement's ledger (else 422 PBP-0910 ACCOUNT_MISMATCH).
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a10
          format: uuid
          type: string
        midazAccountId:
          description: Midaz account of the titles; must be the collections agreement's account (else 422 PBP-0910 ACCOUNT_MISMATCH).
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        returnCutTimes:
          description: Return cut times, 1 to 24, Brasília time. Left out, ["07:00"]. A repeated time is refused with 422 PBP-0910 CUT_TIMES_INVALID.
          items:
            description: Cut time HH:MM, Brasília time (America/Sao_Paulo).
            examples:
              - 07:00
            pattern: ^([01][0-9]|2[0-3]):[0-5][0-9]$
            type: string
          maxItems: 24
          minItems: 1
          type: array
      required:
        - collectionsAgreementId
        - midazAccountId
        - ledgerId
      type: object
    CnabAgreement:
      additionalProperties: false
      properties:
        agreementCode:
          description: The collections agreement's 7-digit code, sent in the file header (G007, left-aligned).
          examples:
            - '1234567'
          pattern: ^[0-9]{7}$
          type: string
        bankCode:
          description: G001. The bankCode of the tenant's PCR connection, the first 3 positions of its barcodes. A file whose header carries another bank code is refused whole.
          examples:
            - '699'
          pattern: ^[0-9]{3}$
          type: string
        collectionsAgreementId:
          description: The collections agreement the CNAB agreement files for.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a71
          format: uuid
          type: string
        createdAt:
          description: When the agreement was created, RFC 3339 in UTC.
          examples:
            - '2026-11-15T13:20:00Z'
          format: date-time
          type: string
        id:
          description: Identifier of the CNAB agreement.
          examples:
            - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b61
          format: uuid
          type: string
        lastRemittanceNsa:
          description: Highest remittance NSA accepted (G018); 0 before the first. The next is expected at lastRemittanceNsa + 1.
          examples:
            - 43
          format: int64
          maximum: 999999
          minimum: 0
          type: integer
        lastReturnNsa:
          description: NSA of the last return generated; 0 before the first. Returns never skip a number.
          examples:
            - 42
          format: int64
          maximum: 999999
          minimum: 0
          type: integer
        ledgerId:
          description: Midaz ledger of the titles.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a10
          format: uuid
          type: string
        midazAccountId:
          description: Midaz account of the titles.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        nextCutAt:
          description: Next scheduled cut, RFC 3339 in UTC.
          examples:
            - '2026-11-17T10:00:00Z'
          format: date-time
          type: string
        organizationId:
          description: Midaz organization of the agreement.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a01
          format: uuid
          type: string
        portfolio:
          description: Portfolio (C006, 14.3P), read from the collections agreement on every read and never stored. Always "1" (simple collection) in V1.
          enum:
            - '1'
          examples:
            - '1'
          type: string
        releasePolicy:
          description: Credit release policy of the collections agreement, read from it on every read and never stored. AFTER_CANCELLATION_WINDOW releases the credit only after the window in which the payer's bank may cancel the write-off has closed; AT_SETTLEMENT releases it on settlement, and a chargeback after the release comes back as movement 90.
          enum:
            - AFTER_CANCELLATION_WINDOW
            - AT_SETTLEMENT
          examples:
            - AFTER_CANCELLATION_WINDOW
          type: string
        returnCutTimes:
          description: Return cut times, Brasília time, in ascending order.
          items:
            description: Cut time HH:MM, Brasília time (America/Sao_Paulo).
            examples:
              - 07:00
            pattern: ^([01][0-9]|2[0-3]):[0-5][0-9]$
            type: string
          maxItems: 24
          minItems: 1
          type: array
        speciesCode:
          description: Title species (G065, 24.3P), read from the collections agreement on every read and never stored.
          examples:
            - '02'
          pattern: ^[0-9]{2}$
          type: string
        status:
          description: ACTIVE takes remittances; INACTIVE refuses them and keeps generating returns of the titles already in.
          enum:
            - ACTIVE
            - INACTIVE
          examples:
            - ACTIVE
          type: string
        updatedAt:
          description: When the agreement last changed, RFC 3339 in UTC.
          examples:
            - '2026-11-16T09:00:00Z'
          format: date-time
          type: string
        version:
          description: Optimistic version; send it on updateCnabAgreement.
          examples:
            - 3
          format: int64
          minimum: 1
          type: integer
      required:
        - id
        - collectionsAgreementId
        - agreementCode
        - bankCode
        - organizationId
        - ledgerId
        - midazAccountId
        - portfolio
        - speciesCode
        - releasePolicy
        - returnCutTimes
        - status
        - lastRemittanceNsa
        - lastReturnNsa
        - nextCutAt
        - version
        - createdAt
        - updatedAt
      type: object
    CnabNotEnabledProblem:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - type: object
          required:
            - code
            - detail
            - layout
          properties:
            code:
              type: string
              const: PBP-0900
            detail:
              description: Names the layout that is off, e.g. "CNAB 240 is not enabled for this tenant".
              type: string
            layout:
              $ref: '#/components/schemas/CnabLayout'
      description: 'PBP-0900 (CNAB Not Enabled): the plugin''s problem document (Detail) with the extension member layout, always present, naming the layout that is off for the tenant. The code is generic across layouts; a future CNAB 400 adds a value to CnabLayout, not a new code (16/11-6).'
    CnabLayout:
      description: CNAB layout a PBP-0900 refers to. CNAB_240 is the only value today; a future CNAB 400 adds a value, so a client must not break on an unknown one.
      type: string
      enum:
        - CNAB_240
      examples:
        - CNAB_240
    CnabAgreementList:
      additionalProperties: false
      properties:
        items:
          description: The page's agreements, newest first.
          items:
            $ref: '#/components/schemas/CnabAgreement'
          type: array
        limit:
          description: Most agreements the page holds.
          examples:
            - 50
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    UpdateCnabAgreementRequest:
      additionalProperties: false
      properties:
        returnCutTimes:
          description: New cut times, replacing the current list; 1 to 24, Brasília time.
          items:
            description: Cut time HH:MM, Brasília time (America/Sao_Paulo).
            examples:
              - 07:00
            pattern: ^([01][0-9]|2[0-3]):[0-5][0-9]$
            type: string
          maxItems: 24
          minItems: 1
          type: array
        status:
          description: ACTIVE takes remittances; INACTIVE refuses them and keeps generating returns of the titles already in.
          enum:
            - ACTIVE
            - INACTIVE
          type: string
        version:
          description: The version last read; any other is refused with 409 PBP-0912.
          examples:
            - 3
          format: int64
          minimum: 1
          type: integer
      required:
        - version
      type: object
    CnabRemittanceReceipt:
      additionalProperties: false
      properties:
        agreementId:
          description: The CNAB agreement the file header names.
          examples:
            - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b61
          format: uuid
          type: string
        alerts:
          description: 'NSA_GAP: the NSA skips numbers. NSA_OUT_OF_ORDER: the NSA is below the last accepted. The file is processed in both cases.'
          items:
            enum:
              - NSA_GAP
              - NSA_OUT_OF_ORDER
            type: string
          type: array
        completedAt:
          description: When every line ended, RFC 3339 in UTC; null before.
          format: date-time
          type:
            - string
            - 'null'
        contentSha256:
          description: SHA-256 of the normalized file (accents removed, CRLF), lowercase hex. Part of the remittance identity with the agreement and the NSA.
          pattern: ^[0-9a-f]{64}$
          type: string
        counts:
          $ref: '#/components/schemas/CnabLineCounts'
        expectedNsa:
          description: 'The NSA expected (last accepted + 1) when this one differs from it; null otherwise and on a DRY_RUN. 1000000 means the 6-digit range of G018 is exhausted: no NSA above the last one is accepted, and a lower NSA still free is accepted with NSA_OUT_OF_ORDER.'
          format: int64
          maximum: 1000000
          minimum: 1
          type:
            - integer
            - 'null'
        fileGeneratedAt:
          description: Generation date and time of the file header (G016, G017), read as Brasília time and answered in UTC; null when the header has no time.
          format: date-time
          type:
            - string
            - 'null'
        fileGenerationDate:
          description: Generation date of the file header (G016), always present.
          examples:
            - '2026-11-16'
          format: date
          type: string
        id:
          description: Identifier of the remittance; null only on a DRY_RUN.
          format: uuid
          type:
            - string
            - 'null'
        lines:
          description: Only on a DRY_RUN, every title line with its outcome (id, boletoId and executedAt null). Absent otherwise.
          items:
            $ref: '#/components/schemas/CnabRemittanceLine'
          type: array
        notices:
          description: 'Fields taken as information only. MESSAGES_NOT_SENT: messages of the batch header, R and S are not sent to the boleto. ACCEPT_FLAG_INFORMATIONAL: the accept flag (25.3P) is kept but not sent. PROTEST_DAYS_IGNORED: protest days (37.3P) ignored with protest code 3 or 7.'
          items:
            enum:
              - MESSAGES_NOT_SENT
              - ACCEPT_FLAG_INFORMATIONAL
              - PROTEST_DAYS_IGNORED
            type: string
          type: array
        nsa:
          description: NSA of the file header (G018).
          examples:
            - 43
          format: int64
          maximum: 999999
          minimum: 1
          type: integer
        receivedAt:
          description: When the file was received, RFC 3339 in UTC.
          format: date-time
          type: string
        recordCount:
          description: Records in the file, headers and trailers included.
          format: int64
          type: integer
        requestedBy:
          description: Subject of the token that sent the file.
          maxLength: 255
          type: string
        sizeBytes:
          description: Size of the file as sent.
          format: int64
          maximum: 4194304
          minimum: 0
          type: integer
        status:
          description: 'VALIDATED: stored, no line started yet. PROCESSING: lines being executed. COMPLETED: every line EXECUTED or REJECTED (also at once, when every line was rejected at validation). DRY_RUN: the answer of a dry run, never stored. Treat the list as open.'
          enum:
            - VALIDATED
            - PROCESSING
            - COMPLETED
            - DRY_RUN
          type: string
        titleCount:
          description: Titles (P segments with their companions) in the file; one line each.
          format: int64
          type: integer
      required:
        - id
        - agreementId
        - nsa
        - status
        - fileGenerationDate
        - receivedAt
        - contentSha256
        - sizeBytes
        - recordCount
        - titleCount
        - counts
        - alerts
        - notices
        - requestedBy
      type: object
    CnabLineCounts:
      additionalProperties: false
      properties:
        executed:
          description: Lines whose request was accepted.
          format: int64
          type: integer
        inFlight:
          description: Lines being executed.
          format: int64
          type: integer
        ready:
          description: Lines to be executed.
          format: int64
          type: integer
        rejected:
          description: Lines refused, with their reasons.
          format: int64
          type: integer
        waiting:
          description: Lines behind an earlier line of the same title, or behind the registration of the title.
          format: int64
          type: integer
      required:
        - waiting
        - ready
        - inFlight
        - executed
        - rejected
      type: object
    CnabRemittanceLine:
      additionalProperties: false
      properties:
        boletoId:
          description: The boleto the entry issued, or the one a write-off or amendment resolved; null before execution and for a rejected entry.
          format: uuid
          type:
            - string
            - 'null'
        companyTitleId:
          description: Title id in the company (G072, 35.3P), kept only in CNAB and answered back in 21.3T.
          examples:
            - ERP-2026-000123
          maxLength: 25
          type:
            - string
            - 'null'
        documentNumber:
          description: Document number (C011, 19.3P).
          examples:
            - NF-000123
          maxLength: 15
          type:
            - string
            - 'null'
        dueDate:
          description: Due date of the title.
          examples:
            - '2026-12-10'
          format: date
          type:
            - string
            - 'null'
        executedAt:
          description: When the line executed, RFC 3339 in UTC.
          format: date-time
          type:
            - string
            - 'null'
        id:
          description: Identifier of the line; null only on a DRY_RUN.
          format: uuid
          type:
            - string
            - 'null'
        instructionKind:
          description: ISSUE (01), WRITE_OFF (02), AMEND (amendment movements, rejected for now) or REJECT (any other movement).
          enum:
            - ISSUE
            - WRITE_OFF
            - AMEND
            - REJECT
          type: string
        lotNumber:
          description: Batch number (G002) of the P segment.
          examples:
            - 1
          format: int64
          type: integer
        movementCode:
          description: Remittance movement code (C004, 07.3P), two digits.
          examples:
            - '01'
          pattern: ^[0-9]{2}$
          type: string
        nominalAmount:
          description: Amount in BRL as a decimal string with two decimal places.
          examples:
            - '1530.75'
          maxLength: 16
          pattern: ^(0|[1-9][0-9]{0,12})\.[0-9]{2}$
          type:
            - string
            - 'null'
        ourNumber:
          description: Nosso número (G069), as in the file, or, once the entry executed, the title's number; zeros while it is not known yet.
          examples:
            - '0000000000004517'
          maxLength: 20
          type:
            - string
            - 'null'
        platformCode:
          description: Code of the refusal by the host or the provider behind a rejection; null otherwise.
          examples:
            - PBP-0832
          maxLength: 64
          type:
            - string
            - 'null'
        recordSequence:
          description: Record sequence in the batch (G038) of the P segment.
          examples:
            - 1
          format: int64
          type: integer
        rejectionReasons:
          description: Up to 5 reason codes of the FEBRABAN note C047 table A, in the order found; empty unless REJECTED.
          items:
            type: string
          maxItems: 5
          type: array
        status:
          description: 'WAITING: behind an earlier line of the same title, or behind the registration of the title. READY: to be executed. IN_FLIGHT: being executed. EXECUTED: the request was accepted; the outcome at the base comes in the return. REJECTED: refused with rejectionReasons. Treat the list as open.'
          enum:
            - WAITING
            - READY
            - IN_FLIGHT
            - EXECUTED
            - REJECTED
          type: string
      required:
        - lotNumber
        - recordSequence
        - movementCode
        - instructionKind
        - status
        - rejectionReasons
      type: object
    DateOrInstantFilter:
      type: string
      pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2}))?$
      x-patternDescription: a YYYY-MM-DD date or an RFC 3339 date-time with offset
      examples:
        - '2026-11-01'
    CnabRemittanceList:
      additionalProperties: false
      properties:
        items:
          description: The page's receipts, newest first.
          items:
            $ref: '#/components/schemas/CnabRemittanceReceipt'
          type: array
        limit:
          description: Most receipts the page holds.
          examples:
            - 50
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    CnabRemittanceLineList:
      additionalProperties: false
      properties:
        items:
          description: The page's lines, in file order.
          items:
            $ref: '#/components/schemas/CnabRemittanceLine'
          type: array
        limit:
          description: Most lines the page holds.
          examples:
            - 50
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    CutCnabReturnRequest:
      additionalProperties: false
      properties:
        agreementId:
          description: The CNAB agreement to cut.
          examples:
            - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b61
          format: uuid
          type: string
      required:
        - agreementId
      type: object
    CnabReturn:
      additionalProperties: false
      properties:
        agreementId:
          description: The CNAB agreement the return belongs to.
          examples:
            - 019a7c1e-4b2d-7f30-9c11-2a5e8d0f4b61
          format: uuid
          type: string
        contentSha256:
          description: SHA-256 of the file as generated, lowercase hex; a rebuilt file is checked against it.
          pattern: ^[0-9a-f]{64}$
          type: string
        filePurged:
          description: true when the stored file was purged after the retention period; the download then rebuilds it from the journal.
          type: boolean
        generatedAt:
          description: When the return was generated, RFC 3339 in UTC.
          format: date-time
          type: string
        id:
          description: Identifier of the return.
          format: uuid
          type: string
        moreReturnsInCut:
          description: 'Only in the 201 of cutCnabReturn: true when movements were left after this file (more than 49,999 to report); the scheduled cut generates the following files in its next cycles, one per transaction, each with its own consecutive NSA and notice; list them with listCnabReturns. Absent in the other operations.'
          type: boolean
        movementCount:
          description: Movements in the file (one T/U pair each); 1 to 49,999, one batch per file (G038).
          format: int64
          maximum: 49999
          minimum: 1
          type: integer
        nsa:
          description: Return NSA of the agreement (G018 of the return header); consecutive, no gaps.
          examples:
            - 42
          format: int64
          maximum: 999999
          minimum: 1
          type: integer
        requestedBy:
          description: Subject of the JWT that asked for an ON_DEMAND cut; null for SCHEDULED.
          maxLength: 255
          type:
            - string
            - 'null'
        sizeBytes:
          description: Size of the file as generated.
          format: int64
          type: integer
        trigger:
          description: 'SCHEDULED: cut at one of the agreement''s cut times. ON_DEMAND: cut by POST /v1/cnab/returns.'
          enum:
            - SCHEDULED
            - ON_DEMAND
          type: string
      required:
        - id
        - agreementId
        - nsa
        - trigger
        - movementCount
        - generatedAt
        - contentSha256
        - sizeBytes
        - filePurged
        - requestedBy
      type: object
    CnabReturnList:
      type: object
      additionalProperties: false
      required:
        - items
        - limit
      properties:
        items:
          description: The page's returns, newest first.
          type: array
          items:
            $ref: '#/components/schemas/CnabReturn'
        limit:
          type: integer
          format: int64
        nextCursor:
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          maxLength: 512
          type:
            - string
            - 'null'
    AntifraudResolveRequest:
      type: object
      required:
        - analysisId
        - decision
      description: 'The partner''s final decision on an analysis, as defined by the Lerian antifraud resolve contract (v1). Body capped at 16 KiB. Only `analysisId`, `decision` and the body size can refuse the request (422 PBP-0219); `reasons` never does: a bad entry is dropped, and the reasons after the first 50 kept are discarded with a warning in the log (P-23).'
      properties:
        analysisId:
          type: string
          pattern: ^[\x21-\x7E]{1,64}$
          description: 'The analysisId the partner returned with REVIEW: 1 to 64 printable ASCII characters, no space.'
        decision:
          type: string
          enum:
            - ALLOW
            - DENY
          description: Final decision. REVIEW is never final.
        reasons:
          type: array
          description: Optional. The service records the first 50 entries the library keeps and discards the rest, with a warning in the log; no count or entry refuses the request.
          items:
            $ref: '#/components/schemas/AntifraudReason'
    AntifraudReason:
      type: object
      description: One reason the partner gave; never a cause to refuse the request. An entry whose code is absent, empty, not a string or holds a control character is dropped; a description that is not a string or holds NUL is blanked (a newline is kept); other members are ignored. Code and description are kept as sent, with no length cut, inside the 16 KiB body.
      properties:
        code:
          type: string
        description:
          type: string
    ProblemWithI13Extensions:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - properties:
            capability:
              $ref: '#/components/schemas/PaymentCapabilityName'
            currentStatus:
              description: 'PBP-0214: the payment''s status when the final decision was refused.'
              type: string
              examples:
                - REJECTED
            maxAmount:
              type: string
              pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
              maxLength: 19
              description: 'PBP-0216: the provider''s per-payment ceiling, exclusive.'
              examples:
                - '250000.00'
            receiptUnavailableReason:
              description: 'PBP-0218: why the payment has no receipt.'
              enum:
                - PAYMENT_NOT_SETTLED
                - PAYMENT_REJECTED
                - PAYMENT_FAILED
                - PAYMENT_CANCELED
                - PROVIDER_WITHOUT_RECEIPT
              type: string
          type: object
      description: The plugin's problem document (Detail, additionalProperties true) with the RFC 9457 extension members added for payments. Each member is present only with the code that names it; `capability` takes the provider capability values and the two payment values (PaymentCapabilityName).
    PaymentCapabilityName:
      description: 'Provider capability names of the payment operations (`capability` member of PBP-0701). The first four are the values the published contract already documents on POST /v1/payments: OPERATION_BANKSLIP_PAYMENT, OPERATION_BARCODE_BILL_PAYMENT, PAYMENT_SEGMENT_BANKSLIP and PAYMENT_SEGMENT_UTILITIES. Two are planned. PAYMENT_AMOUNT_INFORMED: the provider pays an amount the client informs. PAYMENT_RECEIPT: the provider delivers the receipt data at settlement; its absence is answered 409 PBP-0218, not PBP-0701, so it never appears in a PBP-0701 of this operation. The per-payment ceiling is a declared value, not a name. New values may appear; a client must handle an unknown one.'
      enum:
        - OPERATION_BANKSLIP_PAYMENT
        - OPERATION_BARCODE_BILL_PAYMENT
        - PAYMENT_SEGMENT_BANKSLIP
        - PAYMENT_SEGMENT_UTILITIES
        - PAYMENT_AMOUNT_INFORMED
        - PAYMENT_RECEIPT
      type: string
    RegisterElectronicPayerRequest:
      type: object
      required:
        - holderId
        - accounts
        - consent
      properties:
        holderId:
          type: string
          format: uuid
          description: Holder of the customer in the Midaz CRM. Every account in accounts must belong to this holder.
        accounts:
          type: array
          minItems: 1
          maxItems: 20
          items:
            $ref: '#/components/schemas/AccountRef'
        aggregates:
          type: array
          maxItems: 50
          description: Optional aggregates included with the adhesion. Requires capability ELECTRONIC_PAYER_AGGREGATES.
          items:
            $ref: '#/components/schemas/Document'
        consent:
          $ref: '#/components/schemas/Consent'
    AccountRef:
      type: object
      required:
        - midazAccountId
        - ledgerId
      properties:
        midazAccountId:
          type: string
          maxLength: 100
        ledgerId:
          type: string
          format: uuid
    Document:
      type: object
      required:
        - number
      properties:
        number:
          type: string
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          description: 'CPF (11 digits) or CNPJ (14 characters: 12 digits or uppercase letters, then 2 check digits, numeric or alphanumeric as issued by Receita Federal; MAPX-OP016-2009 v62, CNPJ_CPF). No punctuation. Accepted on this request only; never returned.'
    Consent:
      type: object
      description: Attestation of the customer's consent, collected by the institution. Sent on to whoever keeps it for the institution.
      required:
        - acceptedAt
        - channel
        - termVersion
        - consentedBy
      properties:
        acceptedAt:
          type: string
          format: date-time
          description: When the customer consented. Not in the future and not older than 24 hours (configurable).
        channel:
          $ref: '#/components/schemas/Channel'
        termVersion:
          type: string
          minLength: 1
          maxLength: 64
        consentedBy:
          type: string
          minLength: 1
          maxLength: 128
          description: Opaque reference of the customer at the institution. Never a CPF or CNPJ.
    Channel:
      type: string
      description: Neutral channel list (same list as payments).
      enum:
        - BRANCH
        - ATM
        - INTERNET
        - BANKING_AGENT
        - CALL_CENTER
        - ELECTRONIC_FILE
        - DDA
        - DIGITAL_BANKING_AGENT
    AcceptedRequest:
      type: object
      required:
        - requestId
        - kind
        - status
      properties:
        requestId:
          type: string
          format: uuid
        electronicPayerId:
          type: string
          format: uuid
          description: Absent only on an adhesion whose provider answer was not received; a retry with the same Idempotency-Key returns it, and GET /electronic-payers/requests/{requestId} reads the request meanwhile.
        aggregateId:
          type: string
          format: uuid
        thirdPartyId:
          type: string
          format: uuid
        kind:
          $ref: '#/components/schemas/RequestKind'
        status:
          type: string
          enum:
            - PENDING
    RequestKind:
      type: string
      enum:
        - REGISTRATION
        - ACCOUNTS_UPDATE
        - EXCLUSION
        - AGGREGATE_ADDITION
        - AGGREGATE_REMOVAL
        - ACCEPTANCE
        - THIRD_PARTY_ADDITION
        - THIRD_PARTY_REMOVAL
    Problem:
      type: object
      properties:
        type:
          type: string
        title:
          type: string
        status:
          type: integer
        detail:
          type: string
        code:
          type: string
          examples:
            - PBP-1000
        capability:
          type: string
          description: With PBP-0701, the capability the provider does not declare.
    ElectronicPayerPage:
      type: object
      required:
        - items
      properties:
        items:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ElectronicPayer'
              - $ref: '#/components/schemas/ElectronicPayerRemoval'
        nextCursor:
          type:
            - string
            - 'null'
        syncCursor:
          type:
            - string
            - 'null'
          description: Present on the last page.
    ElectronicPayer:
      type: object
      required:
        - electronicPayerId
        - personType
        - status
        - version
        - accounts
        - aggregates
      properties:
        electronicPayerId:
          type: string
          format: uuid
        personType:
          type: string
          enum:
            - INDIVIDUAL
            - COMPANY
        status:
          $ref: '#/components/schemas/PartyStatus'
        version:
          type: integer
          format: int64
          minimum: 1
          description: 'Grows on every change. Keep the last applied version per organization and payer: apply a notice only when its version is greater than the last one applied for the same organizationId and electronicPayerId, except notices that report a refused request or the end of the initial load: they carry the current version and are not discarded by version.'
        adheredAt:
          type:
            - string
            - 'null'
          format: date-time
        accounts:
          type: array
          description: Adhered accounts of this organization only.
          items:
            type: object
            required:
              - midazAccountId
              - ledgerId
              - status
            properties:
              midazAccountId:
                type: string
              ledgerId:
                type: string
                format: uuid
              status:
                $ref: '#/components/schemas/PartyStatus'
        aggregates:
          type: array
          items:
            type: object
            required:
              - aggregateId
              - personType
              - status
            properties:
              aggregateId:
                type: string
                format: uuid
              personType:
                type: string
                enum:
                  - INDIVIDUAL
                  - COMPANY
              status:
                $ref: '#/components/schemas/PartyStatus'
        lastRejection:
          $ref: '#/components/schemas/Rejection'
        updatedAt:
          type: string
          format: date-time
    PartyStatus:
      type: string
      enum:
        - PENDING
        - ACTIVE
        - REJECTED
        - EXCLUDED
    Rejection:
      type:
        - object
        - 'null'
      description: Why the request was refused after it was accepted. providerReason is the original code; category is stable.
      required:
        - title
        - providerReason
        - category
      properties:
        title:
          type: string
        detail:
          type: string
          description: Written by the service from category; never the provider's own text.
        providerReason:
          type: string
          maxLength: 32
          examples:
            - EDDA0005
        category:
          type: string
          enum:
            - ALREADY_ADHERED
            - INVALID_DOCUMENT
            - INVALID_ACCOUNT
            - INVALID_ADHESION_DATE
            - PAYER_NOT_ACTIVE
            - AGGREGATE_CONFLICT
            - THIRD_PARTY_NOT_ELIGIBLE
            - ACCEPTANCE_CONFLICT
            - STALE_REFERENCE
            - INSTITUTION_NOT_ENABLED
            - SCHEDULE_CLOSED
            - ACCOUNT_HOLDER_MISMATCH
            - ACCOUNT_TYPE_NOT_CONFIGURED
            - OTHER
    ElectronicPayerRemoval:
      type: object
      description: |
        Returned only with changedSince, while that cursor is valid: the payer no longer has adhered accounts in this
        organization. Carries no other data (R-4 do review, 19/11) besides the payer's version at the removal (N-6), which
        follows the same rule as the notices: apply the removal only when its version is greater than the last one applied
        for this payer in this organization; otherwise the payer came back afterwards and the removal is stale.
      required:
        - electronicPayerId
        - status
        - changePosition
        - version
      additionalProperties: false
      properties:
        electronicPayerId:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - REMOVED_FROM_ORGANIZATION
        changePosition:
          type: string
          maxLength: 64
          description: Position of the removal in the list. Opaque; use it only to order items.
        version:
          type: integer
          format: int64
          minimum: 1
          description: The payer's version at the removal. Apply the removal only when it is greater than the last version applied for this payer in this organization.
    UpdateElectronicPayerAccountsRequest:
      type: object
      minProperties: 1
      properties:
        accountsToAdd:
          type: array
          maxItems: 20
          items:
            $ref: '#/components/schemas/AccountRef'
        accountsToRemove:
          type: array
          maxItems: 20
          items:
            type: string
            maxLength: 100
            description: midazAccountId
    AddAggregateRequest:
      type: object
      required:
        - document
        - consent
      properties:
        document:
          $ref: '#/components/schemas/Document'
        consent:
          $ref: '#/components/schemas/Consent'
    ElectronicPayerRequest:
      type: object
      required:
        - requestId
        - kind
        - status
        - requestedAt
      properties:
        requestId:
          type: string
          format: uuid
        electronicPayerId:
          type: string
          format: uuid
          description: Absent only on an adhesion whose provider answer was not received yet (status PENDING).
        kind:
          $ref: '#/components/schemas/RequestKind'
        status:
          type: string
          enum:
            - PENDING
            - CONFIRMED
            - REJECTED
        requestedAt:
          type: string
          format: date-time
        settledAt:
          type:
            - string
            - 'null'
          format: date-time
        rejection:
          $ref: '#/components/schemas/Rejection'
    PresentedBoletoPage:
      type: object
      required:
        - items
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/PresentedBoletoSummary'
        nextCursor:
          type:
            - string
            - 'null'
        syncCursor:
          type:
            - string
            - 'null'
    PresentedBoletoSummary:
      type: object
      required:
        - receiverBoletoId
        - registryTitleId
        - audience
        - status
        - version
        - amount
        - dueDate
        - beneficiaryType
      properties:
        receiverBoletoId:
          type: string
          format: uuid
        registryTitleId:
          type: string
          maxLength: 19
          description: Identification number of the boleto in the centralized registry, for support and correlation.
        audience:
          type: string
          enum:
            - PAYER
            - AGGREGATE
            - THIRD_PARTY
        aggregateId:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - OPEN
            - PARTIALLY_PAID
            - WRITTEN_OFF
            - LAPSED
            - NO_LONGER_VISIBLE
        version:
          type: integer
          format: int64
        amount:
          type: string
          pattern: ^[0-9]+\.[0-9]{2}$
        dueDate:
          type: string
          format: date
        beneficiaryType:
          type: string
          enum:
            - INDIVIDUAL
            - COMPANY
        acceptance:
          type:
            - string
            - 'null'
          enum:
            - ACCEPTED
            - REFUSED
            -
    PresentedBoleto:
      allOf:
        - $ref: '#/components/schemas/PresentedBoletoSummary'
        - type: object
          description: |
            Full boleto as presented. Never carries the document of the payer, aggregate or third party, nor the
            bearer, payment channel, payment method or contingency flag of write-offs made by others.
          properties:
            digitableLine:
              type: string
            barcode:
              type: string
            beneficiary:
              $ref: '#/components/schemas/NamedParty'
            finalBeneficiary:
              $ref: '#/components/schemas/NamedParty'
            rightsHolder:
              $ref: '#/components/schemas/NamedParty'
            guarantor:
              $ref: '#/components/schemas/NamedParty'
            interest:
              type: object
            fine:
              type: object
            discounts:
              type: array
              items:
                type: object
            partialPayment:
              type: object
            linkedToDuplicate:
              type: boolean
            taxes:
              type: object
            thirdParties:
              type: array
              items:
                type: object
                required:
                  - thirdPartyId
                  - personType
                  - status
                  - byThisInstitution
                properties:
                  thirdPartyId:
                    type: string
                    format: uuid
                  personType:
                    type: string
                    enum:
                      - INDIVIDUAL
                      - COMPANY
                  status:
                    type: string
                    enum:
                      - PENDING
                      - ACTIVE
                      - REJECTED
                      - REMOVED
                  byThisInstitution:
                    type: boolean
                    description: False when another institution where the payer is adhered included this third party. Such entries carry no name or document (PL-DDA-03); the institution identifies the ones it included by its own records, and the customer may remove any entry they do not recognize.
    NamedParty:
      type: object
      description: Beneficiary, rights holder or guarantor, with name and document (PL-DDA-03).
      properties:
        personType:
          type: string
          enum:
            - INDIVIDUAL
            - COMPANY
        document:
          type: string
        name:
          type: string
        tradeName:
          type: string
    SetAcceptanceRequest:
      type: object
      required:
        - acceptance
        - channel
      properties:
        acceptance:
          type: string
          enum:
            - ACCEPTED
            - REFUSED
        channel:
          $ref: '#/components/schemas/Channel'
    AddThirdPartyRequest:
      type: object
      required:
        - authorizer
        - document
        - consent
      properties:
        authorizer:
          type: object
          required:
            - kind
          properties:
            kind:
              type: string
              enum:
                - PAYER
                - AGGREGATE
              description: AGGREGATE when the boleto is issued against one of the customer's aggregates.
            aggregateId:
              type: string
              format: uuid
              description: Required when kind is AGGREGATE.
        document:
          $ref: '#/components/schemas/Document'
        consent:
          $ref: '#/components/schemas/Consent'
    PaymentReceipt:
      additionalProperties: false
      description: Receipt of a slip payment received as Recebedora (MAPX-OP084-2019 V19 §6.20.3; Convenção FB-0061/2021 Art. 23 and Art. 26). Recorded once at the registration of the write-off; never rewritten.
      properties:
        paymentId:
          format: uuid
          type: string
          examples:
            - 123e4567-e89b-12d3-a456-426614174000
        label:
          const: Pagamento de boleto
          description: The fixed indication the manual requires.
          type: string
        receivingBank:
          $ref: '#/components/schemas/ReceiptInstitution'
        digitableLine:
          type: string
          examples:
            - 00190500954014481606906809350314337370000000100
        issuingInstitution:
          $ref: '#/components/schemas/ReceiptInstitution'
        beneficiary:
          $ref: '#/components/schemas/ReceiptBeneficiary'
        guarantor:
          $ref: '#/components/schemas/ReceiptGuarantor'
        payer:
          $ref: '#/components/schemas/ReceiptPayer'
        finalPayer:
          $ref: '#/components/schemas/ReceiptFinalPayer'
        dueDate:
          format: date
          type: string
          examples:
            - '2026-11-20'
        nominalAmount:
          type: string
          pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
          maxLength: 19
          description: Face value of the slip.
          examples:
            - '1000.00'
        chargesAmount:
          type: string
          pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
          maxLength: 19
          description: 'Charges: interest plus fine.'
          examples:
            - '0.00'
        discountsAmount:
          type: string
          pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
          maxLength: 19
          description: 'Discounts: discount plus rebate (abatimento).'
          examples:
            - '0.00'
        paidAmount:
          type: string
          pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
          maxLength: 19
          description: Amount paid.
          examples:
            - '100.00'
        paidAt:
          description: 'Date and time of the payment: when the write-off was registered at the clearing base.'
          examples:
            - '2026-11-16T14:05:40Z'
          format: date-time
          type: string
        writeOffNumber:
          description: Number of the write-off at the clearing base (NumIdentcBaixa).
          maxLength: 19
          pattern: ^[0-9]{1,19}$
          type: string
          examples:
            - '2026111600000012345'
        authentication:
          description: 'Authentication of the payment: the write-off number, a hyphen and 16 hexadecimal characters, computed once when the write-off is registered and stored. Unique and identical on every read; check it against this receipt, never by recomputing it.'
          maxLength: 36
          pattern: ^[0-9]{1,19}-[0-9a-f]{16}$
          type: string
          examples:
            - 2026111600000012345-9f2c4e1a7b3d5c60
        complete:
          description: False while the source does not deliver every mandatory field.
          type: boolean
        missingFields:
          description: Members the source did not deliver, in this schema's names (for example `payer.name`). Empty when complete.
          items:
            type: string
            maxLength: 64
          type: array
          uniqueItems: true
        returned:
          description: True when the payment was returned after the receipt was issued.
          type: boolean
        returnedAt:
          description: When the return was posted. Present only when `returned` is true.
          examples:
            - '2026-11-17T11:20:04Z'
          format: date-time
          type: string
        issuedAt:
          description: When the receipt was recorded.
          examples:
            - '2026-11-16T14:05:41Z'
          format: date-time
          type: string
      required:
        - paymentId
        - label
        - digitableLine
        - paidAmount
        - paidAt
        - writeOffNumber
        - authentication
        - complete
        - missingFields
        - returned
        - issuedAt
      type: object
    ReceiptInstitution:
      additionalProperties: false
      description: A financial institution named on the receipt. A member the source did not deliver is absent and listed in `missingFields`.
      properties:
        name:
          maxLength: 100
          type: string
          examples:
            - Banco Exemplo S.A.
        ispb:
          pattern: ^[0-9]{8}$
          type: string
          examples:
            - '12345678'
      required: []
      type: object
    ReceiptBeneficiary:
      additionalProperties: false
      description: Beneficiary of the slip (beneficiário).
      properties:
        tradeName:
          description: Trade name, when the beneficiary is a company.
          maxLength: 140
          type: string
        legalName:
          maxLength: 140
          type: string
        taxId:
          type: string
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          description: CPF (11 digits) or CNPJ (14 characters, alphanumeric CNPJ included), digits only, no punctuation.
      required: []
      type: object
    ReceiptGuarantor:
      additionalProperties: false
      description: Guarantor drawer of the slip (sacador avalista), when the slip has one.
      properties:
        legalName:
          maxLength: 140
          type: string
        taxId:
          type: string
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          description: CPF (11 digits) or CNPJ (14 characters, alphanumeric CNPJ included), digits only, no punctuation.
      required:
        - legalName
        - taxId
      type: object
    ReceiptPayer:
      additionalProperties: false
      description: Payer of the slip as registered (pagador).
      properties:
        name:
          maxLength: 140
          type: string
        taxId:
          type: string
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          description: CPF (11 digits) or CNPJ (14 characters, alphanumeric CNPJ included), digits only, no punctuation.
      required: []
      type: object
    ReceiptFinalPayer:
      additionalProperties: false
      description: 'Final payer (pagador final): the holder of the funding account who paid.'
      properties:
        taxId:
          type: string
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          description: CPF (11 digits) or CNPJ (14 characters, alphanumeric CNPJ included), digits only, no punctuation.
      required: []
      type: object
    WriteOffScheduledRelease:
      additionalProperties: false
      properties:
        auditActionId:
          description: Entry of the audit trail that records the scheduling.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a31
          format: uuid
          type: string
        scheduledAt:
          description: When the release was scheduled, RFC 3339 in UTC.
          examples:
            - '2026-11-11T13:00:00Z'
          format: date-time
          type: string
        scheduledBy:
          $ref: '#/components/schemas/Actor'
          description: Who scheduled the release.
        scheduledFor:
          description: Date the release is scheduled for.
          examples:
            - '2026-11-13'
          format: date
          type: string
      required:
        - scheduledFor
        - scheduledAt
        - scheduledBy
        - auditActionId
      type: object
    WriteOffList:
      additionalProperties: false
      properties:
        items:
          description: The page's write-offs, oldest first.
          items:
            $ref: '#/components/schemas/WriteOff'
          type: array
        limit:
          description: Most write-offs the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    WriteOff:
      additionalProperties: false
      properties:
        accountId:
          description: 'Midaz account of the title, the account that issues it: the write-off''s credit always goes to it, under a pooled account too.'
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        amount:
          description: 'Amount of the write-off in reais, as a decimal string with two decimal places: the one Núclea notified, or the title''s when the write-off carries none.'
          examples:
            - '1000.00'
          maxLength: 32
          pattern: ^[0-9]{1,15}(\.[0-9]{1,2})?$
          type: string
        cancellationDeadline:
          description: 'End of the period in which the write-off can be cancelled, RFC 3339 in UTC: the one the PCR gave or, when it gave none, 23:59:59 in Brasília of the first business day of the SILOC calendar after the settlement date of the route. Null only on route NONE.'
          examples:
            - '2026-11-12T02:59:59Z'
          format: date-time
          type:
            - string
            - 'null'
        cancelled:
          description: Whether the write-off was cancelled.
          examples:
            - false
          type: boolean
        creditReleaseDate:
          description: 'First day the credit can be released: the write-off''s movement day plus the title''s creditDelayBusinessDays business days of the SILOC calendar. The movement day is the civil date of writeOffAt in Brasília, or the next business day when it falls on a weekend or holiday. The release waits for this date and for the settlement and, under the title''s releasePolicy AFTER_CANCELLATION_WINDOW, for the end of the cancellation deadline. Null until the credit is owed, and always on route NONE.'
          examples:
            - '2026-11-12'
          format: date
          type:
            - string
            - 'null'
        creditState:
          description: 'Where the write-off''s credit is. NONE: no credit, because the write-off moves no money or was cancelled before its credit was owed. TO_RELEASE: credit waiting for its release. RELEASED: credit released to the account. REVERSED: credit reversed before its release, the write-off cancelled. CHARGEBACK_PENDING: a reversal after the release that the ledger refused, waiting to be processed again. CHARGED_BACK: credit reversed after its release.'
          enum:
            - NONE
            - TO_RELEASE
            - RELEASED
            - REVERSED
            - CHARGEBACK_PENDING
            - CHARGED_BACK
          examples:
            - TO_RELEASE
          type: string
        expectedCycleDate:
          description: Date of the SILOC cycle the write-off is expected to settle in; null when the PCR gave none.
          examples:
            - '2026-11-11'
          format: date
          type:
            - string
            - 'null'
        held:
          description: Whether the release of the write-off's credit is held; holdReason says why.
          examples:
            - false
          type: boolean
        holdReason:
          description: 'Why the release is held. STR_UNCONFIRMED: an STR write-off whose credit nobody confirmed yet. NOT_SETTLED_IN_CYCLE: a CMP write-off its cycle did not settle. SETTLEMENT_OVERDUE: a CMP write-off still without its settlement past its expected cycle and the tolerance. NEGOTIATED: a write-off of a boleto flagged as negotiated. Null when the release is not held.'
          oneOf:
            - enum:
                - STR_UNCONFIRMED
                - NOT_SETTLED_IN_CYCLE
                - SETTLEMENT_OVERDUE
                - NEGOTIATED
              type: string
            - type: 'null'
        id:
          description: Identifier of the write-off.
          examples:
            - 5b0c1e2d-3f4a-4b5c-8d6e-7f8091a2b3c4
          format: uuid
          type: string
        organizationId:
          description: Midaz organization of the title's account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type: string
        origin:
          description: 'Message the write-off reached the PCR by. DDA0108R2: a write-off notice by message. ADDA108RR2: a write-off notice by file. ADDA114RR2: a write-off notice of the receiving contingency file. ADDA120: the lapse of the title after its payment deadline, which carries neither an identifier nor an amount of Núclea. DESTINATARIA: a write-off by the Destinatária, which carries no amount.'
          enum:
            - DDA0108R2
            - ADDA108RR2
            - ADDA114RR2
            - ADDA120
            - DESTINATARIA
          examples:
            - DDA0108R2
          type: string
        pcrWriteOffId:
          description: Identifier Núclea gave the write-off (NumIdentcBaixa); null only on the lapse of the title (origin ADDA120), which carries none.
          examples:
            - '2026101400000098765'
          pattern: ^[0-9]{1,19}$
          type:
            - string
            - 'null'
        receivedAt:
          description: When collections received the notice of the write-off, RFC 3339 in UTC; not when the write-off happened (writeOffAt).
          examples:
            - '2026-11-10T16:43:05Z'
          format: date-time
          type: string
        route:
          description: 'Route the write-off settles by. CMP: a SILOC cycle. STR: the STR, outside the cycles. INTRABANK: inside the institution, on the write-off itself. PIX: Pix, outside the cycles. NONE: no money moves, so the write-off never makes a credit.'
          enum:
            - CMP
            - STR
            - INTRABANK
            - PIX
            - NONE
          examples:
            - STR
          type: string
        scheduledRelease:
          description: Manual release an operator scheduled for a date, cancellable until it; null when none is scheduled.
          oneOf:
            - $ref: '#/components/schemas/WriteOffScheduledRelease'
            - type: 'null'
        settledAt:
          description: When the money of the write-off settled on its route, RFC 3339 in UTC; null while it has not.
          examples:
            - '2026-11-11T08:20:00Z'
          format: date-time
          type:
            - string
            - 'null'
        settlementState:
          description: 'Where the money of the write-off is on its route. AWAITING_SETTLEMENT: not settled yet. SETTLED: settled, at settledAt. NOT_SETTLED: a CMP write-off its cycle did not settle. NO_MOVEMENT: route NONE, with nothing to settle.'
          enum:
            - AWAITING_SETTLEMENT
            - SETTLED
            - NOT_SETTLED
            - NO_MOVEMENT
          examples:
            - AWAITING_SETTLEMENT
          type: string
        titleId:
          description: Collections title the write-off is of.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type: string
        type:
          description: Type of the write-off at Núclea (TpBaixa), such as 0 for a full interbank write-off or 9 for a full write-off via STR; null on the lapse of the title.
          examples:
            - '9'
          pattern: ^[0-9]{1,2}$
          type:
            - string
            - 'null'
        writeOffAt:
          description: 'When the write-off happened at Núclea (DtHrSitBaixa), RFC 3339 in UTC: the base of the credit release date and of the cancellation deadline. Null only on route NONE, on the lapse of the title, which carries none.'
          examples:
            - '2026-11-10T16:42:00Z'
          format: date-time
          type:
            - string
            - 'null'
      required:
        - id
        - titleId
        - organizationId
        - pcrWriteOffId
        - origin
        - amount
        - route
        - writeOffAt
        - settlementState
        - creditState
        - held
        - cancelled
        - receivedAt
      type: object
    CreditEntryList:
      additionalProperties: false
      properties:
        items:
          description: The page's credit entries, oldest first.
          items:
            $ref: '#/components/schemas/CreditEntry'
          type: array
        limit:
          description: Most credit entries the page holds.
          examples:
            - 20
          format: int64
          type: integer
        nextCursor:
          description: Cursor of the page after this one; null on the last page.
          maxLength: 512
          type:
            - string
            - 'null'
        prevCursor:
          description: Cursor of the page before this one; null on the first page.
          maxLength: 512
          type:
            - string
            - 'null'
      required:
        - items
        - limit
      type: object
    CreditEntry:
      additionalProperties: false
      properties:
        accountId:
          description: Midaz account of the title, whose available balance the entry credits or debits.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6d
          format: uuid
          type: string
        amount:
          description: Amount the entry moves in reais, the write-off's, as a decimal string with two decimal places.
          examples:
            - '1000.00'
          maxLength: 32
          pattern: ^[0-9]{1,15}(\.[0-9]{1,2})?$
          type: string
        attempts:
          description: How many times the entry was presented to the ledger.
          examples:
            - 1
          format: int64
          minimum: 0
          type: integer
        counterpartyAlias:
          description: 'Alias of the ledger account on the other side of the entry: resolved once per write-off for its RELEASE, which takes the money from it, and kept for the CHARGEBACK, which returns the money to it. Present on every entry.'
          examples:
            - '@external/BRL'
          maxLength: 100
          type: string
        createdAt:
          description: When the entry was recorded, RFC 3339 in UTC.
          examples:
            - '2026-11-12T09:00:00Z'
          format: date-time
          type: string
        id:
          description: Identifier of the credit entry.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a41
          format: uuid
          type: string
        lastError:
          description: 'Why the entry is not posted, as a closed code and never the ledger''s own text. LEDGER_NO_RESPONSE: the ledger gave no outcome in time. HOST_REFUSED_UNPROVEN: no outcome came in time, and the entry carries unprovenRefusalReason: the host''s own checks refused one of its presentations before the ledger without making the refusal final, and the presentations after that refusal got no outcome either. Such a refusal does not prove an earlier presentation of the entry did not post, so only a look-up of the entry''s key in the ledger settles it. INSUFFICIENT_FUNDS: the balance the entry debits was short of its amount. ACCOUNT_BLOCKED: the account is blocked. ACCOUNT_NOT_ELIGIBLE: the account does not take the entry. COUNTERPARTY_UNAVAILABLE: the counterparty cannot be moved from or to. ROUTE_REFUSED: the entry''s transaction route refused it. KEY_CONFLICT: the entry''s key was already used with another body. Present while the entry waits for an operator, and kept on an entry abandoned after a refusal. Null otherwise: on a POSTED entry, while the entry waits for its presentation or its answer, and on an entry abandoned without a refusal.'
          oneOf:
            - enum:
                - LEDGER_NO_RESPONSE
                - HOST_REFUSED_UNPROVEN
                - INSUFFICIENT_FUNDS
                - ACCOUNT_BLOCKED
                - ACCOUNT_NOT_ELIGIBLE
                - COUNTERPARTY_UNAVAILABLE
                - ROUTE_REFUSED
                - KEY_CONFLICT
              type: string
            - type: 'null'
        ledgerKey:
          description: 'Idempotency key the entry is presented to the ledger with: one per write-off and phase, never presented with another body.'
          examples:
            - col:7c9e6679-7425-40de-944b-e07fc1f90ae7:5b0c1e2d-3f4a-4b5c-8d6e-7f8091a2b3c4:RELEASE
          maxLength: 128
          type: string
        ledgerTransactionId:
          description: Transaction the ledger posted the entry in; null in every state but POSTED.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a51
          format: uuid
          type:
            - string
            - 'null'
        organizationId:
          description: Midaz organization of the title's account.
          examples:
            - 0192a3b4-5c6d-7e8f-9a0b-1c2d3e4f5a6b
          format: uuid
          readOnly: true
          type: string
        phase:
          description: 'What the entry moves. RELEASE: the write-off''s amount, from the counterparty to the available balance of the title''s account, when the credit is released. CHARGEBACK: the same amount back, from that balance to the counterparty of the RELEASE, when the write-off is cancelled after its release.'
          enum:
            - RELEASE
            - CHARGEBACK
          examples:
            - RELEASE
          type: string
        postedAt:
          description: When the ledger posted the entry, RFC 3339 in UTC; null in every state but POSTED.
          examples:
            - '2026-11-12T09:00:02Z'
          format: date-time
          type:
            - string
            - 'null'
        state:
          description: 'Where the entry stands with the ledger. PENDING_CALL: not posted yet: waiting to be presented, presented without an answer yet, or waiting for an operator in the STUCK_CREDIT_ENTRY queue, with lastError saying why. POSTED: posted by the ledger, in ledgerTransactionId. ABANDONED: final, without any effect on the ledger.'
          enum:
            - PENDING_CALL
            - POSTED
            - ABANDONED
          examples:
            - PENDING_CALL
          type: string
        titleId:
          description: Collections title of the write-off.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
          format: uuid
          type: string
        unprovenRefusalReason:
          description: 'Reason of the last refusal the host''s own checks gave the entry before the ledger without making it final, as a closed code from the reasons of lastError: a refusal that does not prove an earlier presentation of the entry did not post, so the entry is presented again and, once its time runs out, waits for an operator with lastError HOST_REFUSED_UNPROVEN. A later refusal of that kind replaces it. A later presentation without an outcome keeps it, so the reason may answer an earlier presentation than the last one; it is kept while the entry waits for an operator. Null on an entry that got no such refusal, and once the entry is posted, refused for good, or presented again after the ledger showed no posting under its key.'
          oneOf:
            - enum:
                - INSUFFICIENT_FUNDS
                - ACCOUNT_BLOCKED
                - ACCOUNT_NOT_ELIGIBLE
                - COUNTERPARTY_UNAVAILABLE
                - ROUTE_REFUSED
                - KEY_CONFLICT
              type: string
            - type: 'null'
        writeOffId:
          description: Write-off whose credit the entry moves.
          examples:
            - 5b0c1e2d-3f4a-4b5c-8d6e-7f8091a2b3c4
          format: uuid
          type: string
      required:
        - id
        - writeOffId
        - titleId
        - organizationId
        - phase
        - amount
        - state
        - ledgerKey
        - counterpartyAlias
        - createdAt
      type: object
    Reason:
      type: string
      description: Reason for the action, required. Text of the operator; must not carry personal data.
      minLength: 10
      maxLength: 500
      examples:
        - STR credit checked on the reserves account statement of 11/10.
    EvidencedActionRequest:
      type: object
      description: Action with a mandatory reason and evidence (lift a hold, reverse, close manually).
      additionalProperties: false
      required:
        - reason
        - evidence
      properties:
        reason:
          $ref: '#/components/schemas/Reason'
        evidence:
          $ref: '#/components/schemas/Evidence'
    AssociateNoticeRequest:
      type: object
      additionalProperties: false
      required:
        - reason
        - titleId
      properties:
        reason:
          $ref: '#/components/schemas/Reason'
        titleId:
          type: string
          format: uuid
          description: Title the notice belongs to.
          examples:
            - 7c9e6679-7425-40de-944b-e07fc1f90ae7
    ReleaseWriteOffRequest:
      type: object
      additionalProperties: false
      required:
        - reason
        - settlementConfirmation
      properties:
        reason:
          $ref: '#/components/schemas/Reason'
        settlementConfirmation:
          $ref: '#/components/schemas/SettlementConfirmation'
    SettlementConfirmation:
      type: object
      description: The operator's attestation that the write-off settled on the route.
      additionalProperties: false
      required:
        - kind
        - settledAt
        - evidence
      properties:
        kind:
          type: string
          enum:
            - STR_CREDIT_CONFIRMED
            - CYCLE_SETTLEMENT_CONFIRMED
          description: '`STR_CREDIT_CONFIRMED`: the STR credit was checked. `CYCLE_SETTLEMENT_CONFIRMED`: the settlement of the cycle was confirmed after a "not settled".'
          examples:
            - STR_CREDIT_CONFIRMED
        settledAt:
          type: string
          format: date-time
          description: Moment of the checked settlement (UTC).
          examples:
            - '2026-11-10T14:05:00Z'
        evidence:
          $ref: '#/components/schemas/Evidence'
    PaymentAntifraudAnalysis:
      type: object
      additionalProperties: false
      description: Antifraud analysis of the payment. Present on every payment the client's antifraud partner evaluated (ALLOW or REVIEW), also after the final decision, as its audit record. Absent when the tenant has the check off and on payments created before the antifraud check existed. The partner's reasons and score are recorded but not exposed.
      required:
        - decision
        - origin
        - evaluatedAt
      properties:
        analysisId:
          type: string
          maxLength: 64
          description: Partner's identifier of the analysis, to quote to whoever operates it. Always present on REVIEW.
          examples:
            - an-7f3c2a91
        decision:
          type: string
          enum:
            - ALLOW
            - REVIEW
          description: Decision at initiation. DENY creates no payment.
        origin:
          type: string
          enum:
            - PROVIDER
            - FALLBACK
          description: 'PROVIDER: the partner answered. FALLBACK: the route''s open posture released it.'
        evaluatedAt:
          type: string
          format: date-time
          examples:
            - '2026-11-16T14:03:12Z'
        reviewExpiresAt:
          type: string
          format: date-time
          description: 'REVIEW only: end of the tenant''s review window, after which the payment ends REJECTED with ANTIFRAUD_REVIEW_EXPIRED.'
          examples:
            - '2026-11-16T14:33:12Z'
        finalDecision:
          type: string
          enum:
            - ALLOW
            - DENY
            - EXPIRED
          description: 'REVIEW only: final decision of the partner, or EXPIRED. Absent while open.'
        decidedAt:
          type: string
          format: date-time
          description: When the final decision or the expiry was recorded. Absent while open.
    PaymentReturn:
      additionalProperties: false
      description: 'Return of a settled payment after the issuing institution cancelled the write-off. While `state` is PENDING the payment is still SETTLED and the amount goes back at `scheduledFor`: 08:20 (America/Sao_Paulo), the first SILOC settlement of the business day after the notice. At that moment the amount is credited back to the funding account, the payment becomes RETURNED, `state` becomes POSTED and PAYMENT_RETURNED is sent. Only Lerian-provider payments carry it.'
      properties:
        state:
          description: 'PENDING: return notified, amount not yet back. POSTED: amount sent back to the funding account; the payment is RETURNED.'
          enum:
            - PENDING
            - POSTED
          type: string
        reason:
          description: Reason the issuing institution gave for cancelling the write-off.
          examples:
            - Cancelamento pela instituicao destinataria
          maxLength: 500
          type: string
        amount:
          type: string
          pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
          maxLength: 19
          description: 'Amount returned to the funding account: the settled amount.'
          examples:
            - '100.00'
        noticedAt:
          description: When the cancellation by the issuing institution was notified.
          examples:
            - '2026-11-16T18:40:00Z'
          format: date-time
          type: string
        scheduledFor:
          description: When the amount goes back to the funding account.
          examples:
            - '2026-11-17T11:20:00Z'
          format: date-time
          type: string
        returnedAt:
          description: When the return was posted. Absent while PENDING.
          examples:
            - '2026-11-17T11:20:04Z'
          format: date-time
          type: string
      required:
        - state
        - reason
        - amount
        - noticedAt
        - scheduledFor
      type: object
    BoletoSettlement:
      type: object
      additionalProperties: false
      required:
        - mode
        - state
        - cycle
      description: Settlement of a SETTLED boleto. A DIRECT boleto is RELEASED from the moment it is settled, with releasedAt equal to settledAt. A HELD boleto starts PENDING_RELEASE and moves as the collections module records each stage; a stage recorded out of order is ignored. A title reopened at the base and paid again starts a new cycle, and the object shows only the current one, numbered by cycle. Each date is present only once its stage happened in the current cycle, and is never null.
      properties:
        mode:
          $ref: '#/components/schemas/SettlementMode'
        state:
          $ref: '#/components/schemas/SettlementState'
        cycle:
          type: integer
          minimum: 1
          maximum: 32767
          description: 'Payment cycle the object describes: 1 at the first payment; increased by 1 each time a title reopened at the base is paid again and the new settlement opens a new cycle (R-04). Always 1 in DIRECT mode. BOLETO_SETTLED, BOLETO_SETTLEMENT_REVERSED and BOLETO_SETTLEMENT_CHARGED_BACK are sent at most once per cycle: the identity of each of them is (boleto, cycle). Boletos settled before this member existed read 1. Fixed on 2026-11-18 (AV-02).'
          examples:
            - 1
        releasedAt:
          type: string
          format: date-time
          description: When the credit became available in the account, RFC 3339 in UTC. Present from RELEASED on.
          examples:
            - '2026-11-14T12:00:00Z'
        reversedAt:
          type: string
          format: date-time
          description: When the held settlement was reversed before release, RFC 3339 in UTC. Present only on REVERSED.
          examples:
            - '2026-11-13T15:30:00Z'
        chargedBackAt:
          type: string
          format: date-time
          description: When the released credit was charged back, RFC 3339 in UTC. Present only on CHARGED_BACK.
          examples:
            - '2026-11-20T10:00:00Z'
      examples:
        - mode: HELD
          state: PENDING_RELEASE
          cycle: 1
        - mode: HELD
          state: RELEASED
          cycle: 1
          releasedAt: '2026-11-14T12:00:00Z'
        - mode: DIRECT
          state: RELEASED
          cycle: 1
          releasedAt: '2026-11-12T18:04:11Z'
        - mode: HELD
          state: RELEASED
          cycle: 2
          releasedAt: '2026-11-28T12:00:00Z'
    SettlementMode:
      type: string
      enum:
        - DIRECT
        - HELD
      description: 'DIRECT: the provider credits the beneficiary''s account when the boleto is paid. HELD: the paid amount is held and credited to the account only on release; until then it is not in the account balance. Fixed by the boleto''s provider. Not to be confused with the HELD lock the collections module keeps internally.'
      examples:
        - HELD
    SettlementState:
      type: string
      enum:
        - PENDING_RELEASE
        - RELEASED
        - REVERSED
        - CHARGEBACK_PENDING
        - CHARGED_BACK
      description: 'Stage of the settlement credit. PENDING_RELEASE: paid and held, not yet credited to the account. RELEASED: credited and available in the account. REVERSED: the held settlement was undone before release, so nothing was credited; this is not the REVERSED status, in which the payment was returned to the payer before settlement. CHARGEBACK_PENDING: the released credit must be charged back but the charge-back was refused (for example, the account lacked funds or was blocked); nothing was debited yet. CHARGED_BACK: the released credit was debited back. Order: PENDING_RELEASE to RELEASED or REVERSED; RELEASED to CHARGEBACK_PENDING or CHARGED_BACK; CHARGEBACK_PENDING to CHARGED_BACK. REVERSED and CHARGED_BACK end the payment cycle: if a title reopened at the base is paid again, the new payment starts a new cycle at PENDING_RELEASE, settlement.cycle increases by 1 and the dates of the previous cycle are cleared. The object always shows the current cycle. Treat the list as open: a value added later must not break a client.'
      examples:
        - PENDING_RELEASE
    BaseSituation:
      type: string
      enum:
        - OPEN
        - PAID
        - CANCELLED
        - LAPSED
      description: 'Situation of the title at the base: OPEN (payable), PAID, CANCELLED, LAPSED (past its payment deadline). Spelled CANCELLED, as the collections module spells it, while status spells CANCELED. Treat the list as open: a value added later must not break a client.'
      examples:
        - OPEN
    RequestedScheduledDate:
      type: string
      format: date
      description: |-
        Planned. Date on which you want the payment to run, `YYYY-MM-DD`, with no time or time zone. Without it, the payment runs immediately.

        - It is not the date the payment runs. On a non-business day the payment runs on `effectiveScheduledDate`: always read that field.
        - Valid window: `tomorrow ≤ scheduledDate ≤ min(dueDate, today + 30 calendar days)`. Outside it, creation is refused with one of the window codes.
        - In the first phase, a date on a non-business day is refused with `PBP-0006`.
      examples:
        - '2026-09-16'
    EffectiveScheduledDate:
      type: string
      format: date
      description: |-
        Planned. Business day on which the payment runs, `YYYY-MM-DD`. Read this date to know when the money goes out.

        - Computed at acceptance as the first business day on or after `scheduledDate`. Equal to it when the requested date is a business day.
        - Fixed at acceptance: a later calendar change does not move it.
        - Only one thing moves it: when the provider refuses the execution for cutoff or time window, the payment is rescheduled to the next business day, up to the attempt limit. A rescheduled payment leaves the `effectiveScheduledDateFrom`/`effectiveScheduledDateTo` interval it was in and enters the next one.
        - Present only in scheduled payments. Absent in an immediate payment.
      examples:
        - '2026-09-14'
    EffectiveAfterDueDate:
      type: boolean
      description: |-
        Planned. `true` when the effective date rolled past the title's due date; `false` otherwise, including in an immediate payment.

        - The window is checked on the requested date (`tomorrow ≤ scheduledDate ≤ min(dueDate, today + 30 days)`). The roll to the next business day happens after that check, so it can pass the due date: a boleto due on a Saturday, scheduled for that day, runs on Monday.
        - This case is accepted, not refused, and has no error code. Use the field to warn whoever scheduled the payment.
        - If the title does not accept payment on the next business day without a change in value, the amount can rise. See `amountIsEstimated`.
        - In the first phase there is no roll: a requested date on a non-business day is refused with `PBP-0006`, so the field is always `false`.
      examples:
        - false
    ScheduleFailureReason:
      type: string
      description: |-
        Planned. Why the execution of a scheduled payment failed terminally. Present only when `status` is `FAILED` and the payment was scheduled. An immediate payment that fails is described only by `errorMessage`.

        | Value | What happened |
        |---|---|
        | `INSUFFICIENT_FUNDS` | Insufficient balance on the effective date. Unlikely, because funds are reserved at creation; it happens if the reservation was undone outside Payments |
        | `BILL_NO_LONGER_PAYABLE` | The title stopped being payable between acceptance and the effective date |
        | `PROVIDER_REJECTED` | The provider refused the instruction by its own rule |
        | `PROVIDER_UNAVAILABLE` | The provider was unavailable up to the attempt limit |
        | `RETRY_LIMIT_EXCEEDED` | Refused for cutoff or time window and rescheduled up to the limit of business days, without success. Each attempt is one business day |
        | `MALFORMED_RECORD` | The record could not be processed because of a data defect |
        | `LEDGER_CONTEXT_MISSING` | The payment's organization or ledger is missing at execution, so it does not run |
        | `CUTOFF_WINDOW_MISSED` | The only non-terminal value: refused for cutoff or time window and rescheduled to the next business day. You only see it if the payment later fails, and then the value is usually `RETRY_LIMIT_EXCEEDED` |

        - In every terminal case the reservation in the ledger is released.
        - `status` decides whether the payment ended, never this field. The field is not returned outside `FAILED`.
      enum:
        - INSUFFICIENT_FUNDS
        - BILL_NO_LONGER_PAYABLE
        - PROVIDER_REJECTED
        - PROVIDER_UNAVAILABLE
        - RETRY_LIMIT_EXCEEDED
        - MALFORMED_RECORD
        - LEDGER_CONTEXT_MISSING
        - CUTOFF_WINDOW_MISSED
      examples:
        - RETRY_LIMIT_EXCEEDED
    BoletoPaidNotification:
      description: 'Body of BOLETO_PAID (base, occurredAt, settledAt, settledAmount, paidVia and settlement). Sent when the boleto becomes SETTLED (payment), for every provider. settlement shows the stage at payment, with cycle 1: HELD/PENDING_RELEASE, or DIRECT/RELEASED, even when a later stage was already recorded (its notification follows this one).'
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - settledAmount
            - settledAt
            - settlement
          properties:
            event:
              type: string
              const: BOLETO_PAID
            status:
              type: string
              const: SETTLED
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
              description: Mode and stage at payment.
      examples:
        - event: BOLETO_PAID
          eventId: 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          occurredAt: '2026-11-12T18:04:11.237Z'
          entityType: BOLETO
          boletoId: 123e4567-e89b-12d3-a456-426614174000
          status: SETTLED
          amount: '150.00'
          providerId: BTG-000123
          settledAmount: '150.00'
          settledAt: '2026-11-12T18:04:11Z'
          paidVia: BOLETO
          settlement:
            mode: HELD
            state: PENDING_RELEASE
            cycle: 1
    BoletoNotificationBase:
      type: object
      description: 'Members common to the boleto notices. Flat body, no envelope, open: the client must ignore members it does not know. Optional members appear only when the boleto holds them. Every BOLETO_* notice carries eventId, the identifier of the notice, equal to the X-Webhook-Id header, and occurredAt, the instant Payments recorded the fact, in UTC with milliseconds; within one transaction, occurredAt grows by 1 ms per notice of the same boleto, in the order of the facts.'
      required:
        - event
        - entityType
        - boletoId
        - status
        - amount
        - eventId
        - occurredAt
      properties:
        event:
          type: string
          description: Event type, equal to the X-Webhook-Event header.
        eventId:
          type: string
          format: uuid
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
        entityType:
          type: string
          const: BOLETO
        boletoId:
          type: string
          format: uuid
        status:
          type: string
          description: Boleto status after the write that produced the notification.
        amount:
          type: string
          description: Boleto amount, decimal string with two places.
          examples:
            - '150.00'
        providerId:
          type: string
          description: Identifier the provider assigned to the boleto, when it has one.
        occurredAt:
          type: string
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          description: 'When Payments recorded the fact, in UTC with milliseconds. Order a boleto''s notices by it: delivery does not guarantee order. Notices of one boleto recorded together never tie and follow the order of the facts; notices recorded at different moments can tie, and in a tie the boleto query tells the current state. It is not the moment of the type''s own member (settledAt, reopenedAt and the like), which is when the origin recorded the fact.'
          examples:
            - '2026-11-12T18:04:11.237Z'
        settledAmount:
          type: string
          examples:
            - '150.00'
        settledAt:
          type: string
          format: date-time
        paidVia:
          type: string
          enum:
            - BOLETO
            - PIX
        canceledAt:
          type: string
          format: date-time
        inactivatedAt:
          type: string
          format: date-time
        cancellationReason:
          type: string
        reversedAt:
          type: string
          format: date-time
          description: Instant of the REVERSED status (payment returned to the payer). Unrelated to settlement.reversedAt.
    BoletoSettlementStageNotification:
      description: Body of BOLETO_SETTLEMENT_REVERSED and BOLETO_SETTLEMENT_CHARGED_BACK. Sent in the transaction that records the stage when the boleto is SETTLED, or, for a stage recorded before, in the transaction that writes SETTLED, after BOLETO_PAID, in the order of the normal flow. A repeated or out-of-order record sends nothing. PENDING_RELEASE and CHARGEBACK_PENDING send nothing; RELEASED sends BOLETO_SETTLED. Each is sent at most once per payment cycle, with identity (boleto, settlement.cycle).
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - settlement
          properties:
            event:
              type: string
              enum:
                - BOLETO_SETTLEMENT_REVERSED
                - BOLETO_SETTLEMENT_CHARGED_BACK
            status:
              type: string
              const: SETTLED
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
              description: 'Settlement after the stage was applied: state REVERSED or CHARGED_BACK, with its date.'
      examples:
        - event: BOLETO_SETTLEMENT_REVERSED
          eventId: 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          occurredAt: '2026-11-13T15:30:00.412Z'
          entityType: BOLETO
          boletoId: 123e4567-e89b-12d3-a456-426614174000
          status: SETTLED
          amount: '150.00'
          providerId: BTG-000123
          settledAmount: '150.00'
          settledAt: '2026-11-12T18:04:11Z'
          paidVia: BOLETO
          settlement:
            mode: HELD
            state: REVERSED
            cycle: 1
            reversedAt: '2026-11-13T15:30:00Z'
    BoletoReopenedFromPaidNotification:
      description: Body of BOLETO_REOPENED_FROM_PAID. The base reopened a paid title. status stays SETTLED; baseSituation becomes OPEN; settlement shows what happened to the credit (REVERSED before release, CHARGEBACK_PENDING or CHARGED_BACK after it), as far as already recorded.
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - baseSituation
            - previousBaseSituation
            - reopenedAt
            - settlement
          properties:
            event:
              type: string
              const: BOLETO_REOPENED_FROM_PAID
            status:
              type: string
              const: SETTLED
            baseSituation:
              type: string
              const: OPEN
            previousBaseSituation:
              type: string
              const: PAID
            reopenedAt:
              type: string
              format: date-time
              description: When the base reopened the title, as the collections module reported it, RFC 3339 in UTC.
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
    BoletoReopenedFromCanceledNotification:
      description: Body of BOLETO_REOPENED_FROM_CANCELED. The base reopened a canceled title; baseSituation becomes OPEN. On a CANCELED boleto, status goes back to CREATED, the boleto can be paid again and canceledAt is cleared. On a SETTLED boleto whose reopened paid title had been canceled (BOLETO_REOPENED_TITLE_CANCELED), status stays SETTLED and settlement is present. Neither BOLETO_CREATED nor BOLETO_CANCEL_FAILED is sent for it.
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - baseSituation
            - previousBaseSituation
            - reopenedAt
          properties:
            event:
              type: string
              const: BOLETO_REOPENED_FROM_CANCELED
            status:
              type: string
              enum:
                - CREATED
                - SETTLED
              description: CREATED when the boleto was CANCELED; SETTLED when it was a reopened paid title.
            baseSituation:
              type: string
              const: OPEN
            previousBaseSituation:
              type: string
              const: CANCELLED
            reopenedAt:
              type: string
              format: date-time
              description: When the base reopened the title, as the collections module reported it, RFC 3339 in UTC.
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
              description: Present only when status is SETTLED.
    BoletoReopenedTitleCanceledNotification:
      description: Body of BOLETO_REOPENED_TITLE_CANCELED. A paid title that the base had reopened (BOLETO_REOPENED_FROM_PAID) was then canceled by the payee's bank. status stays SETTLED, with no transition and no BOLETO_CANCELED; baseSituation becomes CANCELLED; settlement shows the stage of the credit, which moves on its own, so it reads REVERSED, CHARGEBACK_PENDING or CHARGED_BACK once the credit is undone, or still PENDING_RELEASE or RELEASED when the reversal or the charge-back comes later, with its own event.
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - baseSituation
            - previousBaseSituation
            - baseSituationChangedAt
            - settlement
          properties:
            event:
              type: string
              const: BOLETO_REOPENED_TITLE_CANCELED
            status:
              type: string
              const: SETTLED
            baseSituation:
              type: string
              const: CANCELLED
            previousBaseSituation:
              type: string
              const: OPEN
            baseSituationChangedAt:
              type: string
              format: date-time
              description: When the base canceled the title, as the collections module reported it, RFC 3339 in UTC.
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
    BoletoReopenedTitleLapsedNotification:
      description: Body of BOLETO_REOPENED_TITLE_LAPSED. A paid title that the base had reopened (BOLETO_REOPENED_FROM_PAID) was then lapsed (past its payment deadline). status stays SETTLED, with no transition and no BOLETO_INACTIVATED; baseSituation becomes LAPSED; settlement shows the stage of the credit, which moves on its own, so it reads REVERSED, CHARGEBACK_PENDING or CHARGED_BACK once the credit is undone, or still PENDING_RELEASE or RELEASED when the reversal or the charge-back comes later, with its own event.
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - baseSituation
            - previousBaseSituation
            - baseSituationChangedAt
            - settlement
          properties:
            event:
              type: string
              const: BOLETO_REOPENED_TITLE_LAPSED
            status:
              type: string
              const: SETTLED
            baseSituation:
              type: string
              const: LAPSED
            previousBaseSituation:
              type: string
              const: OPEN
            baseSituationChangedAt:
              type: string
              format: date-time
              description: When the title lapsed at the base, as the collections module reported it, RFC 3339 in UTC.
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
    BoletoReopenedPaidAgainNotification:
      description: Body of BOLETO_REOPENED_PAID_AGAIN. A paid title that the base had reopened (BOLETO_REOPENED_FROM_PAID) was paid again, which opens a new payment cycle (R-04). status stays SETTLED, with no transition, no BOLETO_PAID and no BOLETO_SETTLED at this point; baseSituation goes back to PAID. The release of the new cycle sends BOLETO_SETTLED, with the new cycle.
      allOf:
        - $ref: '#/components/schemas/BoletoNotificationBase'
        - type: object
          required:
            - event
            - status
            - baseSituation
            - previousBaseSituation
            - baseSituationChangedAt
            - settlement
          properties:
            event:
              type: string
              const: BOLETO_REOPENED_PAID_AGAIN
            status:
              type: string
              const: SETTLED
            baseSituation:
              type: string
              const: PAID
            previousBaseSituation:
              type: string
              const: OPEN
            baseSituationChangedAt:
              type: string
              format: date-time
              description: When the base recorded the new payment of the title, as the collections module reported it, RFC 3339 in UTC.
            settlement:
              $ref: '#/components/schemas/BoletoSettlement'
              description: 'Settlement at the time of the notification: the new cycle (PENDING_RELEASE, cycle increased by 1) if the new settlement was already recorded; otherwise, the final stage of the previous cycle, with its cycle number.'
    PaymentUnderReviewNotification:
      allOf:
        - $ref: '#/components/schemas/PaymentNotificationBase'
        - properties:
            event:
              const: PAYMENT_UNDER_REVIEW
              type: string
            status:
              const: PENDING_APPROVAL
              type: string
            analysisId:
              type: string
              maxLength: 64
              description: Partner's identifier of the analysis, the same as `antifraud.analysisId` on the payment.
              examples:
                - an-7f3c2a91
            reviewExpiresAt:
              type: string
              format: date-time
              description: End of the review window, the same as `antifraud.reviewExpiresAt` on the payment. Without a final decision by then, the payment ends REJECTED with ANTIFRAUD_REVIEW_EXPIRED and PAYMENT_REJECTED is sent.
              examples:
                - '2026-11-16T14:33:12Z'
          required:
            - analysisId
            - reviewExpiresAt
          type: object
      description: New. Sent when the payment is recorded in PENDING_APPROVAL after the antifraud answered REVIEW. `amount` is the amount of the consult made at initiation. The partner's reasons and score are not sent; they stay in the analysis for audit only (P-30).
    PaymentNotificationBase:
      description: Body every PAYMENT_* notice carries today. Flat JSON, no envelope. Instants are RFC 3339 in UTC, amounts decimal strings with two places. Members are present only when set, except eventId, always present. Unlike a boleto notice, a payment notice carries no occurredAt.
      properties:
        event:
          type: string
          examples:
            - PAYMENT_SETTLED
        eventId:
          type: string
          format: uuid
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
        entityType:
          const: PAYMENT
          type: string
        paymentId:
          format: uuid
          type: string
        status:
          type: string
        amount:
          type: string
          examples:
            - '100.00'
        providerId:
          type: string
      required:
        - event
        - entityType
        - paymentId
        - status
        - amount
        - eventId
      type: object
    PaymentReturnedNotification:
      allOf:
        - $ref: '#/components/schemas/PaymentNotificationBase'
        - properties:
            event:
              const: PAYMENT_RETURNED
              type: string
            status:
              const: RETURNED
              type: string
            settledAmount:
              type: string
              description: Amount settled before the return.
            settledAt:
              type: string
              format: date-time
            returnedAmount:
              type: string
              pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
              maxLength: 19
              description: Amount credited back to the funding account.
              examples:
                - '100.00'
            returnedAt:
              description: When the return was posted.
              examples:
                - '2026-11-17T11:20:04Z'
              format: date-time
              type: string
            returnReason:
              description: Reason the issuing institution gave.
              maxLength: 500
              type: string
          required:
            - returnedAmount
            - returnedAt
            - returnReason
          type: object
      description: New. Sent when the amount goes back to the funding account, not when the issuing institution's notice arrives (PR-A).
    CnabReturnAvailableNotice:
      additionalProperties: true
      properties:
        agreementCode:
          description: Collection agreement code, seven digits, as written in the file header.
          examples:
            - '1234567'
          pattern: ^[0-9]{7}$
          type: string
        agreementId:
          description: CNAB agreement the return belongs to.
          format: uuid
          type: string
        entityType:
          description: Entity the notice is about.
          enum:
            - CNAB_RETURN
          type: string
        event:
          description: Notice type, equal to the X-Webhook-Event header.
          enum:
            - CNAB_RETURN_AVAILABLE
          type: string
        eventId:
          description: Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature.
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
          format: uuid
          type: string
        generatedAt:
          description: When the return was generated, RFC 3339 in UTC.
          format: date-time
          type: string
        movementCount:
          description: Number of movements the return carries, from 1 to 49,999.
          format: int64
          maximum: 49999
          minimum: 1
          type: integer
        nsa:
          description: Sequential number of the return file within the agreement, without gaps.
          format: int64
          type: integer
        occurredAt:
          description: When Payments recorded that the return is available, in UTC with milliseconds.
          examples:
            - '2026-11-12T18:04:11.237Z'
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
          type: string
        returnId:
          description: Identifier of the generated return; the entity of the notice.
          format: uuid
          type: string
        trigger:
          description: 'How the return was cut: at the agreement''s scheduled time (SCHEDULED) or on request (ON_DEMAND). Treat as open.'
          enum:
            - SCHEDULED
            - ON_DEMAND
          type: string
      required:
        - event
        - entityType
        - returnId
        - agreementId
        - agreementCode
        - nsa
        - movementCount
        - trigger
        - generatedAt
        - occurredAt
        - eventId
      type: object
    ElectronicPayerNotice:
      type: object
      description: |
        One notice per organization with an adhered account. When an organization excludes the adhesion while another
        one keeps adhered accounts, that organization receives ELECTRONIC_PAYER_EXCLUDED and the others
        ELECTRONIC_PAYER_UPDATED (R-1), both with the same version. A refused exclusion or account removal arrives as
        ELECTRONIC_PAYER_UPDATE_REJECTED (R-5).
      required:
        - event
        - entityType
        - organizationId
        - electronicPayerId
        - version
        - occurredAt
        - sourceFactId
        - sourceFactFingerprint
        - eventId
      properties:
        event:
          type: string
          enum:
            - ELECTRONIC_PAYER_REGISTERED
            - ELECTRONIC_PAYER_REJECTED
            - ELECTRONIC_PAYER_UPDATED
            - ELECTRONIC_PAYER_UPDATE_REJECTED
            - ELECTRONIC_PAYER_EXCLUDED
            - ELECTRONIC_PAYER_THIRD_PARTY_CHANGED
            - ELECTRONIC_PAYER_THIRD_PARTY_REJECTED
            - ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED
        eventId:
          type: string
          format: uuid
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
        entityType:
          type: string
          enum:
            - ELECTRONIC_PAYER
        organizationId:
          type: string
          format: uuid
        electronicPayerId:
          type: string
          format: uuid
        requestId:
          type: string
          format: uuid
          description: Present when the notice answers a request of this API. A refusal delivered again is recognized by requestId.
        version:
          type: integer
          format: int64
          description: 'The payer''s version. Apply only when greater than the last one applied for the same organizationId and electronicPayerId (one change yields one notice per organization, all with the same version), except ELECTRONIC_PAYER_UPDATE_REJECTED, ELECTRONIC_PAYER_THIRD_PARTY_REJECTED and ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED: they carry the current version and are not discarded by version. Discard repeated deliveries by X-Webhook-Id.'
          minimum: 1
        occurredAt:
          type: string
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
        sourceFactId:
          type: string
          format: uuid
        sourceFactFingerprint:
          type: string
          pattern: ^[0-9a-f]{64}$
          description: Fingerprint of the content of the fact; the same on the notices of every organization the fact concerns. For support only.
        origin:
          type: string
          enum:
            - API
            - BULK_LOAD
            - ACCOUNT_CLOSURE
            - OTHER_INSTITUTION
        rejection:
          $ref: '#/components/schemas/Rejection'
        boletoCount:
          type: integer
          minimum: 0
          format: int64
        syncCursor:
          type: string
        aggregateId:
          type: string
          format: uuid
          description: On ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED, present when the load follows the inclusion of an aggregate (C-09).
        registeredAt:
          type: string
          format: date-time
          description: On ELECTRONIC_PAYER_REGISTERED.
        rejectedAt:
          type: string
          format: date-time
          description: On the *_REJECTED types.
        updatedAt:
          type: string
          format: date-time
          description: On ELECTRONIC_PAYER_UPDATED.
        excludedAt:
          type: string
          format: date-time
          description: On ELECTRONIC_PAYER_EXCLUDED.
        changedAt:
          type: string
          format: date-time
          description: On ELECTRONIC_PAYER_THIRD_PARTY_CHANGED.
        completedAt:
          type: string
          format: date-time
          description: On ELECTRONIC_PAYER_INITIAL_LOAD_COMPLETED.
    ReceiverBoletoNotice:
      type: object
      required:
        - event
        - entityType
        - organizationId
        - electronicPayerId
        - receiverBoletoId
        - registryTitleId
        - version
        - occurredAt
        - sourceFactId
        - sourceFactFingerprint
        - amount
        - dueDate
        - beneficiaryType
        - eventId
      properties:
        event:
          type: string
          enum:
            - RECEIVER_BOLETO_NOTICED
            - RECEIVER_BOLETO_UPDATED
            - RECEIVER_BOLETO_WRITTEN_OFF
            - RECEIVER_BOLETO_PARTIALLY_PAID
            - RECEIVER_BOLETO_WRITEOFF_REVERSED
            - RECEIVER_BOLETO_LAPSED
            - RECEIVER_BOLETO_ACCEPTANCE_CHANGED
            - RECEIVER_BOLETO_ACCEPTANCE_REJECTED
            - RECEIVER_BOLETO_THIRD_PARTY_NOTICED
        eventId:
          type: string
          format: uuid
          description: 'Identifier of this notice, equal to the X-Webhook-Id header and the same on every delivery of it. Covered by the signature: discard repetitions of a notice by it.'
          examples:
            - 0199c3d4-e5f6-7a70-8b2c-3d4e5f6a7b8c
        entityType:
          type: string
          enum:
            - RECEIVER_BOLETO
        organizationId:
          type: string
          format: uuid
        electronicPayerId:
          type: string
          format: uuid
        receiverBoletoId:
          type: string
          format: uuid
        registryTitleId:
          type: string
          maxLength: 32
        requestId:
          type: string
          format: uuid
          description: Present when the notice answers a request of this API. A refusal delivered again is recognized by requestId.
        version:
          type: integer
          format: int64
          description: 'The boleto''s version. Apply only when greater than the last one applied for the same organizationId and receiverBoletoId (one change yields one notice per organization, all with the same version), except RECEIVER_BOLETO_ACCEPTANCE_REJECTED: it carries the current version and is not discarded by version. Discard repeated deliveries by X-Webhook-Id.'
          minimum: 1
        occurredAt:
          type: string
          format: date-time
          pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
        sourceFactId:
          type: string
          format: uuid
        sourceFactFingerprint:
          type: string
          pattern: ^[0-9a-f]{64}$
          description: Fingerprint of the content of the fact; the same on the notices of every organization the fact concerns. For support only.
        amount:
          type: string
          pattern: ^[0-9]+\.[0-9]{2}$
        dueDate:
          type: string
          format: date
        beneficiaryType:
          type: string
          enum:
            - INDIVIDUAL
            - COMPANY
        paidAmount:
          type: string
          pattern: ^[0-9]+\.[0-9]{2}$
        remainingAmount:
          type: string
          pattern: ^[0-9]+\.[0-9]{2}$
        acceptance:
          type: string
          enum:
            - ACCEPTED
            - REFUSED
        byThisInstitution:
          type: boolean
        rejection:
          $ref: '#/components/schemas/Rejection'
        noticedAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_NOTICED and RECEIVER_BOLETO_THIRD_PARTY_NOTICED.
        updatedAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_UPDATED.
        writtenOffAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_WRITTEN_OFF.
        paidAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_PARTIALLY_PAID.
        reversedAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_WRITEOFF_REVERSED.
        lapsedAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_LAPSED.
        changedAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_ACCEPTANCE_CHANGED.
        rejectedAt:
          type: string
          format: date-time
          description: On RECEIVER_BOLETO_ACCEPTANCE_REJECTED.
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http
  parameters:
    OrganizationId:
      description: 'Midaz organization the CNAB agreement, remittance or return belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A resource of another organization is answered 404, exactly as one that does not exist.'
      in: header
      name: X-Organization-Id
      required: true
      schema:
        type: string
        format: uuid
    Cursor:
      description: Opaque cursor returned in nextCursor or prevCursor. Left out, the first page.
      in: query
      name: cursor
      schema:
        type: string
        maxLength: 512
    Limit:
      description: Most items per page.
      in: query
      name: limit
      schema:
        type: integer
        format: int64
        default: 50
        minimum: 1
        maximum: 200
        examples:
          - 50
    ReturnId:
      description: Identifier of the return.
      in: path
      name: return_id
      required: true
      schema:
        type: string
        format: uuid
        examples:
          - 019a8b02-7e55-7a10-a3c4-0f9b8d2e6c85
    OrganizationIdDDA:
      name: X-Organization-Id
      in: header
      required: true
      schema:
        type: string
        format: uuid
    IdempotencyKeyDDA:
      name: Idempotency-Key
      in: header
      required: true
      description: |
        UUID. The same key with the same body returns the same 202 with the same requestId and never creates a second
        request; the same key with another body is refused. One exception: while the provider has not answered the
        request (the earlier answer was 202 PENDING because the provider did not answer after the request was sent), a
        retry with the same key and body sends the request again with the same requestId, which the provider
        deduplicates, and returns the 202 completed with the provider's answer (for an adhesion, the electronicPayerId).
        Once the provider has answered, retries return that 202 unchanged. The key is released only by a 503, when no
        attempt under it can have reached the provider.
      schema:
        type: string
        format: uuid
    CursorDDA:
      name: cursor
      in: query
      required: false
      schema:
        type: string
        maxLength: 1024
      description: nextCursor of the previous page.
    ChangedSince:
      name: changedSince
      in: query
      required: false
      schema:
        type: string
        maxLength: 1024
      description: syncCursor of a previous full read.
    LimitDDA:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 200
        default: 50
    ElectronicPayerId:
      name: electronicPayerId
      in: path
      required: true
      schema:
        type: string
        format: uuid
    ReceiverBoletoId:
      name: receiverBoletoId
      in: path
      required: true
      schema:
        type: string
        format: uuid
    OrganizationIdI13:
      description: 'Midaz organization the payment belongs to. Required: a request without it, or with a value that is not a canonical UUID, is refused with 400 PBP-0025. A payment of another organization is answered 404, exactly as one that does not exist.'
      in: header
      name: X-Organization-Id
      schema:
        type: string
    PaymentId:
      description: Payment identifier (UUID).
      in: path
      name: id
      required: true
      schema:
        examples:
          - 123e4567-e89b-12d3-a456-426614174000
        format: uuid
        type: string
    WriteOffIdPath:
      name: write_off_id
      in: path
      required: true
      description: Identifier of the write-off in collections.
      schema:
        type: string
        format: uuid
    CreditEntryIdPath:
      name: credit_entry_id
      in: path
      required: true
      description: Identifier of the credit entry.
      schema:
        type: string
        format: uuid
    IdempotencyKeyHeader:
      name: Idempotency-Key
      in: header
      required: true
      description: 'Idempotency key of the client, a UUID. Missing or invalid: 400 `PBP-0012`; an earlier request with the same key still running: 409 `PBP-0007`; the same key with another body: 422 `PBP-0013`. Afterwards, the same key returns the stored answer.'
      schema:
        type: string
        format: uuid
        examples:
          - 5f2b8a8e-3c1d-4f7a-9b2e-6d4c1a0e9f11
    NoticeIdPath:
      name: notice_id
      in: path
      required: true
      description: Local identifier of the received notice.
      schema:
        type: string
        format: uuid
    CommandIdPath:
      name: command_id
      in: path
      required: true
      description: Identifier of the command to the PCR.
      schema:
        type: string
        format: uuid
    AgreementIdPath:
      name: agreement_id
      in: path
      required: true
      description: Identifier of the agreement in collections.
      schema:
        type: string
        format: uuid
    TitleIdPath:
      name: title_id
      in: path
      required: true
      description: Identifier of the collections title.
      schema:
        type: string
        format: uuid
