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

# Analyze a MED infraction

> Records the counterparty PSP's analysis result (JDPI relato-infracao/analisar, contract §2.4). The §2.4 invariants (resultadoAnalise {0=Aceita,1=Rejeitada}, tpFraude {0..4} required when Aceita) are validated before any JDPI call. Persists the JDPI response entity (the advanced watermark + minted idMarcacaoFraude) and returns it.



## OpenAPI

````yaml /en/openapi/v3-current/pix.yaml post /v1/med/infractions/{idRelatoInfracao}/analyze
openapi: 3.1.0
info:
  description: Brazilian PIX Direct (DICT + SPI) plugin API.
  title: plugin-br-pix-jd
  version: 1.0.0
servers: []
security:
  - BearerAuth: []
paths:
  /v1/med/infractions/{idRelatoInfracao}/analyze:
    post:
      tags:
        - MED Infractions
      summary: Analyze a MED infraction
      description: >-
        Records the counterparty PSP's analysis result (JDPI
        relato-infracao/analisar, contract §2.4). The §2.4 invariants
        (resultadoAnalise {0=Aceita,1=Rejeitada}, tpFraude {0..4} required when
        Aceita) are validated before any JDPI call. Persists the JDPI response
        entity (the advanced watermark + minted idMarcacaoFraude) and returns
        it.
      operationId: analyzeMedInfraction
      parameters:
        - description: The infraction GUID.
          in: path
          name: idRelatoInfracao
          required: true
          schema:
            description: The infraction GUID.
            examples:
              - a1b2c3d4-e5f6-7890-abcd-ef1234567890
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyzeInfractionRequestBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InfractionView'
          description: OK
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
components:
  schemas:
    AnalyzeInfractionRequestBody:
      additionalProperties: false
      properties:
        detalhesAnalise:
          description: Analysis detail.
          examples:
            - Confirmed fraud.
          type: string
        idempotencyKey:
          description: >-
            Client-supplied idempotency key: any stable business string. The
            plugin projects it deterministically into the GUID form JDPI
            requires (contract 6), so the same value always dedups against the
            same JDPI request and the raw value is never sent verbatim.
          examples:
            - med-infraction-analyze-2024-0001
          type: string
        resultadoAnalise:
          description: Infraction analysis result (0=Aceita, 1=Rejeitada).
          examples:
            - 0
          format: int64
          type: integer
        tpFraude:
          description: Fraud-type code (0..4); required when resultadoAnalise=0 (Aceita).
          examples:
            - 1
          format: int64
          type: integer
      required:
        - resultadoAnalise
        - idempotencyKey
      type: object
    InfractionView:
      additionalProperties: false
      properties:
        detalhes:
          description: Free-text detail to help the recebedor analyse.
          examples:
            - Suspected scam.
          type: string
        detalhesAnalise:
          description: Analysis detail.
          examples:
            - Confirmed.
          type: string
        dtHrCriacao:
          description: JDPI creation timestamp (RFC 3339 UTC).
          examples:
            - '2024-01-01T12:00:00.000Z'
          type: string
        dtHrUltModificacao:
          description: >-
            JDPI last-modification timestamp (RFC 3339 UTC) — the poll
            watermark.
          examples:
            - '2024-01-01T12:05:00.000Z'
          type: string
        endToEndId:
          description: EndToEndId of the suspect payment.
          examples:
            - E1234567820240101000000000000001
          type: string
        idMarcacaoFraude:
          description: Fraud-marker GUID, when analysis produced one.
          examples:
            - c3d4e5f6-a7b8-9012-cdef-345678901234
          type: string
        idRecValores:
          description: Value-recovery GUID, when the infraction came from a recovery.
          examples:
            - b2c3d4e5-f6a7-8901-bcde-f23456789012
          type: string
        idRelatoInfracao:
          description: Infraction GUID (the natural key).
          examples:
            - a1b2c3d4-e5f6-7890-abcd-ef1234567890
          type: string
        motivo:
          description: >-
            Infraction motivo code (1=Solicitacao de devolucao, 2=Cancelamento
            da devolucao).
          examples:
            - 1
          format: int64
          type: integer
        motivoDescription:
          description: Human-readable infraction motivo label.
          examples:
            - Solicitacao de devolucao
          type: string
        pspContraParte:
          description: ISPB of the counterparty.
          examples:
            - '87654321'
          type: string
        pspCriador:
          description: ISPB of the infraction creator.
          examples:
            - '12345678'
          type: string
        resultadoAnalise:
          description: >-
            Infraction analysis result (0=Aceita, 1=Rejeitada); null until
            analysed.
          examples:
            - 0
          format: int64
          type: integer
        resultadoAnaliseDescription:
          description: Human-readable infraction analysis-result label.
          examples:
            - Aceita
          type: string
        status:
          description: >-
            stRelatoInfracao lifecycle code (0=Aberto, 1=Recebido, 2=Cancelado,
            3=Analisado).
          examples:
            - 0
          format: int64
          type: integer
        statusDescription:
          description: Human-readable stRelatoInfracao label.
          examples:
            - Aberto
          type: string
        tpSitOrigem:
          description: Situation-origin code (0..5).
          examples:
            - 0
          format: int64
          type: integer
        tpSitOrigemDescription:
          description: Human-readable tpSitOrigem label.
          examples:
            - Golpe/Estelionato
          type: string
        vlrInfracao:
          description: Amount to block on the account, in centavos; null when absent.
          examples:
            - 15000
          format: int64
          type: integer
      required:
        - idRelatoInfracao
        - endToEndId
        - motivo
        - motivoDescription
        - tpSitOrigem
        - tpSitOrigemDescription
        - status
        - statusDescription
        - pspCriador
        - pspContraParte
        - dtHrCriacao
        - dtHrUltModificacao
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          examples:
            - ERR-0001
          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
    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: The value at the given location
      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
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````