Refund via api call

Topic summary

API refund calculation fails with HTTP 400. Shopify returns: {“errors”:{“id”:“expected String to be a id”}}.

Context:

  • order_number: #1; refund_amount: 144.91 EUR; shopify_order_id: 10868291633420.
  • Payload (calculate): currency EUR; shipping amount 0 (not full refund); refund_line_items: quantity 1, line_item_id 123456777777, restock_type no_restock.

Key details:

  • 400 indicates a bad request; response points to an “id” type/format issue.
  • Provided payload includes numeric IDs (e.g., line_item_id); the error references an expected String for an “id” field.

Outcome/status:

  • Refund calculation cannot proceed; user is unsure of the mistake.
  • No resolution or guidance provided yet; issue remains open.

Notes:

  • The included error payload and JSON snippets are central to diagnosing the problem.
Summarized with AI on January 9. AI used: gpt-5.

Hi, I have currently following problem: Error Details

Error

process-shopify-refund • 09.01.2026, 20:27:19

Message

Failed to calculate refund in Shopify: 400

User Context

{
  "order_number": "#1",
  "refund_amount": 144.91,
  "shopify_order_id": 10868291633420
}

Error Details

{
  "status_code": 400,
  "shopify_response": "{\"errors\":{\"id\":\"expected String to be a id\"}}",
  "calculate_payload": {
    "refund": {
      "currency": "EUR",
      "shipping": {
        "amount": 0,
        "full_refund": false
      },
      "refund_line_items": [
        {
          "quantity": 1,
          "line_item_id": 123456777777,
          "restock_type": "no_restock"
        }
      ]
    }
  }
}

I don’t know what’s wrong with this call.

Hi @lilracc

It means the line_item_id is the Shopify GraphQL global ID rather than the numeric REST ID. The API expects a gid formatted string when using calculateRefund. Retrieving the order through GraphQL and providing the line item gid, then the refund calculation does not fail with the 400 error.

Hi @lilracc

The error message “expected String to be a id” indicates that the Shopify API is receiving an ID in a format it cannot process, typically because a numerical value was sent where a string (text) was expected. While Shopify IDs look like numbers, the GraphQL and REST APIs often require them to be passed as strings within the payload

In your specific calculate_payload, the line_item_id is currently set as an integer (123456777777). To fix the 400 error, you should wrap that ID in quotation marks so it is treated as a string ("123456777777").

Additionally, ensure that the shopify_order_id in your broader user context is also handled as a string if it is being passed as a variable in the same request.

Hope this helps!