Record a refund
orders:writeRate limit writesIdempotent with Idempotency-KeyRecords a refund: no money moves here — refund at the gateway, or let its webhook do this. Without lines the whole order (everything not yet refunded) is marked refunded. With lines, each quantity is capped at what is still unrefunded; lines already fully refunded are skipped. amount overrides the computed sum (line prices × quantities, or the remaining total); refunded_total never exceeds the order total. restock (default false) puts the refunded units back in stock. payment_status becomes refunded or partially_refunded. A refund that adds nothing (amount 0, or an order already refunded in full) is a 422 and changes nothing — no lines, stock, status or email to the buyer.
Store orders only: a Site product order (kind: product) answers 404.
Authorization
ESTAGE-API-KeystringheaderrequiredA project key, est_live_…, from Settings → API keys. Call from server code only.
Path parameters
idintegerrequiredBody
application/jsonlinesarray of objectnullable≤ 200 itemsShow 2 fields
order_item_idintegerrequiredAn item id of this order (items[].id).
quantityintegerrequired≥ 1restockbooleandefault falseamountnumbernullable≥ 0Headers
Idempotency-Keystring≤ 255 charsAny unique string per attempt. A retry with the same key gets the first answer back instead of doing the work twice.
curl --request POST \ --url 'https://api.estage.com/v1/orders/order-id/refund' \ --header 'ESTAGE-API-Key: est_live_your-api-key' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: your-unique-key' \ --data '{ "lines": [{ "order_item_id": 70211, "quantity": 1 }], "restock": true }'
{
"data": {
"id": 98314,
"number": 1042,
"fulfillment_status": "unfulfilled",
"payment_status": "partially_refunded",
"gateway": "stripe",
"cancelled_at": null,
"currency": "USD",
"subtotal": "54.00",
"discount_total": "5.40",
"shipping_total": "6.00",
"tax_total": "0.00",
"total": "54.60",
"refunded_total": "27.00",
"discount_code": "SUMMER10",
"customer": {
"id": 44120,
"email": "ana@example.com",
"name": "Ana Lopez"
},
"items": [
{
"id": 70211,
"product_id": 5012,
"variant_id": 30442,
"name": "Classic Tee",
"variant_title": "L",
"sku": "TEE-L",
"quantity": 2,
"unit_price": "27.00",
"total": "54.00",
"fulfilled_quantity": 0,
"refunded_quantity": 1
}
],
"created_at": "2026-11-02T14:05:31Z",
"updated_at": "2026-11-02T14:05:31Z",
"kind": "commerce",
"product": null,
"subscription_id": null,
"expires_at": null,
"access_active": null,
"shipping_address": {
"name": "Ana Lopez",
"line1": "12 Harbor St",
"line2": null,
"city": "Portland",
"state": "OR",
"postal_code": "97201",
"country": "US",
"phone": "+15035550142"
},
"billing_address": {
"name": "Ana Lopez",
"line1": "12 Harbor St",
"line2": null,
"city": "Portland",
"state": "OR",
"postal_code": "97201",
"country": "US",
"phone": "+15035550142"
},
"note": null,
"applied_discounts": [
{
"id": 412,
"method": "code",
"kind": "order",
"type": "percent",
"label": "SUMMER10",
"code": "SUMMER10",
"amount": 5.4,
"free_shipping": false
}
],
"shipping_lines": [
{
"group": "0",
"rate_id": 77,
"name": "Standard",
"method": "shipping",
"carrier_code": null,
"service_code": null,
"price": 6
}
],
"fulfillments": [],
"shipping_costs": {
"paid": 6,
"labels": 0,
"difference": 6,
"currency": "USD",
"priced": 0,
"unpriced": 0,
"foreign": []
}
}
}{ error: { code, message, details } }.