Skip to main content

Order refunds

The order refunds API allows you to create, view, and delete individual refunds, based on an existing order.

Order refund properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
date_createddate-timeThe date the order refund was created, in the site's timezone. READ-ONLY
date_created_gmtdate-timeThe date the order refund was created, as GMT. READ-ONLY
amountstringTotal refund amount. Optional. If this parameter is provided, it will take precedence over line item totals, even when total of line items does not matches with this amount.
reasonstringReason for refund.
refunded_byintegerUser ID of user who created the refund.
refunded_paymentbooleanIf the payment was refunded via the API. See api_refund. READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties
line_itemsarrayLine items data. See Order refund - Line items properties
tax_linesarrayTax lines data. See Order refund - Tax lines properties READ-ONLY
shipping_linesarrayShipping lines data. See Order refund - Shipping lines properties
fee_linesarrayFee lines data. See Order refund - Fee lines properties
api_refundbooleanWhen true, the payment gateway API is used to generate the refund. Default is true. WRITE-ONLY
api_restockbooleanWhen true, the selected line items are restocked Default is true. WRITE-ONLY
compute_totalsbooleanWhen true, the server computes per-line refund amounts from quantities and validates the request against the order's refund history. Available since WooCommerce 11.1. See Server-computed refunds. Default is false. WRITE-ONLY

Order refund - Meta data properties

AttributeTypeDescription
idintegerMeta ID. READ-ONLY
keystringMeta key.
valuestringMeta value.

Order refund - Line items properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
namestringProduct name.
product_idintegerProduct ID.
variation_idintegerVariation ID, if applicable.
quantityintegerQuantity ordered.
tax_classstringTax class of product.
subtotalstringLine subtotal (before discounts).
subtotal_taxstringLine subtotal tax (before discounts). READ-ONLY
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order refund line item - Taxes properties READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties
skustringProduct SKU. READ-ONLY
pricestringProduct price. READ-ONLY

Order refund line item - Taxes properties

AttributeTypeDescription
idintegerTax rate ID. READ-ONLY
totalstringTax total. READ-ONLY
subtotalstringTax subtotal. READ-ONLY

Order refund - Tax lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
rate_codestringTax rate code. READ-ONLY
rate_idintegerTax rate ID. READ-ONLY
labelstringTax rate label. READ-ONLY
compoundbooleanWhether or not this is a compound tax rate. READ-ONLY
tax_totalstringTax total (not including shipping taxes). READ-ONLY
shipping_tax_totalstringShipping tax total. READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties

Order refund - Shipping lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
method_titlestringShipping method name.
method_idstringShipping method ID.
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order refund - Tax lines properties READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties

Order refund - Fee lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
namestringFee name.
tax_classstringTax class of fee.
tax_statusstringTax status of fee. Options: taxable and none.
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order refund - Tax lines properties READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties

Create a refund

This API helps you to create a new refund for an order.

POST /wp-json/wc/v3/orders/<id>/refunds
curl -X POST https://example.com/wp-json/wc/v3/orders/723/refunds \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"amount": "30",
"line_items": [
{
"id": "111",
"refund_total": 10,
"refund_tax": [
{
"id": "222",
"refund_total": 20
}
]
}
}'

Line item parameters

ParameterTypeDescription
idintegerThe ID of the line item in the order.
refund_totalnumberThe amount to refund for this line item, excluding taxes.
refund_taxarrayRefunds for tax rates. See Refund tax parameters

Refund tax parameters

ParameterTypeDescription
idintegerThe ID of the tax rate.
refund_totalnumberThe amount of tax to refund for this line item.

Server-computed refunds (compute_totals)

Available since WooCommerce 11.1.

Set compute_totals to true to have the server compute per-line refund amounts instead of supplying them. Line items may then send only id and quantity: the server derives each line's refund amount from the order's stored unit prices and taxes, caps it to the line's remaining refundable amount, and validates the whole request against the order's refund history. The refund amount is derived from the line items unless supplied explicitly.

curl -X POST https://example.com/wp-json/wc/v3/orders/723/refunds \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"compute_totals": true,
"line_items": [
{
"id": 111,
"quantity": 1
}
]
}'

Line item parameters with compute_totals

ParameterTypeDescription
idintegerThe ID of the line item in the order. Each line item may appear only once per request.
quantityintegerThe number of units to refund. The server computes the amount for the quantity.
refund_totalnumberOptional explicit amount for this line. Tax-inclusive when refund_tax is omitted (the server splits the tax portion out); tax-exclusive when refund_tax is supplied.
refund_taxarrayOptional explicit tax refunds. See Refund tax parameters

When amount is supplied together with compute_totals, it must be at least the computed line items total and no more than the order's remaining refundable amount. Requests that exceed what is still refundable are rejected with HTTP 400 or 422 and error codes such as woocommerce_rest_invalid_refund_amount, woocommerce_rest_refund_exceeds_remaining, woocommerce_rest_quantity_exceeds_refundable, and woocommerce_rest_duplicate_line_item.

Older stores silently ignore compute_totals

Stores running WooCommerce below 11.1 drop the unknown compute_totals parameter and process the request with the classic behavior. A quantity-only request then creates a refund of 0.00 instead of the intended amount. Before sending computed-form requests, verify that the store supports the flag:

  • Send OPTIONS /wp-json/wc/v3/orders/<id>/refunds and check that compute_totals is listed in the endpoint arguments, or
  • Probe POST /wp-json/wc/v3/orders/<id>/refunds/preview, which returns rest_no_route with HTTP 404 on stores without support.

Preview a refund

Available since WooCommerce 11.1.

This API computes the totals a refund would have, without creating it. The preview uses the same calculation engine as refund creation with compute_totals, so clients do not have to replicate tax, rounding, and currency-precision logic. It requires the same capability as creating a refund.

POST /wp-json/wc/v3/orders/<id>/refunds/preview
curl -X POST https://example.com/wp-json/wc/v3/orders/723/refunds/preview \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"line_items": [
{
"line_item_id": 111,
"quantity": 1
}
]
}'

Preview line item parameters

ParameterTypeDescription
line_item_idintegerThe ID of the line item in the order. Note that the preview keys lines by line_item_id where the create endpoint uses id.
quantityintegerThe number of units to preview. Shipping and fee lines must use a quantity of 1.
refund_totalnumberOptional explicit tax-inclusive amount for this line.

Preview response properties

AttributeTypeDescription
breakdownobjectRefund breakdown by item type: products, shipping, and fees, each with items, subtotal, tax, and total. READ-ONLY
subtotalstringGrand subtotal of the refund preview, excluding tax. READ-ONLY
taxstringGrand tax total of the refund preview. READ-ONLY
totalstringGrand total of the refund preview, tax-inclusive. READ-ONLY
max_refundablestringMaximum refundable amount remaining on the order. READ-ONLY

Invalid requests return the same errors as creation with compute_totals, for example woocommerce_rest_invalid_refund_amount for a non-positive total and woocommerce_rest_preview_exceeds_max_refundable with HTTP 422 when the preview exceeds the remaining refundable amount.

Retrieve a refund

This API lets you retrieve and view a specific refund from an order.

GET /wp-json/wc/v3/orders/<id>/refunds/<refund_id>
curl https://example.com/wp-json/wc/v3/orders/723/refunds/726 \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
dpstringNumber of decimal points to use in each resource.

List all refunds

This API helps you to view all the refunds from an order.

Note: To view a list of refunds from your store, regardless of order, check out the refunds endpoint.

GET /wp-json/wc/v3/orders/<id>/refunds
curl https://example.com/wp-json/wc/v3/orders/723/refunds \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to those matching a string.
afterstringLimit response to resources published after a given ISO8601 compliant date.
beforestringLimit response to resources published before a given ISO8601 compliant date.
dates_are_gmtbooleanInterpret after and before as UTC dates when true.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderbystringSort collection by object attribute. Options: date, modified, id, include, title and slug. Default is date.
parentarrayLimit result set to those of particular parent IDs.
parent_excludearrayLimit result set to all items except those of a particular parent ID.
dpintegerNumber of decimal points to use in each resource. Default is 2.

Delete a refund

This API helps you delete an order refund.

DELETE /wp-json/wc/v3/orders/<id>/refunds/<refund_id>
curl -X DELETE https://example.com/wp-json/wc/v3/orders/723/refunds/726?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringRequired to be true, as resource does not support trashing.