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.