Mastering Shopify Flow Inventory Updates: Troubleshooting `inventorySetQuantities` API Errors

Hey everyone! Your friendly Shopify expert here, diving into a really insightful community discussion that recently caught my eye. We all know how crucial accurate inventory management is, and automating those updates with Shopify Flow can be a game-changer. But sometimes, even with the best intentions (and maybe a little AI help!), things don't quite go as planned.

A fellow store owner, ssg1205, kicked off a thread titled "Flow inventorySetQuantities 2026-01" because they were hitting a wall trying to automate inventory replenishment. They wanted to use Shopify Flow's "Send Admin API Request" action to update quantities for products falling below certain thresholds. Sounds straightforward, right? Well, they kept running into a frustrating error: "Variable $input of type InventorySetQuantitiesInput! was provided invalid value" or sometimes just "No data returned. This is expected for this action" in the output, even when the Flow "Run code" step showed success.

The Mystery of the Failing Mutation

What made this particularly puzzling for ssg1205 was that they had successfully tested the exact mutation in Shopify’s GraphiQL app. Here's a snippet of what worked for them in GraphiQL, changing an inventory item from 10 to 12:

mutation {
  inventorySetQuantities(input: {
    name: "available",
    reason: "correction",
    referenceDocumentUri: "logistics://replenishment/auto",
    quantities: [{
      inventoryItemId: "gid://shopify/InventoryItem/47664006070573",
      locationId: "gid://shopify/Location/63312822306",
      quantity: 12,
      changeFromQuantity: 10
    }]
  }) @idempotent(key: "replenish-47664006070573") {
    userErrors { field message }
  }
}

This proved that the GraphQL mutation itself was perfectly valid and capable of doing the job. So, if it worked in GraphiQL, why was it failing when embedded in a Flow action?

Unmasking the Culprit: Curly Quotes and JSON Escaping

This is where the collective wisdom of the community really shines! After a few attempts and error messages shared by ssg1205, a sharp-eyed expert named PaulNewton pinpointed a common, yet often overlooked, issue: curly quotes. Take a look at this example from ssg1205's failing Flow input:

{
  “mutation_name”: “inventorySetQuantities”,
  “mutation_input”: “{
  “reason”: “correction”,
  “referenceDocumentUri”: “logistics://replenishment/auto”,
  “quantities”: [
    {
      “inventoryItemId”: “gid://shopify/InventoryItem/53885106422061”,
      “locationId”: “gid://shopify/Location/63312822306”,
      “name”: “available”,
      “quantity”: 12
    }
  ]
}”,
  “api_version”: “2026-01”,
  “hydration_type_patch”: “{}”
}

Do you see them? Look closely at the quotation marks around keys and values like “mutation_name” or “reason”. They’re not the standard straight double quotes (") that JSON requires; they're fancy, typographic curly quotes ( and ). This seemingly small detail is a huge deal to a machine parser. As PaulNewton eloquently put it, " :eyes: ← those are curly quotes, use proper double quotes in code: "".

This usually happens when you copy-paste code or JSON from word-processing software, certain text editors, or even some browser extensions that try to be "smart" with typography. And yes, as PaulNewton also hinted, sometimes even "bad AI-tools" can introduce these issues if they aren't careful about code formatting. The Shopify Flow action expects a perfectly formed JSON string, and those curly quotes break it.

Beyond Curly Quotes: Other Key Considerations

While the curly quotes were a major red flag, other community members like tim_1 brought up additional important points that are crucial for successful API calls:

  • Deprecated Fields: tim_1 noted that ignoreCompareQuantity is deprecated. While it might not cause an error immediately, it's good practice to avoid deprecated fields to ensure future compatibility and avoid unexpected behavior.
  • Required Fields: tim_1 also mentioned that referenceDocumentUri, even if not explicitly marked as required in some contexts, was often necessary for the mutation to work properly. This field provides context for the inventory change, which is important for auditing and tracking.

Your Step-by-Step Guide to Fixing Flow Inventory Mutations

So, how do you ensure your Shopify Flow inventory updates run smoothly? Here's a clear breakdown based on the community's insights:

1. Validate Your GraphQL Mutation First

Before you even think about Flow, make sure your GraphQL mutation is perfect. Use the Shopify GraphiQL app or the Shopify CLI. This step isolates the GraphQL structure from any Flow-specific formatting issues. Once it works there, you know your core logic is sound.

2. Construct Your mutation_input String Carefully

The mutation_input field in Flow's "Send Admin API Request" action expects a string that represents your GraphQL input. This means the entire JSON object for your mutation's input argument needs to be enclosed in double quotes and have all its internal double quotes escaped with a backslash (").

3. Banish Curly Quotes!

This is paramount. When building or pasting your JSON, ensure every single double quote is a straight ", not a curly or . If you're copying from somewhere, paste it into a plain text editor (like Notepad on Windows, TextEdit in plain text mode on Mac, or a code editor like VS Code) first to strip out any rich text formatting before moving it into Flow.

4. Include All Necessary Fields

Based on the working example and community advice, your mutation_input JSON should include:

  • reason: A string explaining why the inventory is changing (e.g., "correction", "replenishment").
  • referenceDocumentUri: A URI providing context for the change (e.g., "logistics://replenishment/auto"). This is highly recommended, even if not strictly enforced in all API versions.
  • quantities: An array of objects, each containing:
    • inventoryItemId: The GID of the inventory item.
    • locationId: The GID of the location where the inventory is being updated.
    • name: The inventory level name (e.g., "available").
    • quantity: The new quantity to set.
    • changeFromQuantity: (Optional but recommended for idempotency) The quantity you expect the item to be at before the change. This helps prevent accidental updates if the inventory has changed unexpectedly.

5. Ensure Proper JSON Escaping for Flow

When you put your mutation JSON into the mutation_input string, it needs to be escaped correctly. Here’s a correct example of how the mutation_input string should look (using the working GraphiQL example's structure, but adjusted to Flow's string format):

{
  "mutation_name": "inventorySetQuantities",
  "mutation_input": "{
  \\"name\\": \\"available\\",\
  \\"reason\\": \\"correction\\",\
  \\"referenceDocumentUri\\": \\"logistics://replenishment/auto\\",\
  \\"quantities\\": [{\
    \\"inventoryItemId\\": \\"gid://shopify/InventoryItem/47664006070573\\",\
    \\"locationId\\": \\"gid://shopify/Location/63312822306\\",\
    \\"quantity\\": 12,\
    \\"changeFromQuantity\\": 10\
  }] \
}",
  "api_version": "2026-01",
  "hydration_type_patch": "{}"
}

Notice how every internal double quote is now \" and newlines are \ . This is crucial for Flow to parse the string correctly.

A Creative Alternative for Complex Needs

Interestingly, ssg1205 eventually found an alternative path to success, mentioning that "Shopify’s native AI has now built a custom app for me to replenish quantities for products that fall within certain thresholds with a single click. With the help of Power Automate and Windows Task Scheduler, I run a scheduled task once a day to click the App’s replenish button, and now my issue is resolved." This highlights that for highly specific or complex scenarios, a custom app combined with external automation tools like Power Automate can be a powerful solution. However, for most direct inventory updates, getting the Flow API call right is often the more streamlined approach.

So, the next time you're wrestling with a Shopify Flow API error, remember to double-check your quotes, validate your GraphQL, and ensure your JSON is perfectly formatted and escaped. The community's collective experience shows that these small details often make all the difference in unlocking powerful automation for your store!

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools