KashuDocs

Refunds

The refunds endpoints of the Kashu API, with their parameters, objects, errors and examples. The guide explains how they fit together.

EndpointWhat it does
POST /v1/refundsRefund part or all of a captured payment. Without an amount, all that is left.
GET /v1/refundsList refunds, newest first.
GET /v1/refunds/{id}Retrieve a refund.

The refund object

FieldTypeAbout
idstringAn id that starts rf_.
objectstringAlways "refund".
amountintegerIn the currency's minor unit, such as cents for USD. More than 0.
currencystringThree capital letters, such as USD.
paymentstringAn id that starts py_.
statusenumOne of pending, succeeded, failed.
reasonenum or nullOne of requested_by_customer, duplicate, fraudulent.
failure_reasonenum or nullOne of already_refunded, processing_error.
metadatamap of strings
livemodeboolean
createdintegerUnix seconds.
{
  "id": "rf_1a2B3c4D5e6F7g8H9i0J1k2L",
  "object": "refund",
  "amount": 4999,
  "currency": "USD",
  "payment": "py_1a2B3c4D5e6F7g8H9i0J1k2L",
  "status": "succeeded",
  "reason": null,
  "failure_reason": null,
  "metadata": {
    "order": "1001"
  },
  "livemode": false,
  "created": 1762473600
}

POST /v1/refunds

Refund part or all of a captured payment. Without an amount, all that is left.

Scope
refunds:write
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Required. This endpoint moves money. See Idempotency.
Answers
201 with the Refund.

Parameters

NameInTypeRequiredAbout
Idempotency-KeyheaderstringRequiredRequired. Retry with the same key and get the same result. Up to 255 characters.
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Request body

FieldTypeRequiredAbout
paymentstringRequiredAn id that starts py_.
amountintegerOptionalIn the currency's minor unit, such as cents for USD. More than 0. Up to 99999999.
reasonenumOptionalOne of requested_by_customer, duplicate, fraudulent.
metadatamap of stringsOptionalKeys up to 40 characters, values up to 500.

Errors

Examples

curl https://api.kashupay.com/v1/refunds \
  -H "Authorization: Bearer $KASHU_SECRET_KEY" \
  -H "Idempotency-Key: refunds-create-1001" \
  -H "Content-Type: application/json" \
  -d '{"payment":"py_1a2B3c4D5e6F7g8H9i0J1k2L","amount":4999}'
const refund = await kashu("POST", "/v1/refunds", {
  "payment": "py_1a2B3c4D5e6F7g8H9i0J1k2L",
  "amount": 4999
}, { idempotencyKey: "refunds-create-1001" });
console.log(refund.status);

GET /v1/refunds

List refunds, newest first.

Scope
refunds:read
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Not used. A read changes nothing.
Answers
200 with a list of Refund, newest first.

Parameters

NameInTypeRequiredAbout
paymentquerystringOptionalAn id that starts py_.
limitqueryintegerOptionalAt least 1. Up to 100. Defaults to 10.
cursorquerystringOptional
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Errors

Examples

curl "https://api.kashupay.com/v1/refunds?limit=3" \
  -H "Authorization: Bearer $KASHU_SECRET_KEY"
const list = await kashu("GET", "/v1/refunds?limit=3");
console.log(list.has_more);

GET /v1/refunds/{id}

Retrieve a refund.

Scope
refunds:read
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Not used. A read changes nothing.
Answers
200 with the Refund.

Parameters

NameInTypeRequiredAbout
idpathstringRequiredAn id that starts rf_.
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Errors

Examples

curl https://api.kashupay.com/v1/refunds/rf_1a2B3c4D5e6F7g8H9i0J1k2L \
  -H "Authorization: Bearer $KASHU_SECRET_KEY"
const refund = await kashu("GET", "/v1/refunds/rf_1a2B3c4D5e6F7g8H9i0J1k2L");
console.log(refund.status);