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

# Apply the antifraud final decision

> Applies the final decision of the client's antifraud partner on a payment it sent to review (`REVIEW`). The partner calls it, not the payer.

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

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

**How it works**

- It follows the Lerian antifraud resolve contract (v1), shared with the other Lerian transactional plugins. The body is `AntifraudResolveRequest`.
- Only the partner's machine credential can call it: an application the tenant lists as its antifraud partner, with the `antifraud-partner` role. `editor` users and the client's own applications get `403`.
- Requires the `payments` x `resolve` permission, held only by the `antifraud-partner` role.
- The partner application gets `403` on every other route. It never creates, cancels or reads a payment.
- No `X-Organization-Id`: the analysis is found by `analysisId` in the token's tenant.
- `X-Idempotency` is `<analysisId>:<decision>`. The same key returns the first outcome. Repeat a `5xx` under the same key.
- `ALLOW`: the slip is consulted again with the stored data, and the capability and limit checks run again. If accepted, the payment moves to `UNCONFIRMED` with the amount of the new consult (the informed amount, when one was stored) and follows the normal payment flow. If refused, it ends `REJECTED` with the consult's reason.
- `DENY`: the payment ends `REJECTED` with `ANTIFRAUD_DENIED`.
- Both send `PAYMENT_REJECTED` when the payment ends `REJECTED`. The outcome later goes back to the partner as feedback.
- Lerian sets up the tenant's antifraud (on or off, the partner's credential and address, the review window) and the partner's applications at onboarding. No client endpoint reads or changes them.



## OpenAPI

````yaml /pt/openapi/v3-current/payments-pcr.yaml post /v1/payments/antifraud/resolve
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/antifraud/resolve:
    post:
      tags:
        - Payments
      summary: Apply the antifraud final decision
      description: >-
        Applies the final decision of the client's antifraud partner on a
        payment it sent to review (`REVIEW`). The partner calls it, not the
        payer.


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


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


        **How it works**


        - It follows the Lerian antifraud resolve contract (v1), shared with the
        other Lerian transactional plugins. The body is
        `AntifraudResolveRequest`.

        - Only the partner's machine credential can call it: an application the
        tenant lists as its antifraud partner, with the `antifraud-partner`
        role. `editor` users and the client's own applications get `403`.

        - Requires the `payments` x `resolve` permission, held only by the
        `antifraud-partner` role.

        - The partner application gets `403` on every other route. It never
        creates, cancels or reads a payment.

        - No `X-Organization-Id`: the analysis is found by `analysisId` in the
        token's tenant.

        - `X-Idempotency` is `<analysisId>:<decision>`. The same key returns the
        first outcome. Repeat a `5xx` under the same key.

        - `ALLOW`: the slip is consulted again with the stored data, and the
        capability and limit checks run again. If accepted, the payment moves to
        `UNCONFIRMED` with the amount of the new consult (the informed amount,
        when one was stored) and follows the normal payment flow. If refused, it
        ends `REJECTED` with the consult's reason.

        - `DENY`: the payment ends `REJECTED` with `ANTIFRAUD_DENIED`.

        - Both send `PAYMENT_REJECTED` when the payment ends `REJECTED`. The
        outcome later goes back to the partner as feedback.

        - Lerian sets up the tenant's antifraud (on or off, the partner's
        credential and address, the review window) and the partner's
        applications at onboarding. No client endpoint reads or changes them.
      operationId: resolveAntifraudAnalysis
      parameters:
        - name: X-Idempotency
          in: header
          required: true
          description: >-
            Raw `<analysisId>:<decision>`, as the library contract defines. The
            same key replays the first outcome.
          schema:
            type: string
            pattern: ^[\x21-\x7E]{1,128}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AntifraudResolveRequest'
      responses:
        '200':
          description: >-
            OK. The decision was applied, whatever happened to the payment. Read
            the outcome on the payment. On `ALLOW`, if the source no longer
            accepts the informed amount, the payment ends `REJECTED` with
            `PBP-0217`.
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0012:
                  summary: 'PBP-0012: Idempotency-Key missing'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0012
                    title: Bad Request
                    status: 400
                    detail: X-Idempotency is missing or malformed.
                    code: PBP-0012
          description: |-
            Bad Request.

            - `PBP-0012`: `X-Idempotency` is missing or malformed.
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0003:
                  summary: 'PBP-0003: Invalid credential'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0003
                    title: Unauthorized
                    status: 401
                    detail: authentication required
                    code: PBP-0003
          description: >-
            Unauthorized.


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


            - `PBP-0004`: the credential does not have the `payments` x
            `resolve` permission. It is held only by the listed antifraud
            partner application.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0005:
                  summary: 'PBP-0005: Analysis not found'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0005
                    title: Not Found
                    status: 404
                    detail: No antifraud analysis with this analysisId.
                    code: PBP-0005
          description: >-
            Not Found.


            - `PBP-0005`: no analysis with this `analysisId` in the token's
            tenant.
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemWithI13Extensions'
              examples:
                PBP-0214:
                  summary: 'PBP-0214: Analysis already closed'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0214
                    title: ANTIFRAUD_ANALYSIS_CLOSED
                    status: 409
                    detail: The antifraud analysis is already closed.
                    code: PBP-0214
                    currentStatus: REJECTED
                PBP-0215:
                  summary: 'PBP-0215: Review window ended'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0215
                    title: ANTIFRAUD_REVIEW_EXPIRED
                    status: 409
                    detail: The review window of this analysis has ended.
                    code: PBP-0215
          description: >-
            Conflict. Final. Do not repeat.


            - `PBP-0214`: the analysis is already closed: a final decision was
            applied before, or it expired. `currentStatus` names the payment's
            status. A concurrent decision under another key also gets this code.

            - `PBP-0215`: the review window ended (`antifraud.reviewExpiresAt`
            passed). The payment ends `REJECTED` with
            `ANTIFRAUD_REVIEW_EXPIRED`.


            See the [error
            list](/pt/reference/interfaces/payments-btg/payments-error-list) for
            every code.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0219:
                  summary: 'PBP-0219: Invalid resolve body'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0219
                    title: ANTIFRAUD_RESOLVE_INVALID
                    status: 422
                    detail: The body does not follow the antifraud resolve contract.
                    code: PBP-0219
                PBP-0013:
                  summary: 'PBP-0013: Key used for another request'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0013
                    title: Idempotency Key Conflict
                    status: 422
                    detail: >-
                      The request body does not match the original request for
                      this idempotency key.
                    code: PBP-0013
          description: >-
            Unprocessable Entity.


            - `PBP-0219`: the body breaks the resolve contract. Only
            `analysisId`, `decision` and the body size (16 KiB) can cause it.

            - `PBP-0013`: this `X-Idempotency` was already used with a different
            body. A repeat must be byte-identical. A `422` after a `5xx` on the
            same key means the earlier outcome was not recorded: do not repeat.


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


            - `PBP-0002`: an unexpected failure. Repeat under the same
            `X-Idempotency`.
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
              examples:
                PBP-0015:
                  summary: 'PBP-0015: Consult unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0015
                    title: Provider Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0015
                PBP-0008:
                  summary: 'PBP-0008: Dependency unavailable'
                  value:
                    type: https://errors.lerian.studio/v1/PBP-0008
                    title: Service Unavailable
                    status: 503
                    detail: internal error
                    code: PBP-0008
          description: >-
            Service Unavailable. Repeat with the same `X-Idempotency`.


            - `PBP-0015`: on `ALLOW`, the new consult of the slip gave no usable
            answer. Nothing changed: the payment stays `PENDING_APPROVAL` until
            it is decided or expires.

            - `PBP-0008`: a dependency (authentication or storage) is
            unavailable, or a request with the same `X-Idempotency` is still
            running. In that case the answer has `Retry-After`: wait, then
            repeat with the same key.
          headers:
            Retry-After:
              description: >-
                Seconds to wait before repeating with the same X-Idempotency.
                Sent on the in-flight answer.
              schema:
                type: integer
                minimum: 1
                examples:
                  - 1
      security:
        - BearerAuth: []
components:
  schemas:
    AntifraudResolveRequest:
      type: object
      required:
        - analysisId
        - decision
      description: >-
        The partner's final decision on an analysis, as defined by the Lerian
        antifraud resolve contract (v1). Body capped at 16 KiB. Only
        `analysisId`, `decision` and the body size can refuse the request (422
        PBP-0219); `reasons` never does: a bad entry is dropped, and the reasons
        after the first 50 kept are discarded with a warning in the log (P-23).
      properties:
        analysisId:
          type: string
          pattern: ^[\x21-\x7E]{1,64}$
          description: >-
            The analysisId the partner returned with REVIEW: 1 to 64 printable
            ASCII characters, no space.
        decision:
          type: string
          enum:
            - ALLOW
            - DENY
          description: Final decision. REVIEW is never final.
        reasons:
          type: array
          description: >-
            Optional. The service records the first 50 entries the library keeps
            and discards the rest, with a warning in the log; no count or entry
            refuses the request.
          items:
            $ref: '#/components/schemas/AntifraudReason'
    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
    ProblemWithI13Extensions:
      allOf:
        - $ref: '#/components/schemas/Detail'
        - properties:
            capability:
              $ref: '#/components/schemas/PaymentCapabilityName'
            currentStatus:
              description: >-
                PBP-0214: the payment's status when the final decision was
                refused.
              type: string
              examples:
                - REJECTED
            maxAmount:
              type: string
              pattern: ^(0|[1-9][0-9]{0,15})\.[0-9]{2}$
              maxLength: 19
              description: 'PBP-0216: the provider''s per-payment ceiling, exclusive.'
              examples:
                - '250000.00'
            receiptUnavailableReason:
              description: 'PBP-0218: why the payment has no receipt.'
              enum:
                - PAYMENT_NOT_SETTLED
                - PAYMENT_REJECTED
                - PAYMENT_FAILED
                - PAYMENT_CANCELED
                - PROVIDER_WITHOUT_RECEIPT
              type: string
          type: object
      description: >-
        The plugin's problem document (Detail, additionalProperties true) with
        the RFC 9457 extension members added for payments. Each member is
        present only with the code that names it; `capability` takes the
        provider capability values and the two payment values
        (PaymentCapabilityName).
    AntifraudReason:
      type: object
      description: >-
        One reason the partner gave; never a cause to refuse the request. An
        entry whose code is absent, empty, not a string or holds a control
        character is dropped; a description that is not a string or holds NUL is
        blanked (a newline is kept); other members are ignored. Code and
        description are kept as sent, with no length cut, inside the 16 KiB
        body.
      properties:
        code:
          type: string
        description:
          type: string
    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
    PaymentCapabilityName:
      description: >-
        Provider capability names of the payment operations (`capability` member
        of PBP-0701). The first four are the values the published contract
        already documents on POST /v1/payments: OPERATION_BANKSLIP_PAYMENT,
        OPERATION_BARCODE_BILL_PAYMENT, PAYMENT_SEGMENT_BANKSLIP and
        PAYMENT_SEGMENT_UTILITIES. Two are planned. PAYMENT_AMOUNT_INFORMED: the
        provider pays an amount the client informs. PAYMENT_RECEIPT: the
        provider delivers the receipt data at settlement; its absence is
        answered 409 PBP-0218, not PBP-0701, so it never appears in a PBP-0701
        of this operation. The per-payment ceiling is a declared value, not a
        name. New values may appear; a client must handle an unknown one.
      enum:
        - OPERATION_BANKSLIP_PAYMENT
        - OPERATION_BARCODE_BILL_PAYMENT
        - PAYMENT_SEGMENT_BANKSLIP
        - PAYMENT_SEGMENT_UTILITIES
        - PAYMENT_AMOUNT_INFORMED
        - PAYMENT_RECEIPT
      type: string
  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.