Modifying Product Type Error

Topic summary

A user encountered an error when trying to automatically set product types in Shopify Flow based on keywords in product titles. The issue stemmed from incorrect JSON formatting in the ProductUpdate mutation.

Solution Found:
The proper mutation syntax requires wrapping parameters in an “input” object:

{
  "input": {
    "productType": "Product Type Here",
    "id": "{{product.id}}"
  }
}

Key Points:

  • Use the ProductUpdate API request
  • Include both productType and product ID within the input wrapper
  • The “Get product data” step mentioned by some users is unnecessary for this use case—it’s only needed when referencing data from products other than the trigger product

Status: Resolved. The flow now successfully creates product types automatically when specific keywords are detected in product titles upon creation.

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

I have a fairly simple Flow I’m trying to create but running into a problem.

I created a flow that upon product creation it searches the product title for key words I choose and then if a specific keyword is found I want it to create a Product Type.

I have the condition working, but the API call to add a product type isn’t working and I know its mostly because I don’t know how to code. Think their is a very important snippet I’m missing but not sure where to find it.

I chose ProductUpdate

and in the mutations I just included this

{
“productType”: “xxxxxx”,
}

I removed all the lines I didn’t need but its giving me the error

Ran into exception: Mutation input evaluated to invalid JSON. Please ensure the input forms valid JSON after Liquid code is run.

I resolved my issue, I’m posting my solution in case someone in the future stumbles upon this.

I created a Flow that checked the Product Title upon product creation to see if it contained a key word of my choosing (example “Glove”) then I wanted it to create a Product Type called “Gloves” automatically. I didn’t know how to tell the mutation to update the product correctly without an error. The proper code is below

{
“input”: {
“productType”: “Product Type Here”,
“id”: “{{product.id}}”
}
}

The proper API Request is ProductUpdate

Good Luck!!

1 Like

Just wanted to say THANK YOU FOR THIS! I was having the exact same issue and missed the “get product data” step which was preventing the Admin API Request action.

Why are either of you using “Get product data”? The only reason you need that is if you need to use data from some other product (than the one in the trigger).

Good question! Going to chalk it up to trial and error trying to learn flow. Was able to remove that segment and tested the function of flow and its working as intended.

Thanks for letting me/us know; helps clean up the flow!

Thanks for posting this!