Create WooCommerce Order Refund
woocommerce_create_order_refundCreate a refund for a WooCommerce order, either a flat amount or per line item. Specify order ID and optionally amount, reason, or items to refund.
Instructions
Issue a refund against an order, either as a flat amount or itemized by line item. This is a DESTRUCTIVE, hard-to-reverse financial operation - confirm details with the user before calling.
Args:
order_id (number, required)
amount (string, optional): flat refund amount; required if line_items is omitted
reason (string, optional)
line_items (array, optional): [{id, quantity?, refund_total?}] for itemized refunds
api_refund (boolean, default true): attempt gateway refund vs. record-only
response_format ('markdown'|'json'): default 'markdown'
Returns: The created refund object.
Examples:
Use when: "refund $15 of order 100 for a damaged item" -> order_id=100, amount="15.00", reason="Damaged item"
Error Handling:
Returns "Error: Bad request (400)" if the amount exceeds the order total or the gateway rejects the refund.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | No | Amount to refund as a numeric string, e.g. '10.00'. If omitted with no line_items, refunds the full order total. | |
| reason | No | Reason for the refund, shown in admin and possibly to the customer | |
| order_id | Yes | The numeric WooCommerce order ID to refund | |
| api_refund | No | If true (default) and the payment gateway supports it, attempts to refund via the gateway API; set false to only record the refund in WooCommerce | |
| line_items | No | Specific line items to refund; omit to do a simple amount-based refund | |
| response_format | No | Output format: 'markdown' for human-readable text or 'json' for machine-readable structured data | markdown |