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

# Decide Antifraud Analysis

> Use this endpoint to decide a transfer that waits in `FRAUD_ANALYSIS`. The antifraud partner of your institution calls it with its `/resolve` answer, or a person of your institution calls it.

`evaluationKey` is the key that the partner received. It is the `transferId` for a TED OUT, a cross-core TED, and the payer end of a P2P. It is the `transferId` followed by `.in` for the recipient end of a P2P.

- `DENY` rejects the transfer and releases its hold and its usage limit.
- `ALLOW` resumes the transfer. It sends the TED OUT, sends the cross-core credit, or confirms the P2P hold. The `200` answer carries the status that the transfer is in. It is `FRAUD_ANALYSIS` again when the `ALLOW` of the payer end of a P2P opened the analysis of the recipient end.

A received TED (TED IN) that the antifraud partner holds is decided here by the partner application alone, under its `transferId`. The call writes only the closing block of the check. The next re-drive credits the TED (`ALLOW`) or returns it with STR0010 code 9 (`DENY`). A person decides a received TED on [Decide TED IN Held by Antifraud](/en/reference/interfaces/ted-jd/decide-ted-in-held-by-antifraud) and gets `403` here. A received cross-core credit is never decided: the first answer of the partner is final, so the partner gets `409` and a person gets `403`. The partner always gets `409` for a TED IN that it did not answer, and `503` while its evaluation has no answer recorded yet.

The first final decision wins, from whoever sends it. A second decision gets `409`. So does a decision for another `analysisId` or another end than the pending one, and a decision after `decideBy`. A `503` with `Retry-After` means that nothing was applied, or that a repeat is safe. Send the same request again.

Two kinds of caller can decide. The application token of your institution carries the decision of the partner (`resolutionOrigin` is `PARTNER`). A person with the `transfers:decide` permission carries an operator decision (`resolutionOrigin` is `OPERATOR`) and must send a `justification` of 10 to 500 characters. The body carries the partner contract: `decision` (`ALLOW` or `DENY`), `analysisId`, and optional `reasons`.

The caller must be identified. A token that names neither a person nor an application gets `403` before anything is decided. The partner application needs `AUTH_M2M_INVERSION_ENABLED=true` on the service. Without it, its token passes without an identity.

This endpoint does not require the `X-Organization-Id` header.



## OpenAPI

````yaml /en/openapi/v3-current/ted.yaml post /v1/transfers/{evaluationKey}/fraud-decision
openapi: 3.0.3
info:
  title: Bank Transfer (TED) Plugin API
  description: >-
    Complete API for Brazilian bank transfers (TED OUT, TED IN, P2P) through the
    Lerian platform, including transfer initiation, processing, status tracking,
    cancellation, and returns.
  version: 3.8.0
servers:
  - url: https://api.example.com
    description: >-
      Replace the example host with the URL provided during environment
      onboarding.
security:
  - BearerAuth: []
  - OAuth2ClientCredentials:
      - api
  - OAuth2Password:
      - api
tags:
  - name: Transfers API
    description: >-
      Endpoints for initiating, processing, tracking, cancelling, and returning
      transfers.
  - name: Webhooks
    description: >-
      Endpoints for registering and managing tenant-scoped webhook subscriptions
      for transfer events.
  - name: Webhook DLQ
    description: Endpoints for inspecting and retrying webhook dead-letter queue messages.
paths:
  /v1/transfers/{evaluationKey}/fraud-decision:
    post:
      tags:
        - Transfers API
      summary: Decide Antifraud Analysis
      description: >-
        Use this endpoint to decide a transfer that waits in `FRAUD_ANALYSIS`.
        The antifraud partner of your institution calls it with its `/resolve`
        answer, or a person of your institution calls it.


        `evaluationKey` is the key that the partner received. It is the
        `transferId` for a TED OUT, a cross-core TED, and the payer end of a
        P2P. It is the `transferId` followed by `.in` for the recipient end of a
        P2P.


        - `DENY` rejects the transfer and releases its hold and its usage limit.

        - `ALLOW` resumes the transfer. It sends the TED OUT, sends the
        cross-core credit, or confirms the P2P hold. The `200` answer carries
        the status that the transfer is in. It is `FRAUD_ANALYSIS` again when
        the `ALLOW` of the payer end of a P2P opened the analysis of the
        recipient end.


        A received TED (TED IN) that the antifraud partner holds is decided here
        by the partner application alone, under its `transferId`. The call
        writes only the closing block of the check. The next re-drive credits
        the TED (`ALLOW`) or returns it with STR0010 code 9 (`DENY`). A person
        decides a received TED on [Decide TED IN Held by
        Antifraud](/en/reference/interfaces/ted-jd/decide-ted-in-held-by-antifraud)
        and gets `403` here. A received cross-core credit is never decided: the
        first answer of the partner is final, so the partner gets `409` and a
        person gets `403`. The partner always gets `409` for a TED IN that it
        did not answer, and `503` while its evaluation has no answer recorded
        yet.


        The first final decision wins, from whoever sends it. A second decision
        gets `409`. So does a decision for another `analysisId` or another end
        than the pending one, and a decision after `decideBy`. A `503` with
        `Retry-After` means that nothing was applied, or that a repeat is safe.
        Send the same request again.


        Two kinds of caller can decide. The application token of your
        institution carries the decision of the partner (`resolutionOrigin` is
        `PARTNER`). A person with the `transfers:decide` permission carries an
        operator decision (`resolutionOrigin` is `OPERATOR`) and must send a
        `justification` of 10 to 500 characters. The body carries the partner
        contract: `decision` (`ALLOW` or `DENY`), `analysisId`, and optional
        `reasons`.


        The caller must be identified. A token that names neither a person nor
        an application gets `403` before anything is decided. The partner
        application needs `AUTH_M2M_INVERSION_ENABLED=true` on the service.
        Without it, its token passes without an identity.


        This endpoint does not require the `X-Organization-Id` header.
      operationId: decideAntifraudAnalysis
      parameters:
        - name: X-Idempotency
          in: header
          required: true
          description: >-
            The key of the decision, `analysisId:decision`, as the partner sends
            it. This route does not fence the key. The status of the transfer is
            the durable check, so a repeat reaches the decision and answers what
            it finds.
          schema:
            type: string
            maxLength: 255
            pattern: ^[\x21-\x7E]{1,255}$
        - name: evaluationKey
          in: path
          required: true
          description: >-
            The evaluation key of the partner. It is the `transferId`, or the
            `transferId` followed by `.in`.
          schema:
            type: string
      requestBody:
        required: true
        description: >-
          The decision, the `analysisId`, and optional reasons. A person also
          sends `justification`, which the route ignores from the partner
          application.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FraudDecisionRequest'
      responses:
        '200':
          description: >-
            Indicates that the decision was applied, or that it was already
            applied and the repeat found it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FraudDecisionResponse'
        '400':
          description: 'BTF-0001: `X-Idempotency` is missing or malformed.'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            BTF-0405: the caller lacks the `transfers:decide` permission, the
            token names neither a person nor an application, or a person decides
            a received TED here. A person decides an STR TED on the desk route,
            and a cross-core credit is never decided.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
        '404':
          description: >-
            BTF-0200: the transfer does not exist, or `evaluationKey` is neither
            of the two forms.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
        '409':
          description: >-
            BTF-0128: the transfer is not open for this decision. It is already
            final, it waits on another end or another `analysisId`, or its
            decision time has passed. The detail says which.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
        '422':
          description: >-
            BTF-0129: a `decision` other than `ALLOW` or `DENY`, an invalid
            `analysisId`, or an operator decision without a `justification` of
            10 to 500 characters.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
        '500':
          description: >-
            BTF-9000: the outcome is unknown. Send the decision again. The
            answer tells what the transfer became.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
        '503':
          description: >-
            BTF-0130: the decision is not applied yet, and repeating it is safe.
            `Retry-After` says when.
          headers:
            Retry-After:
              $ref: '#/components/headers/RetryAfter'
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
components:
  schemas:
    FraudDecisionRequest:
      type: object
      required:
        - analysisId
        - decision
      properties:
        analysisId:
          type: string
          description: >-
            The identifier of the analysis that the decision closes. It must be
            the pending one.
          example: an-8f31c2
        decision:
          type: string
          enum:
            - ALLOW
            - DENY
          example: ALLOW
        justification:
          type: string
          minLength: 10
          maxLength: 500
          description: >-
            The reason of the person. Required from a person, and ignored from
            the partner application.
          example: Confirmed with the account holder by phone
        reasons:
          type: array
          description: The reasons of the partner, as it sends them.
          items:
            $ref: '#/components/schemas/FraudCheckReason'
    FraudDecisionResponse:
      type: object
      properties:
        transferId:
          type: string
          format: uuid
          example: 770e8400-e29b-41d4-a716-446655440003
        status:
          allOf:
            - $ref: '#/components/schemas/TransferStatus'
          description: The status that the transfer is in after the decision.
          example: PROCESSING
        ledgerGroupId:
          type: string
          description: >-
            The ledger group of a P2P between two ledgers. Absent on every other
            transfer.
        recipientLedgerId:
          type: string
          format: uuid
          description: >-
            The recipient's Midaz ledger on a P2P between two ledgers of one
            organization. Absent on every other transfer.
    ProblemDocument:
      type: object
      description: >-
        The RFC 9457 problem document that the service answers every error with,
        on `application/problem+json`. Route-specific members (for example
        `refusalCode`, `transactionId`, `ledgerStatus`, `systemplaneKey`) appear
        flat at the top level beside these.
      additionalProperties: true
      required:
        - type
        - title
        - status
        - detail
        - code
        - requestId
        - service
        - category
      properties:
        type:
          type: string
          description: >-
            A URI that names the error code:
            `https://errors.lerian.studio/v1/<code>`.
          example: https://errors.lerian.studio/v1/BTF-0200
        title:
          type: string
          description: The HTTP status text.
          example: Not Found
        status:
          type: integer
          description: The HTTP status code.
          example: 404
        detail:
          type: string
          description: A human-readable explanation of this occurrence.
          example: transfer not found
        instance:
          type: string
          description: The trace ID of this request, when one was recorded.
          example: 4bf92f3577b34da6a3ce929d0e0e4736
        errors:
          type: array
          description: Each rejected field. Present on field validation errors only.
          items:
            type: object
            properties:
              message:
                type: string
                description: Why the value was rejected.
                example: transferId must be a valid UUID
              location:
                type: string
                description: 'Where the value sits: `body.<field>` or `query.<field>`.'
                example: body.senderAccountId
        code:
          type: string
          description: The stable BTF error code.
          example: BTF-0200
        upstream:
          type: object
          description: >-
            The error that an upstream provider (JD SPB, Midaz) reported. Absent
            unless surfaced.
          properties:
            code:
              type: string
              description: The provider's own error code, verbatim.
              example: AAC90
            message:
              type: string
              description: The provider's own error message, bounded.
              example: Assinatura invalida
        requestId:
          type: string
          description: The request correlation ID. Present even when empty.
          example: 6d3e2a68-1f2b-4c3d-9e4f-5a6b7c8d9e0f
        service:
          type: string
          description: The system that produced the error.
          example: plugin
        category:
          type: string
          description: The machine-readable error category.
          example: deterministic
    FraudCheckReason:
      type: object
      properties:
        code:
          type: string
          example: VELOCITY
        description:
          type: string
          example: Several transfers to a new recipient in a short time.
    TransferStatus:
      type: string
      enum:
        - CREATED
        - FRAUD_ANALYSIS
        - PENDING
        - PROCESSING
        - COMPLETED
        - REJECTED
        - FAILED
        - CANCELLED
        - RECEIVED
      description: >-
        The current status of the transfer. For TED OUT: CREATED → PENDING →
        PROCESSING → COMPLETED, REJECTED, or FAILED. With the antifraud check of
        your institution on, a TED OUT goes through FRAUD_ANALYSIS before
        PENDING: the amount is held, and nothing is sent to JD in that status. A
        TED OUT in FRAUD_ANALYSIS ends PENDING when the check allows it,
        REJECTED when the check rejects it or `decideBy` passes, or CANCELLED. A
        cross-core TED and a P2P can also wait in FRAUD_ANALYSIS. For P2P:
        CREATED → PROCESSING → COMPLETED or FAILED (PENDING is an SPB-specific
        state and does not apply to P2P). A TED OUT can be CANCELLED while in
        CREATED, FRAUD_ANALYSIS, or PENDING status, and a cross-core TED or a
        P2P only in FRAUD_ANALYSIS. For TED IN: RECEIVED → PROCESSING →
        COMPLETED or FAILED. A COMPLETED TED IN can also transition to FAILED in
        the event of a chargeback.
      example: COMPLETED
  responses:
    Unauthorized:
      description: Indicates that the request is missing a valid authentication token.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ProblemDocument'
          examples:
            unauthorized:
              summary: Missing authorization
              value:
                type: https://errors.lerian.studio/v1/BTF-0401
                title: Unauthorized
                status: 401
                detail: Missing Token
                code: BTF-0401
                category: plugin
                requestId: 6d3e2a68-1f2b-4c3d-9e4f-5a6b7c8d9e0f
                service: plugin
    RateLimitExceeded:
      description: >-
        Indicates that the rate limit has been exceeded. Retry after the number
        of seconds specified in the Retry-After header.
      headers:
        Retry-After:
          description: Seconds until rate limit resets
          schema:
            type: integer
            example: 60
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ProblemDocument'
          examples:
            rateLimitExceeded:
              summary: Too many requests
              value:
                type: https://errors.lerian.studio/v1/BTF-0429
                title: Too Many Requests
                status: 429
                detail: Rate limit exceeded
                code: BTF-0429
                category: rate_limit
                requestId: 6d3e2a68-1f2b-4c3d-9e4f-5a6b7c8d9e0f
                service: plugin
              description: >
                Rate-limit responses use the dedicated `BTF-0429` code with the
                `rate_limit` category. Clients should back off using the HTTP
                status `429` and the `Retry-After` header.
  headers:
    RetryAfter:
      description: The number of seconds to wait before you send the request again.
      schema:
        type: integer
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Bearer token authentication. The tenantId is derived from the bearer
        token or authenticated request context and is not supplied through
        X-Organization-Id.
    OAuth2ClientCredentials:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /v1/login/oauth/access_token
          scopes:
            api: TED transfer API access
    OAuth2Password:
      type: oauth2
      flows:
        password:
          tokenUrl: /v1/login/oauth/access_token
          scopes:
            api: TED transfer API access

````

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