> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fastpaybrasil.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Request a refund

> Requests a **full refund** (estorno) for a charge that has `paid` status.
Partial refunds are not supported — the entire charge amount is reversed.

Works for both PIX and credit card payment methods.

On success the charge status transitions to `refunded` and the
`charge.refunded` webhook event is fired to all configured endpoints
and the charge's `postbackUrl` (if set).



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/refunds
openapi: 3.0.0
info:
  title: FastPay API
  version: 1.0.0
  description: >-
    API for creating and managing payment charges.


    ## Authentication


    This API uses **Basic Authentication** for direct API access, such as
    creating charges.

    Use your API key as the username and an empty string as password.

    The header should be formatted as:


    `Authorization: Basic {base64(apiKey:)}`.


    For example:


    ```

    Authorization: Basic YWxleG91dG9uOiIi

    ```


    ## Webhooks


    FastPay sends webhooks to notify your application about charge status
    changes in real-time.

    Webhooks are sent via HTTP POST requests to your configured webhook
    endpoints.


    ### Webhook Events


    The following webhook events are available for charges:


    - `charge.created` - Sent when a new charge is created

    - `charge.pending` - Sent when a charge is pending payment

    - `charge.paid` - Sent when a charge is successfully paid

    - `charge.updated` - Sent when a charge is updated


    ### Webhook Payload Structure


    All webhook payloads follow this structure:


    ```json

    {
      "id": "webhook_event_id",
      "event": "charge.paid",
      "data": {
        // Complete charge object
      }
    }

    ```


    ### Webhook Delivery


    - Webhooks are sent via HTTP POST requests

    - Content-Type: `application/json`

    - Retry logic is implemented for failed deliveries

    - Webhook events are stored in the database for audit purposes

    - Delivery logs are maintained for debugging and monitoring


    ### Webhook Security


    - Webhooks are sent to pre-configured endpoints

    - Endpoints can be enabled/disabled per merchant

    - Event filtering is supported (only receive specific events)

    - Failed deliveries are retried with exponential backoff
servers:
  - url: https://api-global.fastpaybrasil.com
    description: Produção e Sandbox (diferenciados pela API key)
security: []
paths:
  /v1/refunds:
    post:
      tags:
        - Charges
      summary: Request a refund
      description: >-
        Requests a **full refund** (estorno) for a charge that has `paid`
        status.

        Partial refunds are not supported — the entire charge amount is
        reversed.


        Works for both PIX and credit card payment methods.


        On success the charge status transitions to `refunded` and the

        `charge.refunded` webhook event is fired to all configured endpoints

        and the charge's `postbackUrl` (if set).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - chargeId
                - reason
              properties:
                chargeId:
                  type: string
                  description: ID of the charge to refund. Must be in `paid` status.
                  example: 2vorkDcXyvzifL63YX09S9VqcnI
                reason:
                  type: string
                  description: Reason for the refund.
                  example: Customer requested cancellation
      responses:
        '201':
          description: Refund requested successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefundResponse'
        '401':
          description: Unauthorized - invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Charge not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable Entity - charge is not in paid status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - basic: []
components:
  schemas:
    RefundResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - refunded
            - pending
            - refused
            - failed
          description: Result status of the refund operation
          example: refunded
        reason:
          type: string
          nullable: true
          description: Reason from the PSP (null if not provided)
          example: null
        pspRefundRefId:
          type: string
          nullable: true
          description: PSP reference ID for the refund transaction
          example: ref_abc123
    ErrorResponse:
      type: object
      properties:
        statusCode:
          type: integer
          description: HTTP status code
          example: 422
        message:
          type: string
          description: Descriptive error message
          example: SubMerchant is not active
        error:
          type: string
          description: Error type
          example: Unprocessable Entity
  securitySchemes:
    basic:
      type: http
      scheme: basic
      description: |-
        HTTP Basic authentication. Use your secret key as the
        username and an empty string as password. The API key
        should be base64 encoded in the format 'username:' when
        sending the Authorization header.

````