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

# Refund a payment

> Refunds a sale by its payment id, whichever way it was charged. The same rules as the other refund endpoints apply: the same day the sale was approved (until 22:30 Mexico City time, 22:00 for American Express), never a meses sin intereses sale with installments already collected, and keeping Compago's fee when your refund terms say so.



## OpenAPI

````yaml POST /developer/v1/refund
openapi: 3.1.0
info:
  title: Compago API
  version: 1.0.0
  description: >-
    Public and private API endpoints for Compago's payment infrastructure. This
    specification currently includes endpoints for one-time payments. More
    endpoints will be added as the platform evolves.
servers:
  - url: https://demo-api-harmony.compago.com/api
  - url: https://api-harmony.compago.com/api
security: []
tags:
  - name: OneTimePayment
    description: Endpoints for creating and processing one-time payment links
  - name: PaymentMethod
    description: >-
      Endpoints for saving cards, charging saved payment methods, holding and
      capturing funds, and processing refunds
  - name: PaymentIntent
    description: >-
      Endpoints for creating and managing card-present payment intents for POS
      terminal integrations
  - name: Payments
    description: Read the payments your organization has taken
  - name: Subscriptions
    description: Read and manage recurring billing agreements
  - name: PaymentLinks
    description: Create, edit and retire hosted checkout links
  - name: Products
    description: Manage the catalogue behind product-based payment links
  - name: Promotions
    description: Read the promotions your organization funds or benefits from
  - name: Salespeople
    description: Read the point-of-sale operators in your organization
  - name: Organization
    description: Read your organization profile and its members
  - name: SavedCards
    description: Read saved payment methods and their payments
  - name: Payouts
    description: >-
      Read the transfers Compago sent to your bank accounts and what each one
      paid
  - name: Events
    description: >-
      Read the webhook events of the last 30 days, to reconcile after your
      endpoint was down
  - name: ApiKeys
    description: Manage your organization's API keys with a key that holds `apiKey:write`.
paths:
  /developer/v1/refund:
    post:
      tags:
        - Refunds
      summary: Refund a payment
      description: >-
        Refunds a sale by its payment id, whichever way it was charged. The same
        rules as the other refund endpoints apply: the same day the sale was
        approved (until 22:30 Mexico City time, 22:00 for American Express),
        never a meses sin intereses sale with installments already collected,
        and keeping Compago's fee when your refund terms say so.
      operationId: createPublicRefund
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateV1RefundRequest'
      responses:
        '201':
          description: Refunded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1Refund'
        '400':
          description: >-
            Not refundable: `NOT_REFUNDABLE` (the sale was not approved),
            `REFUND_INSTALLMENTS_COLLECTED`, `REFUND_WINDOW_EXPIRED`,
            `PARTIAL_REFUND_NOT_SUPPORTED`, or a body that failed validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '401':
          description: Unauthorized. The `x-api-key` header is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '403':
          description: >-
            Forbidden. The key is not bound to an organization, or the
            organization is not a merchant.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '404':
          description: Not found, or the payment belongs to another organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '409':
          description: >-
            `ALREADY_REFUNDED`, `REFUND_FEE_NOT_COVERED` (what you have pending
            to settle does not cover Compago's fee), or
            `REFUND_THROUGH_INTEGRATION` (a store integration such as Shopify
            charged it: refund it there).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
        '429':
          description: Too many requests. See Rate limits.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateV1RefundRequest:
      type: object
      properties:
        paymentId:
          type: string
          format: uuid
          description: >-
            The sale to refund: any payment of your organization, whichever way
            it was charged (payment link, one-time payment, terminal, saved
            card).
        amount:
          type: number
          exclusiveMinimum: 0
          example: 1150
          description: >-
            Optional. What to give back. Today every sale is refunded in full:
            send the payment's `chargedAmount` or omit the field. Any other
            amount is refused with `PARTIAL_REFUND_NOT_SUPPORTED`.
      required:
        - paymentId
    V1Refund:
      type: object
      description: >-
        A refund of a sale. Today a refund always gives back the whole charge
        (the sale and its tip).
      required:
        - id
        - object
        - paymentId
        - amount
        - currency
        - status
        - failureReason
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
        object:
          type: string
          enum:
            - refund
        paymentId:
          type: string
          format: uuid
          description: The sale refunded, as `GET /developer/v1/payment/{id}` reads it.
        amount:
          type: number
          example: 1150
          description: What went back to the customer, in MXN.
        currency:
          type: string
          example: MXN
          enum:
            - MXN
        status:
          type: string
          enum:
            - PENDING
            - SUCCEEDED
            - FAILED
          description: >-
            `SUCCEEDED` once the bank accepted it. `PENDING` while a bank
            transfer refund (SPEI) is on its way, `FAILED` if the bank refused
            it.
        failureReason:
          type:
            - string
            - 'null'
          enum:
            - DECLINED
            - RETURN_FAILED
            - null
          description: >-
            Why the refund failed: `DECLINED` when the bank declined the card
            refund, `RETURN_FAILED` when a transfer could not be sent back to
            the account it came from. `null` otherwise.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    PublicError:
      type: object
      properties:
        message:
          type: string
          description: Human-readable description.
        code:
          type: string
          description: Stable machine-readable code. Branch on this, not on `message`.
      required:
        - message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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