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

# Initiate a DARF payment

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



## OpenAPI

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


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

````

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