What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Change product Url via API and enable rewrite on old url

Change product Url via API and enable rewrite on old url

Happycasastore
Visitor
1 0 0

Hi,

when I change the url from the shoify backend I can choose the possibility  to create an URL Redirect from the old link to new one..
But, since I want to do the same thing via API, when I change the "handle" field it creates a new Url but old one became a "not found page"... there is a way to set this "create URL REDIRECT" via API?

 

Thnak you very much

 

Happycasastore_0-1642083544146.png

 

Reply 1 (1)

csam
Shopify Staff (Retired)
267 40 51

Hi @Happycasastore 

 

While it's not part of the product update mutation, you can create a URL redirect via a separate mutation using UrlRedirect. Here is some documentation about the mutation: https://shopify.dev/api/admin-graphql/2021-10/objects/urlredirect#fields

 

Hope this helps!

To learn more visit the Shopify Help Center or the Community Blog.