Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I want to switch to the new way of managing webhooks through the config file. But I want some clarification on exactly how this works for existing webhook subscriptions, because I don't want to break anything. So is this just automatically applied to all shops on installation? Do I have to use the GraphQL API to unsubscribe the old users from the webhooks if I want to take advantage of the new filters feature? If I switch to the new way, will it just automatically apply to all users right away or only new users?
Originally posted in Slack: https://shopifypartners.slack.com/archives/C4E5GV5U4/p1719430887032349
Solved! Go to the solution
This is an accepted solution.
Okay, so it looks like if you have webhooks subscribed using the old method, they will still be active. So you will receive 2 webhooks, one from the old subscription and one from the new managed webhook. So you need to unregister the old ones. The easiest way to do that is remove all the webhook handlers in your code and then call 'await shopify.webhooks.register({ session });' The register function (as of v6 of the library) adds, removes, or updates the webhook subscriptions as necessary, depending on your handlers set, so if you don't add any handlers it will remove all subscriptions, leaving only the Shopify managed ones. You will have to do this for every shop in your database.
This is an accepted solution.
Okay, so it looks like if you have webhooks subscribed using the old method, they will still be active. So you will receive 2 webhooks, one from the old subscription and one from the new managed webhook. So you need to unregister the old ones. The easiest way to do that is remove all the webhook handlers in your code and then call 'await shopify.webhooks.register({ session });' The register function (as of v6 of the library) adds, removes, or updates the webhook subscriptions as necessary, depending on your handlers set, so if you don't add any handlers it will remove all subscriptions, leaving only the Shopify managed ones. You will have to do this for every shop in your database.
Hey @DavidT, thank you for raising and sharing your resolution. We've also incorporated this back into the dev docs here: https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-subscriptions