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

# Add an aggregate

> Adds an aggregate to the electronic payer. Boletos issued against the aggregate are presented to this payer, at this institution only.

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

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

**How it works**

- Send the aggregate's `document` (CPF or CNPJ, without punctuation; a CNPJ can be alphanumeric) and the customer's `consent`.
- `consent.acceptedAt` cannot be in the future or older than 24 hours (configurable).
- The answer is `202` with a `requestId`. The outcome arrives as a webhook notice and at `GET /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
- A retry under the same `Idempotency-Key` and body returns the same `202` and `requestId`. It never creates a second request.
- The same key with another body or `X-Organization-Id` is refused with `PBP-0013`.
- If the provider did not answer an earlier attempt, the same key and body resend it with the same `requestId`. The provider discards the duplicate.



## OpenAPI

````yaml /pt/openapi/v3-current/payments-pcr.yaml post /v1/electronic-payers/{electronicPayerId}/aggregates
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/electronic-payers/{electronicPayerId}/aggregates:
    parameters:
      - $ref: '#/components/parameters/ElectronicPayerId'
      - $ref: '#/components/parameters/OrganizationIdDDA'
    post:
      tags:
        - Electronic payers
      summary: Add an aggregate
      description: >-
        Adds an aggregate to the electronic payer. Boletos issued against the
        aggregate are presented to this payer, at this institution only.


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


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


        **How it works**


        - Send the aggregate's `document` (CPF or CNPJ, without punctuation; a
        CNPJ can be alphanumeric) and the customer's `consent`.

        - `consent.acceptedAt` cannot be in the future or older than 24 hours
        (configurable).

        - The answer is `202` with a `requestId`. The outcome arrives as a
        webhook notice and at `GET
        /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.

        - A retry under the same `Idempotency-Key` and body returns the same
        `202` and `requestId`. It never creates a second request.

        - The same key with another body or `X-Organization-Id` is refused with
        `PBP-0013`.

        - If the provider did not answer an earlier attempt, the same key and
        body resend it with the same `requestId`. The provider discards the
        duplicate.
      operationId: addElectronicPayerAggregate
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyDDA'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddAggregateRequest'
      responses:
        '202':
          description: >-
            Accepted. The request was taken for processing. The outcome arrives
            as a webhook notice and at `GET
            /v1/electronic-payers/{electronicPayerId}/requests/{requestId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '404':
          description: >-
            Not Found.


            - `PBP-1005`: the electronic payer does not exist or has no adhered
            account in this organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-1005:
                  summary: 'PBP-1005: Electronic payer not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1005
                    title: ELECTRONIC_PAYER_NOT_FOUND
                    status: 404
                    detail: electronic payer not found in this organization
                    code: PBP-1005
        '422':
          description: >-
            Unprocessable Entity.


            - `PBP-0013`: the `Idempotency-Key` was already used on this
            endpoint with a different body or `X-Organization-Id`. Resend the
            original request under that key, or send the new request under a new
            key.

            - `PBP-0701`: the provider does not support aggregates. The
            `capability` member is `ELECTRONIC_PAYER_AGGREGATES`.

            - `PBP-1000`: DDA is not enabled for the tenant: there is no
            provider route for `ELECTRONIC_PAYER`. Configure the route first.

            - `PBP-1001`: the aggregate's CPF or CNPJ is invalid (check digit or
            length).

            - `PBP-1002`: `consent` is missing or incomplete, or `acceptedAt` is
            in the future or older than the accepted window (24 hours,
            configurable). Collect the consent again.


            The provider can also refuse the request with its own code, for
            example when the aggregate is the payer itself. The `category`
            member gives a stable reason. Handle the refusal by `category`.


            See the [error
            list](/pt/reference/interfaces/payments-btg/payments-error-list) for
            every code.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
              examples:
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: >-
                      The request body or X-Organization-Id does not match the
                      original request for this idempotency key.
                    code: PBP-0013
                PBP-0701:
                  summary: 'PBP-0701: Feature not supported by the provider'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0701
                    title: PROVIDER_CAPABILITY_NOT_SUPPORTED
                    status: 422
                    detail: the provider does not support this capability
                    code: PBP-0701
                    capability: ELECTRONIC_PAYER_AGGREGATES
                PBP-1000:
                  summary: 'PBP-1000: DDA not enabled'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1000
                    title: DDA_NOT_ENABLED
                    status: 422
                    detail: DDA is not enabled for this tenant
                    code: PBP-1000
                PBP-1001:
                  summary: 'PBP-1001: Invalid CPF or CNPJ'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1001
                    title: INVALID_DOCUMENT
                    status: 422
                    detail: the CPF or CNPJ is invalid
                    code: PBP-1001
                PBP-1002:
                  summary: 'PBP-1002: Consent invalid'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-1002
                    title: INVALID_CONSENT
                    status: 422
                    detail: >-
                      consent is missing, incomplete or outside the accepted
                      time window
                    code: PBP-1002
      security:
        - BearerAuth: []
components:
  parameters:
    ElectronicPayerId:
      name: electronicPayerId
      in: path
      required: true
      schema:
        type: string
        format: uuid
    OrganizationIdDDA:
      name: X-Organization-Id
      in: header
      required: true
      schema:
        type: string
        format: uuid
    IdempotencyKeyDDA:
      name: Idempotency-Key
      in: header
      required: true
      description: >
        UUID. The same key with the same body returns the same 202 with the same
        requestId and never creates a second

        request; the same key with another body is refused. One exception: while
        the provider has not answered the

        request (the earlier answer was 202 PENDING because the provider did not
        answer after the request was sent), a

        retry with the same key and body sends the request again with the same
        requestId, which the provider

        deduplicates, and returns the 202 completed with the provider's answer
        (for an adhesion, the electronicPayerId).

        Once the provider has answered, retries return that 202 unchanged. The
        key is released only by a 503, when no

        attempt under it can have reached the provider.
      schema:
        type: string
        format: uuid
  schemas:
    AddAggregateRequest:
      type: object
      required:
        - document
        - consent
      properties:
        document:
          $ref: '#/components/schemas/Document'
        consent:
          $ref: '#/components/schemas/Consent'
    AcceptedRequest:
      type: object
      required:
        - requestId
        - kind
        - status
      properties:
        requestId:
          type: string
          format: uuid
        electronicPayerId:
          type: string
          format: uuid
          description: >-
            Absent only on an adhesion whose provider answer was not received; a
            retry with the same Idempotency-Key returns it, and GET
            /electronic-payers/requests/{requestId} reads the request meanwhile.
        aggregateId:
          type: string
          format: uuid
        thirdPartyId:
          type: string
          format: uuid
        kind:
          $ref: '#/components/schemas/RequestKind'
        status:
          type: string
          enum:
            - PENDING
    Problem:
      type: object
      properties:
        type:
          type: string
        title:
          type: string
        status:
          type: integer
        detail:
          type: string
        code:
          type: string
          examples:
            - PBP-1000
        capability:
          type: string
          description: With PBP-0701, the capability the provider does not declare.
    Document:
      type: object
      required:
        - number
      properties:
        number:
          type: string
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          description: >-
            CPF (11 digits) or CNPJ (14 characters: 12 digits or uppercase
            letters, then 2 check digits, numeric or alphanumeric as issued by
            Receita Federal; MAPX-OP016-2009 v62, CNPJ_CPF). No punctuation.
            Accepted on this request only; never returned.
    Consent:
      type: object
      description: >-
        Attestation of the customer's consent, collected by the institution.
        Sent on to whoever keeps it for the institution.
      required:
        - acceptedAt
        - channel
        - termVersion
        - consentedBy
      properties:
        acceptedAt:
          type: string
          format: date-time
          description: >-
            When the customer consented. Not in the future and not older than 24
            hours (configurable).
        channel:
          $ref: '#/components/schemas/Channel'
        termVersion:
          type: string
          minLength: 1
          maxLength: 64
        consentedBy:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            Opaque reference of the customer at the institution. Never a CPF or
            CNPJ.
    RequestKind:
      type: string
      enum:
        - REGISTRATION
        - ACCOUNTS_UPDATE
        - EXCLUSION
        - AGGREGATE_ADDITION
        - AGGREGATE_REMOVAL
        - ACCEPTANCE
        - THIRD_PARTY_ADDITION
        - THIRD_PARTY_REMOVAL
    Channel:
      type: string
      description: Neutral channel list (same list as payments).
      enum:
        - BRANCH
        - ATM
        - INTERNET
        - BANKING_AGENT
        - CALL_CENTER
        - ELECTRONIC_FILE
        - DDA
        - DIGITAL_BANKING_AGENT
  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.