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

# Refund Sale

> Marks an existing sale as refunded when it is still eligible to be refunded. If the sale has already been refunded, the endpoint still returns a successful response indicating that state.



## OpenAPI

````yaml PATCH /sales
openapi: 3.0.1
info:
  title: Referly API
  description: API for managing affiliates, referrals, and sales for SaaS businesses
  version: 1.0.0
servers:
  - url: https://www.referly.so/api/v1
security:
  - bearerAuth: []
paths:
  /sales:
    patch:
      summary: Mark a sale as refunded
      description: >-
        Marks an existing sale as refunded when it is still eligible to be
        refunded. If the sale has already been refunded, the endpoint still
        returns a successful response indicating that state.
      requestBody:
        description: Sale refund details
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SaleRefund'
        required: true
      responses:
        '200':
          description: Sale refund status processed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SaleRefundResponse'
        '400':
          description: Sale cannot be marked as refunded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SaleRefundError'
        '404':
          description: Sale not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SaleRefundError'
components:
  schemas:
    SaleRefund:
      type: object
      required:
        - saleId
      properties:
        saleId:
          type: integer
          description: The sale ID to mark as refunded
    SaleRefundResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the refund request was handled successfully
        alreadyRefunded:
          type: boolean
          description: >-
            Whether the sale had already been marked as refunded before this
            request
        reason:
          type: string
          description: Result reason, such as refunded or already_refunded
    SaleRefundError:
      type: object
      properties:
        error:
          type: string
          description: error message
        reason:
          type: string
          description: error reason
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````