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
    • Dates
    • Pagination
    • Authentication
    • Idempotent Requests
    • Timeouts
    • API Simulator
  • Models
    • Introduction
    • Contact Object
    • Consumer Object
    • Discount Object
    • Item Object
    • Money Object
    • Order Details Object
    • Payment Object
    • Refund Object
    • Shipping Courier Object
  • Service Status
    • GETPing
  • Configuration
    • GETGet Configuration
  • Orders
    • Introduction
    • GETGet Order
    • POSTCreate Order
  • Javascript afterpay.js
    • Information
    • Redirect Method
  • Payments
    • Introduction
    • POSTCapture Payment
    • PUTUpdate Shipping Courier
    • GETGet Payment By Order ID
    • GETGet Payment By Token
    • GETList Payment(s)
    • POSTCreate Refund
    • PUTUpdate Payment by Order ID
    • POSTReverse Payment By Token
  • Errors
    • Introduction
    • Get Errors
    • Put/Post Errors
  • Reference
      • POSTCapture Payment
      • POSTCreate Refund
      • GETGet Payment By Order ID
      • GETGet Payment By Token
      • GETList Payments
      • POSTReverse Payment
      • PUTUpdate Courier
      • PUTUpdate Payment
LogoLogo
ReferencePayments

Create Refund

POST
https://global-api-sandbox.afterpay.com/v1/payments/:orderId/refund/environment::environment
POST
/v1/payments/:orderId/refund/environment::environment
$curl -X POST https://global-api-sandbox.afterpay.com/v1/payments/orderId/refund/environment:environment \
> -H "User-Agent: User-Agent" \
> -H "Content-Type: application/json" \
> -u "<username>:<password>" \
> -d '{
> "amount": {
> "amount": "0.00",
> "currency": "string"
> }
>}'
1{}
This endpoint performs a full or partial refund. The refund operation is [idempotent](../../docs/online-api/idempotent-requests.md) if a unique requestId and merchantReference are provided. ### Connection Timeouts | Timeout | Time (Seconds) | | ------- | ------------ | | Open | 10 | | Read | 70 |
Was this page helpful?
Previous

Get Payment By Order ID

Next
Built with

This endpoint performs a full or partial refund.

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

Connection Timeouts

TimeoutTime (Seconds)
Open10
Read70

Authentication

AuthorizationBasic

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

Path parameters

environmentstringRequired

Use api-sandbox for AU/NZ, or api.us-sandbox for US.

orderIdstringRequired
The unique Afterpay 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.

Response

Returns a 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, Afterpay-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. |

Errors

412
Precondition Failed Error
422
Unprocessable Entity Error

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, Afterpay-generated Refund ID.
refundedAtstringThe UTC timestamp of when the refund was completed, in ISO 8601 format.