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

# Unblock a Pix Refund

> Use this endpoint to unblock a refund stuck in PROCESSING or PENDING status. The endpoint fetches the current reversal status from BTG and triggers the appropriate refund settlement flow if BTG shows the reversal has completed or failed; the optional request body field allowNotFoundUnblock (default false) opts into resolving a CASHOUT refund as FAILED when BTG reports the reversal absent (404), or an intra-PSP refund parked at CREATED that Midaz holds no transaction for (nothing reverted). An inter-PSP refund at CREATED is refused with 422 (PIX-0470): its Midaz debit may exist unrecorded, so an operator resolves it. A refund of an intra-PSP transfer, which BTG never holds, is settled on Midaz alone at CREATED, PENDING or PROCESSING, 65 minutes after its last write. A PENDING refund updated less than 150 seconds ago is also refused with 422 (PIX-0470): the create flow may still be sending it to BTG. The request body is intentionally an opaque raw-bytes payload (no typed schema): unknown fields are ignored, and an empty body is valid.



## OpenAPI

````yaml /pt/openapi/v3-current/indirect-pix.yaml post /v1/refunds/{refund_id}/unblock
openapi: 3.1.0
info:
  contact:
    email: contact@lerian.studio
    name: Lerian Studio
    url: https://lerian.studio
  description: >-
    API for Pix Indirect via BTG. It covers DICT keys and claims; MED infraction
    reports, fraud markers, refund requests, and funds recoveries; DICT
    statistics and reconciliation; Pix transfers, refunds, and schedules; static
    QR codes and QR code decoding; immediate and due-date collections; Pix
    Automático for the payer; transaction reports and TemposTransacoes
    statistics; and inbound and outbound webhook records.
  license:
    name: Lerian Studio General License
  title: Pix BTG API
  version: 1.14.0
servers:
  - url: https://api.example.com
    description: >-
      Replace the example host with the URL provided during environment
      onboarding.
security:
  - BearerAuth: []
paths:
  /v1/refunds/{refund_id}/unblock:
    post:
      tags:
        - Refunds
      summary: Unblock a Pix Refund
      description: >-
        Use this endpoint to unblock a refund stuck in PROCESSING or PENDING
        status. The endpoint fetches the current reversal status from BTG and
        triggers the appropriate refund settlement flow if BTG shows the
        reversal has completed or failed; the optional request body field
        allowNotFoundUnblock (default false) opts into resolving a CASHOUT
        refund as FAILED when BTG reports the reversal absent (404), or an
        intra-PSP refund parked at CREATED that Midaz holds no transaction for
        (nothing reverted). An inter-PSP refund at CREATED is refused with 422
        (PIX-0470): its Midaz debit may exist unrecorded, so an operator
        resolves it. A refund of an intra-PSP transfer, which BTG never holds,
        is settled on Midaz alone at CREATED, PENDING or PROCESSING, 65 minutes
        after its last write. A PENDING refund updated less than 150 seconds ago
        is also refused with 422 (PIX-0470): the create flow may still be
        sending it to BTG. The request body is intentionally an opaque raw-bytes
        payload (no typed schema): unknown fields are ignored, and an empty body
        is valid.
      operationId: payment-unblock-refund
      parameters:
        - description: Refund ID (UUID format)
          in: path
          name: refund_id
          required: true
          schema:
            description: Refund ID (UUID format)
            type: string
        - description: Unique identifier of the Midaz Ledger Account (UUID format)
          in: header
          name: X-Account-Id
          required: true
          schema:
            description: Unique identifier of the Midaz Ledger Account (UUID format)
            type: string
      requestBody:
        content:
          application/octet-stream:
            schema:
              contentMediaType: application/octet-stream
              format: binary
              type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnblockRefundOutput'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorBody'
          description: Bad Request
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorBody'
          description: Internal Server Error
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorBody'
          description: Error
components:
  schemas:
    UnblockRefundOutput:
      additionalProperties: false
      properties:
        btgStatus:
          description: Status retrieved from BTG (for transparency)
          examples:
            - CONFIRMED
          type: string
        message:
          description: Additional context about the unblock result
          examples:
            - Refund successfully unblocked.
          type: string
        refund:
          $ref: '#/components/schemas/RefundCashoutOutput'
          description: Updated refund details after the unblock attempt
      required:
        - refund
        - message
        - btgStatus
      type: object
    LegacyErrorBody:
      additionalProperties: false
      properties:
        code:
          type: string
        fields:
          additionalProperties:
            type: string
          type: object
        headers:
          additionalProperties:
            type: string
          type: object
        message:
          type: string
        paths:
          additionalProperties:
            type: string
          type: object
        queryParams:
          additionalProperties:
            type: string
          type: object
        raw:
          type: string
        title:
          type: string
      required:
        - code
        - title
        - message
      type: object
    RefundCashoutOutput:
      additionalProperties: false
      properties:
        accountId:
          examples:
            - 01989f9e-6508-79f8-9540-835be49fbd0d
          type: string
        amount:
          examples:
            - '100.50'
          type: string
        createdAt:
          examples:
            - '2024-01-15T10:30:00Z'
          type: string
        deletedAt:
          type: string
        description:
          examples:
            - Customer reported unauthorized transaction
          type: string
        id:
          examples:
            - 550e8400-e29b-41d4-a716-446655440001
          type: string
        ledger:
          $ref: '#/components/schemas/LedgerInfo'
        metadata:
          additionalProperties: {}
          type: object
        originalEndToEndId:
          examples:
            - E12345678202411241430ABCDEFGHIJK
          type: string
        returnEndToEndId:
          examples:
            - D3030629420200808185300887639654
          type: string
        status:
          enum:
            - CREATED
            - PENDING
            - PROCESSING
            - COMPLETED
            - REJECTED
            - FAILED
            - CANCELLED
          examples:
            - PENDING
          type: string
        type:
          enum:
            - CASHOUT
            - CASHIN
          examples:
            - CASHOUT
          type: string
        updatedAt:
          examples:
            - '2024-01-15T10:30:00Z'
          type: string
      required:
        - id
        - originalEndToEndId
        - returnEndToEndId
        - amount
        - status
        - type
        - accountId
        - createdAt
        - updatedAt
      type: object
    LedgerInfo:
      additionalProperties: false
      properties:
        destinationOperationId:
          examples:
            - 550e8400-e29b-41d4-a716-446655440013
          type: string
        revert:
          $ref: '#/components/schemas/LedgerRevertInfo'
        sourceOperationId:
          examples:
            - 550e8400-e29b-41d4-a716-446655440012
          type: string
        transactionId:
          examples:
            - 550e8400-e29b-41d4-a716-446655440011
          type: string
      type: object
    LedgerRevertInfo:
      additionalProperties: false
      properties:
        destinationOperationId:
          examples:
            - 550e8400-e29b-41d4-a716-446655440016
          type: string
        sourceOperationId:
          examples:
            - 550e8400-e29b-41d4-a716-446655440015
          type: string
        transactionId:
          examples:
            - 550e8400-e29b-41d4-a716-446655440014
          type: string
      type: object
  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.