For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HomeGuidesAPI Reference
HomeGuidesAPI Reference
  • Online API
    • API Environments
    • Direct Payment Flow
    • REST
    • HTTPS
    • Request Headers
    • Dates
    • Pagination
    • Authentication
    • Idempotent Requests
    • Timeouts
    • API Simulator
    • JavaScript afterpay.js
      • POSTCapture Payment
      • PUTUpdate Shipping Courier
      • GETGet Payment By Order ID
      • GETGet Payment By Token
      • GETList Payments
      • POSTCreate Refund
    • Errors
LogoLogo
Online APIPayments

Create Refund

POST
https://global-api-sandbox.afterpay.com/v1/payments/:orderId/refund
POST
/v1/payments/:orderId/refund
$curl -X POST https://global-api-sandbox.afterpay.com/v1/payments/orderId/refund \
> -H "User-Agent: User-Agent" \
> -H "Content-Type: application/json" \
> -u "<username>:<password>" \
> -d '{
> "amount": {
> "amount": "0.00",
> "currency": "GBP"
> }
>}'
This endpoint performs a full or partial refund. The refund operation is [idempotent](/v-1/idempotent-requests) if a unique `requestId` and `merchantReference` are provided. ## Successful Response (201) Returns a [Refund object](/v-1/refund-object) in response. All request parameters will be echoed in the response. In addition, the response includes the following: | Attribute | Type | Description | | :----------- | :----- | :--------------------------------------------------------------------------------------------------------------------------- | | `refundId` | string | The unique, permanent, Clearpay-generated Refund ID. | | `refundedAt` | string | The UTC timestamp of when the refund was completed, in [ISO 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format. | ## Connection Timeouts | Timeout | Time (Seconds) | | :------ | :------------- | | Open | 10 | | Read | 70 | ## Errors In addition to the [PUT/POST Errors](/v-1/put-post-errors) applicable to all POST endpoints, the following errors are specific to Create Refund: | HTTP Status Code | errorCode | Description | | :-- | :-- | :-- | | **412** <br />Precondition Failed | `precondition_failed` | The `orderId` is invalid, does not exist, or is not eligible for a refund. For example, the order was declined. | | **422** <br />Unprocessable Entity | `invalid_amount` | The `amount` requested exceeded the amount available. | | **422** <br />Unprocessable Entity | `unsupported_currency` | The currency of the refund does not match the currency of the order (and the Merchant account). |
Was this page helpful?
Previous

Errors

Next
Built with

This endpoint performs a full or partial refund.

The refund operation is idempotent if a unique requestId and merchantReference are provided.

Successful Response (201)

Returns a Refund object in response. All request parameters will be echoed in the response. In addition, the response includes the following:

AttributeTypeDescription
refundIdstringThe unique, permanent, Clearpay-generated Refund ID.
refundedAtstringThe UTC timestamp of when the refund was completed, in ISO 8601 format.

Connection Timeouts

TimeoutTime (Seconds)
Open10
Read70

Errors

In addition to the PUT/POST Errors applicable to all POST endpoints, the following errors are specific to Create Refund:

HTTP Status CodeerrorCodeDescription
412
Precondition Failed
precondition_failedThe orderId is invalid, does not exist, or is not eligible for a refund. For example, the order was declined.
422
Unprocessable Entity
invalid_amountThe amount requested exceeded the amount available.
422
Unprocessable Entity
unsupported_currencyThe currency of the refund does not match the currency of the order (and the Merchant account).

Authentication

AuthorizationBasic

Basic authentication of the form Basic <base64(username:password)>.

Path parameters

orderIdstringRequired
The unique Clearpay Order ID to apply the refund to.

Headers

User-AgentstringRequired
AcceptstringOptionalDefaults to application/json

Request

This endpoint expects an object.
amountobjectRequired
The refund amount. The refund amount can not exceed the payment total.
requestIdstringOptional
A unique request ID, required for safe retries. It is recommended that the merchant generate a UUID for each unique refund.
merchantReferencestringOptional

The merchant’s internal refund id/reference. This must be included along with the requestId to utilise idempotency.