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

# Refund a flagged payment

> Returns a `high_risk` payment with no verification of the payer: to the address it was sent from, or to `refund_address` when given. The network fee is deducted from the refunded amount. The invoice moves to `refunding`, then `refunded` once the transaction is on chain. Errors: `REFUND_UNAVAILABLE` (403) when this payment can only be refunded through compliance (aml@pawpayments.com), `REFUND_EXPIRED` (403) after the 30-day window, `REFUND_ADDRESS_NOT_ALLOWED` (403) for an address that may not receive it (use another one or the sending address), `INVALID_ADDRESS` (400), `PAYOUTS_DISABLED` (403) when `refund_address` is not the sender and the request does not come from a whitelisted IP (the same rule as payouts), `REFUND_RETRY_LATER` (503), `INVALID_STATUS`, `REFUND_IN_PROGRESS` and `ALREADY_REFUNDED` (409).



## OpenAPI

````yaml /api-reference/openapi.json post /api/v2/invoices/{invoice_id}/refund
openapi: 3.1.0
info:
  title: PawPayments API
  description: >-
    Public REST API for the PawPayments crypto payment gateway.


    All `/api/v2/*` endpoints require an `x-api-key` header issued in the
    merchant dashboard. Responses are wrapped in `{"ok": true, "result": ...}`
    on success and `{"ok": false, "error": {code, message, details?}}` on
    failure.
  version: 2.0.0
servers:
  - url: https://api.pawpayments.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Catalog
  - name: Merchant
  - name: Invoices
  - name: Sandbox
  - name: Payouts
  - name: Notifications
  - name: Permanent addresses
paths:
  /api/v2/invoices/{invoice_id}/refund:
    post:
      tags:
        - Invoices
      summary: Refund a flagged payment
      description: >-
        Returns a `high_risk` payment with no verification of the payer: to the
        address it was sent from, or to `refund_address` when given. The network
        fee is deducted from the refunded amount. The invoice moves to
        `refunding`, then `refunded` once the transaction is on chain. Errors:
        `REFUND_UNAVAILABLE` (403) when this payment can only be refunded
        through compliance (aml@pawpayments.com), `REFUND_EXPIRED` (403) after
        the 30-day window, `REFUND_ADDRESS_NOT_ALLOWED` (403) for an address
        that may not receive it (use another one or the sending address),
        `INVALID_ADDRESS` (400), `PAYOUTS_DISABLED` (403) when `refund_address`
        is not the sender and the request does not come from a whitelisted IP
        (the same rule as payouts), `REFUND_RETRY_LATER` (503),
        `INVALID_STATUS`, `REFUND_IN_PROGRESS` and `ALREADY_REFUNDED` (409).
      operationId: post__api_v2_invoices_{invoice_id}_refund
      parameters:
        - name: invoice_id
          in: path
          required: true
          schema:
            type: string
          description: Unique 24-character hex invoice id.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DirectRefundV2.a1ea1bf'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectRefundEnvelope.d4a12ff'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope.d4a12ff'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope.d4a12ff'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope.d4a12ff'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope.d4a12ff'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope.d4a12ff'
        '422':
          description: Unprocessable Content
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope.d4a12ff'
components:
  schemas:
    DirectRefundV2.a1ea1bf:
      description: Body of `POST /api/v2/invoices/{invoice_id}/refund` (may be empty).
      properties:
        refund_address:
          anyOf:
            - maxLength: 256
              type: string
            - type: 'null'
          default: null
          description: >-
            Where to send the refund, on the payment's network. Omit it to
            return the funds to the address the payment came from.
          title: Refund Address
      title: DirectRefundV2
      type: object
    DirectRefundEnvelope.d4a12ff:
      properties:
        ok:
          const: true
          title: Ok
          type: boolean
        result:
          $ref: '#/components/schemas/DirectRefundEnvelope.d4a12ff.DirectRefund'
      required:
        - ok
        - result
      title: DirectRefundEnvelope
      type: object
    ErrorEnvelope.d4a12ff:
      example:
        error:
          code: VALIDATION_ERROR
          details:
            - field: amount
              message: Field required
          message: Validation failed
        ok: false
      properties:
        ok:
          const: false
          title: Ok
          type: boolean
        error:
          $ref: '#/components/schemas/ErrorEnvelope.d4a12ff.ErrorBody'
      required:
        - ok
        - error
      title: ErrorEnvelope
      type: object
    DirectRefundEnvelope.d4a12ff.DirectRefund:
      example:
        refund_address: TJRyWwFs9wTFGZg3JbrVriFbNfCug5tDeC
        status: refunding
      properties:
        status:
          const: refunding
          description: >-
            The refund is accepted and being sent; the invoice moves to
            `refunding`, then `refunded` once the transaction is on chain.
          title: Status
          type: string
        refund_address:
          description: >-
            Where the funds are sent: the `refund_address` you asked for, or the
            address the payment came from.
          title: Refund Address
          type: string
      required:
        - status
        - refund_address
      title: DirectRefund
      type: object
    ErrorEnvelope.d4a12ff.ErrorBody:
      properties:
        code:
          description: Machine-readable error code (e.g. NOT_FOUND, VALIDATION_ERROR).
          title: Code
          type: string
        message:
          title: Message
          type: string
        details:
          anyOf:
            - {}
            - type: 'null'
          default: null
          description: >-
            Optional context. For VALIDATION_ERROR contains a list of {field,
            message}.
          title: Details
      required:
        - code
        - message
      title: ErrorBody
      type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: x-api-key
      in: header

````

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