Refund a payment
Refund a card payment, whole or in part.
Path parameters
orgIdstringRequiredThe opaque organization id issued to you, normally CUID-shaped (for example
cmsx…). It is not anorg_-prefixed alias. Pass it unchanged in every organization-scoped path.paymentIdstringRequiredThe payment's
id, or the acquirer'sexternalId.
Headers
Idempotency-KeystringRequiredA unique value per logical operation, 1-255 chars of
A-Z a-z 0-9 _ . : -.More
Reuse it to retry. Same key with the same body replays the stored response; same key with a different body is a
409, because answering with the first call's result would hand you a receipt for a payout you did not request. A4xxreleases the key, so you can fix the body and reuse it.Reuse it; do not generate one per attempt. A key minted per attempt defeats replay entirely: every retry looks like a new request, so every retry pays. We also watch for an identical body arriving under a different key within 15 minutes and refuse it with
DUPLICATE_REQUEST_DETECTED.Records are kept for 7 days. That is a retention window only: there is no path where an expired key is re-executed.
X-Allow-DuplicatestringOptionalSet to
trueto send a request that is byte-identical to one you sent within the last 15 minutes under a different key.trueis the only accepted value. It switches off the guard that catches a retry arriving under a fresh key, so send it only when you mean to pay twice.
Body
This endpoint expects a JSON object, or no body.
amountstringOptionalDecimal string in the payment's currency, at most as many decimal places as the currency has. Omit for everything remaining.
reasonstringOptionalThe four refund reasons most card APIs use.
Allowed values:requested_by_customerduplicatefraudulentothernotestringOptionalFor your own team. Never shown to the buyer; echoed on the event.
Behavior
Moves money out of your balance and back to the buyer's card. Omit
amount to refund everything still refundable; pass a decimal string
in the payment's currency to refund part of it. paymentId is the
payment's id from GET /links/{linkId}/payments (the acquirer's
externalId is accepted too).
The key needs the refunds scope. It is a consent an owner or
admin grants when the key is issued (scopes: ["write", "refunds"]);
a key without it, including one issued before scopes existed, gets
403 INSUFFICIENT_SCOPE and nothing moves.
Idempotency-Key is required, and the acquirer's refund endpoint has
no idempotency of its own, so the key is what makes a retry safe: reuse
it. A byte-identical refund of the same payment under a different
key within fifteen minutes is refused with DUPLICATE_REQUEST_DETECTED;
a genuine second refund of the same amount sends X-Allow-Duplicate: true. One refund is in flight per payment at a time: a second one
while the first is still being confirmed is 409 REFUND_IN_PROGRESS;
read the payment and try again once refundedBase has moved.
When the outcome is unknown (the card processor did not answer
definitively) the answer is 500 PAYOUT_OUTCOME_UNKNOWN. The refund
may have gone through. Do not resend it, and never under a new
Idempotency-Key: read the payment first. refundedBase moves, and
checkout_payment.refunded or .partially_refunded follows, if it
did. A replay of the same key answers 409 PAYOUT_OUTCOME_UNKNOWN
until we resolve it. (The shared message speaks of a payout and
GET /orders; for a refund, read the payment instead.)
A full refund publishes checkout_payment.refunded; a partial one
publishes checkout_payment.partially_refunded (opt-in, like the rest
of the family). Both carry the refund just made in refund. Every
payment read lists its refunds under refunds.
Responses
200The payment after the refund, with the refund that was just made.
Body · RefundCheckoutPaymentResponse
idstringRequiredkindstringRequiredHow a buyer may pay.
cardis the hosted card page (card, wallets and PayPal in one).Allowed values:cardbankcryptocashappacceptorstringOptionalWhich side recorded it:
sandboxfor a simulated payment,manualfor one you recorded in the dashboard. A live card payment carries an internal label for the card processor, which can change without notice. Do not branch on it.externalIdstringOptionalThe acceptor's id for it. Opaque.
amountBasestringRequiredGross, base units.
currencystringRequireddecimalsintegerRequiredfeeBasestringRequiredProcessing fee, base units.
"0"when none was stated.netBasestring | nullOptionalWhat reached your balance, when the acceptor stated it.
applicationFeeBasestringOptionalOur fee, base units.
refundedBasestring | nullOptionalCumulative refunded, or null when nothing has been.
refundsarray of objectRequiredEvery refund on this payment, oldest first, with who asked for it and why. Empty when none.
Show 11 properties
idstringRequiredpaymentIdstringRequiredamountBasestringRequiredThis refund, base units.
currencystringRequireddecimalsintegerRequiredreasonstring | nullRequiredThe four refund reasons most card APIs use.
Allowed values:requested_by_customerduplicatefraudulentothernotestring | nullRequiredsourcestringRequiredAllowed values:dashboardapiacquirerstatusstringRequiredAllowed values:pendingsucceededactorstring | nullRequiredA teammate's name, or the API key's name. Null for a refund made at the acquirer.
createdAtstring<date-time>Required
disputeSubstatusstring | nullOptionalSet while a dispute is open. No event fires until it resolves.
statusstringRequiredpaidis not final:refundedandreversed(a chargeback) can follow, weeks later.pendingon a bank payment that has settled means it is held (short of the total, or in the wrong currency) andreviewReasonsays why; it moves when someone accepts it in the dashboard.Allowed values:pendingprocessingpaidfailedShow 2 more values
reversedrefundedfailureCodestring | nullOptionalreviewReasonstring | nullOptionalWhy a settled bank deposit is held in
pending, in words. Null on anything not held.clientReferenceIdstring | nullOptionalThe
?client_reference_id=the buyer's visit carried (card rail only). The link-level one is on the link.paidAtstring<date-time> | nullOptionalreversedAtstring<date-time> | nullOptionalsettledAtstring<date-time> | nullOptionalNull in this version; the money is in your balance at the processor and we do not see it move from there.
createdAtstring<date-time>Requiredrefundobject | nullRequiredOne refund on a payment: the piece that moved, not the cumulative figure (that is
refundedBaseon the payment).sourcesays who asked for it:dashboard,api, oracquirerfor a refund made at the card processor's own tools that nobody initiated here.pendingis a refund we asked for and have not yet seen come back; do not branch on values beyondpendingandsucceeded.Show 11 properties
idstringRequiredpaymentIdstringRequiredamountBasestringRequiredThis refund, base units.
currencystringRequireddecimalsintegerRequiredreasonstring | nullRequiredThe four refund reasons most card APIs use.
Allowed values:requested_by_customerduplicatefraudulentothernotestring | nullRequiredsourcestringRequiredAllowed values:dashboardapiacquirerstatusstringRequiredAllowed values:pendingsucceededactorstring | nullRequiredA teammate's name, or the API key's name. Null for a refund made at the acquirer.
createdAtstring<date-time>Required
Errors
400VALIDATION_ERROR(a malformed amount, more decimal places than the currency has, an unknown reason, a note over 255 characters),REFUND_EXCEEDS_REMAINING(more thanamountBase - refundedBase),REFUND_NOT_ALLOWED(the payment is notpaid: already refunded in full, charged back, failed or still pending),REFUND_DISPUTED(a dispute is open; it decides where the money goes),PROVIDER_REJECTED(the card processor refused, with its words), orIDEMPOTENCY_KEY_REQUIRED/IDEMPOTENCY_KEY_INVALID. Nothing moved on any of them.401The key was refused. Nothing ran.
UNAUTHORIZED: missing, invalid or revoked, or a key on a route that does not accept one.KEY_EXPIRED: the key passed the expiry it was issued with. Issue a new one; an expired key cannot be rotated.KEY_IP_NOT_ALLOWED: the key is pinned to source addresses and this request came from another.
403INSUFFICIENT_SCOPE(the key is read-only or lacks therefundsscope),FORBIDDEN(a key for a different organization),ACCOUNT_BLOCKED, orLIVE_KEY_ORG_NOT_APPROVED. Refunds are not held back by business verification.404No such link or product in this organization, or the id belongs to another one.
409REFUND_IN_PROGRESS(another refund on this payment is still being confirmed at the acquirer; nothing further was sent),CONFLICT(in the sandbox, another refund landed a moment earlier; read the payment again), or an idempotency conflict:IDEMPOTENCY_KEY_CONFLICT,IDEMPOTENCY_KEY_REQUEST_IN_PROGRESS,DUPLICATE_REQUEST_DETECTED, orPAYOUT_OUTCOME_UNKNOWNon a replay of a key whose first call answered500(the refund may have gone through; read the payment, do not resend).429Too many requests. The default ceiling is 100 requests per minute per API credential on a 60-second window. High-volume payout and reconciliation routes declare a 600/minute override, and batch submission a 30/minute ceiling. A separate 2,000/minute per-source-IP abuse ceiling always applies.
Obey
Retry-After; it is in seconds and is authoritative. A 429 means the request was refused before the handler ran. Retry reads normally; retry an idempotent mutation with its sameIdempotency-Key.500PAYOUT_OUTCOME_UNKNOWN: the call failed after the money may have moved, and we cannot yet say whether it did. Do not retry with a newIdempotency-Key; that is how a payment goes out twice. Look the outcome up first (the operation says where), or replay the same key, which answers409 PAYOUT_OUTCOME_UNKNOWNuntil we resolve it. Send support therequestId.Every other
500isINTERNAL: nothing was recorded under the key, and retrying with the same key is safe.
Error body · Error
typestringRequiredStable machine-readable code.
detailstringRequiredWhat went wrong, in a sentence. Always a string, so
detail.toLowerCase()is safe.More
This is the field to read on
BAD_REQUESTandPROVIDER_REJECTED, where the type alone does not name the condition.messagestringRequiredThe same text as
detail, kept for integrations written beforedetailexisted. Readdetail.resolutionstringOptionalWhat to do about it, when there is a specific answer. It is not on every error (it is absent on
BAD_REQUEST,NOT_FOUND,PAYOUT_NOT_CANCELABLEandDESTINATION_ACCOUNT_NOT_FOUND), so treat it as optional and fall back todetail.statusintegerRequiredHTTP status, repeated in the body.
statusCodeintegerRequiredThe same value as
status, kept for integrations written beforestatusexisted. Readstatus.requestIdstringRequiredQuote this to support and we can find the exact request. Also sent as the
x-request-idresponse header, which is the only place it appears on a successful response. Success bodies do not carry it. Send your ownx-request-idon the request and we use it, so your trace and ours share one identifier; otherwise we mint one.errorsarray of stringOptionalPresent on VALIDATION_ERROR; names each field that failed.
originalIdempotencyKeystringOptionalOn
DUPLICATE_REQUEST_DETECTEDonly. Send the request again with this to receive the original payout instead of making a second one. Without it there is no way to recover except by risking a double payment.originalPayoutIdstringOptionalOn
DUPLICATE_REQUEST_DETECTEDonly. The payout the first request created.originalBatchIdstringOptionalOn a batch
DUPLICATE_REQUEST_DETECTED. The run the first request created.originalRequestIdstringOptionalOn a
409 PAYOUT_OUTCOME_UNKNOWNreplay. TherequestIdof the call whose outcome is unknown; quote it to support.existingRecipientIdstringOptionalOn
BANK_ACCOUNT_ALREADY_LINKED. The recipient in your organization that already holds this account.existingMethodIdstringOptionalOn
BANK_ACCOUNT_ALREADY_LINKED. The payment method on that recipient.
Branch on type, never on the status or the message. Every error type is listed with what to do about it.
Was this page helpful?