Create refund
Refund an amount or specific line items of an order, through the payment gateway or as a manual record.
POST https://cotlet.dev/api/v1/woocommerce/orders/{order_id}/refunds
Creates a refund on one order for the amount you give, optionally tied to line items from get_order. With api_refund true, the default, WooCommerce uses the payment gateway API to send the money back, which needs a compatible gateway; with false it only records the refund and you send the money yourself. A refund below the full order value is a partial refund and the order status does not change; a full refund sets it to Refunded. By default you confirm each call; you can switch that off for this tool.
Parameters
| Name | Type | Description |
|---|---|---|
| order_id integer required | integer | Order ID from list_orders. |
| amount string required | string | Refund amount in the order currency, for example "22.00". |
| reason string | string | Reason stored with the refund. |
| line_items array | array | Items to refund: objects with line_item_id from get_order, quantity and amount. |
| api_refund boolean | boolean | true refunds through the payment gateway, false only records it. Default: true. |
Request
curl -X POST https://cotlet.dev/api/v1/woocommerce/orders/1042/refunds \
-H "Authorization: Bearer $COTLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount":"22.00","reason":"Damaged in transit","line_items":[{"line_item_id":7002,"quantity":1,"amount":"22.00"}],"api_refund":true}' result = client.call("woocommerce", "create_refund", {"order_id":1042,"amount":"22.00","reason":"Damaged in transit","line_items":[{"line_item_id":7002,"quantity":1,"amount":"22.00"}],"api_refund":True}) const result = await cotlet.call('woocommerce', 'create_refund', {"order_id":1042,"amount":"22.00","reason":"Damaged in transit","line_items":[{"line_item_id":7002,"quantity":1,"amount":"22.00"}],"api_refund":true}); cotlet call woocommerce create_refund --data '{"order_id":1042,"amount":"22.00","reason":"Damaged in transit","line_items":[{"line_item_id":7002,"quantity":1,"amount":"22.00"}],"api_refund":true}' Example response
{
"refund_id": 1051,
"order_id": 1042,
"amount": "22.00",
"reason": "Damaged in transit",
"refunded_via": "payment gateway",
"order_status": "processing"
}