Unable to refund amount for items removed using order editing API

Topic summary

Issue: After removing a line item via the Order Edit API, attempting to refund that item with the Refunds Calculate endpoint returns an error: “refund_line_items.quantity: cannot refund more items than were purchased.”

Context: The request includes shipping.full_refund=true and a refund_line_items entry with line_item_id (of the removed item), restock_type=cancel, and quantity=1 against the 2024-04 calculate endpoint. A code snippet and the exact error message are central to understanding the problem.

Key questions from the poster:

  • Does the Refund API also attempt to remove items and therefore only operate on line items that still exist on the order?
  • If so, how can one refund the amount for a line item that was previously removed via the Order Edit API?

Status: No solution or guidance provided in the thread yet. The workflow for refunding amounts tied to items removed through order edits remains unclear and unresolved.

Summarized with AI on December 31. AI used: gpt-5.

I have removed one line item using order edit API. Now I’m trying to refund that amount using refund API. But the calculate refund API doesn’t allow to me to specify the quantity as 1
If I do it throws me the error

{ "errors": { "refund_line_items.quantity": [ "cannot refund more items than were purchased" ] } }

https://subdomain.myshopify.com/admin/api/2024-04/orders/01234/refunds/calculate.json

{
    "refund": {
        "shipping": {
            "full_refund": true
        },
        "refund_line_items": [
            {
                "line_item_id": 1234,
                "restock_type": "cancel",
                "quantity": 1
            }
  
        ]
    }
}

any thoughts on what might be happening here?

  1. Does refund API also tries to remove the item from the order? so it can only work on existing items in the order?
  2. If that is the case is there a way to refund the amount removed using order edit API?