Create refund
Refund an amount or specific line items of an order, through the payment gateway or as a manual record.
MCP tool woocommerce_write → create_refund
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. |
tools/call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "woocommerce_write",
"arguments": {
"operation": "create_refund",
"arguments": {
"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
{
"content": [
{
"type": "text",
"text": "{ ... same JSON as structuredContent ... }"
}
],
"structuredContent": {
"refund_id": 1051,
"order_id": 1042,
"amount": "22.00",
"reason": "Damaged in transit",
"refunded_via": "payment gateway",
"order_status": "processing"
},
"isError": false
}