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

# Create an agreement outside the default template

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



## OpenAPI

````yaml /es/openapi/v3-current/payments-pcr.yaml post /v1/collections/agreements
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/collections/agreements:
    post:
      tags:
        - Collections Agreements
      summary: Create an agreement outside the default template
      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](/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 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](/es/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](/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, 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: []
components:
  schemas:
    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
    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'
            - null
          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
            - null
          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
            - null
          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
    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
    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
    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
    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
    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:
            - 99999999
          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
  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.