Create Order Refund


Creates a full or partial refund for an order. Provide 'amount' for a simple refund, or 'line_items' (order line item IDs with a refund_total each) for an itemized refund — at least one is required. Unlike the WooCommerce REST API, api_refund defaults to false here: set it to true explicitly to also call the payment gateway's refund API and actually return funds; otherwise this only records the refund in WooCommerce without moving money. Stock is not automatically restocked.

Also known as: refund an order, give money back, partial refund.

Property Value
Ability slug mosmcp/create-order-refund
Wire tool name mosmcp__create-order-refund
Category WooCommerce (mosmcp-woocommerce)
Plan Free

 

Required access

Requirement Value
Capability edit_shop_orders
Minimum default role Shop manager
Requires WooCommerce
Annotations readOnly: false · destructive: true · idempotent: false · openWorld: false

 

Input schema

Field Type Required Default Description
id integer Yes — The order ID (required).
amount string — Total refund amount. Takes precedence over line_items totals when both are given.
reason string — Refund reason.
line_items object[] — Itemized refund lines. Each id is an order line item ID (from get-order's line_items[].id, not a product ID).
line_items[].id integer Yes —
line_items[].refund_total number Yes —
api_refund boolean false Whether to also call the payment gateway to actually process the refund. Defaults to false (records the refund only).

 

Output schema

Field Type Required
success boolean
message string
data object
data.id integer
data.date_created string \| null
data.amount string
data.reason string
data.refunded_by integer
data.line_items object[]
meta object
meta.ability string
meta.timestamp string
meta.execution_time string \| null

 

Example

Sample prompt
Refund $24 on order 1057 because one shirt arrived damaged, and send the money back to the card.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 356,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__create-order-refund",
    "arguments": {
      "input": {
        "id": 1057,
        "amount": "24.00",
        "reason": "Item arrived damaged",
        "api_refund": true
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 356,
  "result": {
    "isError": false,
    "structuredContent": {
      "success": true,
      "message": "Refund created.",
      "data": {
        "id": 1102,
        "date_created": "2026-09-28T10:05:00",
        "amount": "24.00",
        "reason": "Item arrived damaged",
        "refunded_by": 1,
        "line_items": []
      },
      "meta": {
        "ability": "mosmcp/create-order-refund",
        "timestamp": "2026-09-29T10:15:00+00:00",
        "execution_time": "18.4ms"
      }
    }
  }
}

 

Edge cases / errors

  • api_refund defaults to false: the refund is only recorded in WooCommerce and no money moves unless you set it to true (then the payment gateway is called).
  • Neither amount nor line_items given → wcab_missing_refund_amount; a negative or non-numeric amount/refund_total → wcab_invalid_refund_amount.
  • WooCommerce rejects it (e.g. amount exceeds what's left to refund, or the gateway doesn't support refunds) → wcab_refund_failed with WooCommerce's message.
  • Stock is not restocked automatically; unknown order → wcab_order_not_found; no edit rights → wcab_cannot_edit.

 


<< Previous Next >>
Create Order Create Product

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.