How to refund order with multiple transactions via REST api?

Topic summary

Problem Solved: Refunding Orders with Multiple Transactions

The original poster shares a working JSON example for refunding Shopify orders that involve multiple transactions via REST API, addressing a gap in official documentation.

Key Technical Requirements:

  • All refund_line_items must be structured as individual objects within a single array
  • Multiple transactions also need to be formatted as individual objects in one array
  • Failing to follow this structure results in an “expected to be hash” error

JSON Structure Includes:

  • Line item details (price, line_item_id, quantity, restock_type, location_id)
  • Transaction objects (amount, currency, parent_id, kind, gateway)
  • Shipping and notification settings

The poster emphasizes this solution saved significant troubleshooting time and hopes it helps others avoid similar issues with the underdocumented API endpoint.

Summarized with AI on November 22. AI used: claude-sonnet-4-5-20250929.

Here is an example JSON needed to refund an order with multiple transactions since the shopify documenation does not provide one.

I wasted a lot of time with this, so hopefully this helps someone avoid that :))

{
    "refund": {
        "notify": "true",
        "note": "",
        "shipping": {
            "full_refund": "false"
        },
        "refund_line_items": [
            {
                "price": 191.94,
                "line_item_id": xxx,
                "quantity": 1,
                "restock_type": "no_restock",
                "location_id": xxx
            },
            {
                "price": 155.94,
                "line_item_id": xxx,
                "quantity": 1,
                "restock_type": "no_restock",
                "location_id": xxx
            },
            {
                "price": 21,
                "line_item_id": xxx,
                "quantity": 1,
                "restock_type": "no_restock",
                "location_id": xxx
            }
        ],
        "transactions": [
            {
                "parent_id": xxx,
                "currency": "EUR",
                "amount": "347.88",
                "kind": "refund",
                "gateway": "bogus"
            },
            {
                "parent_id": xxx,
                "currency": "EUR",
                "amount": "21.00",
                "kind": "refund",
                "gateway": "bogus"
            }
        ]
    }
}

As you can see, the refund_line_items need to all be individual objects in one array, otherwise you get the:

array expected to be hash

error

The multiple transactions need to also be individual objects in one array

Cheers,

Matthias7

1 Like