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

# Write Antifraud Partner Credentials

> Replaces the whole credential bundle that TED JD uses on the calls to the antifraud partner of one flow. The body is `{"credentials": {...}}`. The bundle accepts `secret` (required), `certPem` and `keyPem` (both or neither), and `header.<Name>`. TED JD refuses any other key. When the route of the flow uses `hmac-v1`, the `secret` must have at least 32 characters. A `204` answer has no body, and no answer returns a credential value.

TED JD writes nothing when it refuses the bundle with `AFC-0001`. After `AFC-0003`, the write may have landed, so read the status before you write again.

In BYOC, this operation exists only when `PLUGIN_AUTH_ENABLED` is `true`, `ANTIFRAUD_SECRETS_BACKEND` is set, and TED JD read the runtime settings at startup. Otherwise the path answers `404`. The caller needs the `antifraud_credentials:write` permission, which the `editor` role holds. A person or an application that holds the permission can call it. TED JD authorizes the application with its own permissions, whatever the value of `AUTH_M2M_INVERSION_ENABLED`.

The answers `AFC-0001` to `AFC-0004` are not problem documents. Their body holds `code` (the HTTP status), `title` (the error code) and `message`. The `401` and `403` answers, and the `503` answer with `BTF-0402`, are problem documents. This endpoint does not require the `X-Organization-Id` header.



## OpenAPI

````yaml /es/openapi/v3-current/ted.yaml put /v1/external-credentials/{target}
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.9.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.
  - name: Antifraud Credentials
    description: >-
      Write the credential bundle of an antifraud partner flow and read its
      status.
paths:
  /v1/external-credentials/{target}:
    put:
      tags:
        - Antifraud Credentials
      summary: Write Antifraud Partner Credentials
      description: >-
        Replaces the whole credential bundle that TED JD uses on the calls to
        the antifraud partner of one flow. The body is `{"credentials": {...}}`.
        The bundle accepts `secret` (required), `certPem` and `keyPem` (both or
        neither), and `header.<Name>`. TED JD refuses any other key. When the
        route of the flow uses `hmac-v1`, the `secret` must have at least 32
        characters. A `204` answer has no body, and no answer returns a
        credential value.


        TED JD writes nothing when it refuses the bundle with `AFC-0001`. After
        `AFC-0003`, the write may have landed, so read the status before you
        write again.


        In BYOC, this operation exists only when `PLUGIN_AUTH_ENABLED` is
        `true`, `ANTIFRAUD_SECRETS_BACKEND` is set, and TED JD read the runtime
        settings at startup. Otherwise the path answers `404`. The caller needs
        the `antifraud_credentials:write` permission, which the `editor` role
        holds. A person or an application that holds the permission can call it.
        TED JD authorizes the application with its own permissions, whatever the
        value of `AUTH_M2M_INVERSION_ENABLED`.


        The answers `AFC-0001` to `AFC-0004` are not problem documents. Their
        body holds `code` (the HTTP status), `title` (the error code) and
        `message`. The `401` and `403` answers, and the `503` answer with
        `BTF-0402`, are problem documents. This endpoint does not require the
        `X-Organization-Id` header.
      operationId: putAntifraudCredentials
      parameters:
        - $ref: '#/components/parameters/AntifraudCredentialTarget'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AntifraudCredentialsRequest'
            example:
              credentials:
                secret: replace-with-the-secret-of-the-partner
      responses:
        '204':
          description: TED JD replaced the bundle. The answer has no body.
        '400':
          description: >-
            `AFC-0001`: TED JD refused the body or the bundle, and wrote
            nothing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AntifraudCredentialError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: >-
            `AFC-0002`: the write did not complete, for example because another
            write is in progress. Send the bundle again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AntifraudCredentialError'
        '500':
          description: >-
            `AFC-0004`: the secret manager refuses TED JD, or the stored value
            is not a JSON object of strings.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AntifraudCredentialError'
        '503':
          description: >-
            `AFC-0003`: the secret manager or the runtime settings did not
            answer, and the write may have landed. `BTF-0402`: the Access
            Manager did not answer, and this answer is a problem document.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AntifraudCredentialError'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDocument'
components:
  parameters:
    AntifraudCredentialTarget:
      name: target
      in: path
      required: true
      description: >-
        The flow of the credential bundle: `antifraud-out`,
        `antifraud-intra-out`, `antifraud-intra-in` or `antifraud-in`.
      schema:
        type: string
        enum:
          - antifraud-out
          - antifraud-intra-out
          - antifraud-intra-in
          - antifraud-in
  schemas:
    AntifraudCredentialsRequest:
      type: object
      description: The credential bundle of one flow.
      required:
        - credentials
      properties:
        credentials:
          type: object
          description: The bundle, as a flat object of string values.
          additionalProperties:
            type: string
    AntifraudCredentialError:
      type: object
      description: >-
        The error body of the antifraud credential routes. It is not a problem
        document.
      properties:
        code:
          type: integer
          description: The HTTP status.
        title:
          type: string
          description: The error code.
          enum:
            - AFC-0001
            - AFC-0002
            - AFC-0003
            - AFC-0004
        message:
          type: string
          description: The reason, as text.
    ProblemDocument:
      type: object
      description: >-
        The RFC 9457 problem document that the service answers an error with, on
        `application/problem+json`. The `AFC-` answers of the antifraud
        credential routes use their own body. 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
  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
    Forbidden:
      description: >-
        Indicates that the caller is authenticated but lacks permission for this
        operation.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ProblemDocument'
          examples:
            permissionDenied:
              summary: Caller lacks permission
              value:
                type: https://errors.lerian.studio/v1/BTF-0405
                title: Forbidden
                status: 403
                detail: >-
                  the credential is not allowed to perform transfers:create on
                  this request
                code: BTF-0405
                category: plugin
                requestId: 6d3e2a68-1f2b-4c3d-9e4f-5a6b7c8d9e0f
                service: plugin
  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.