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.

Switching to Shopify managed webhooks

Solved

Switching to Shopify managed webhooks

DavidT
Shopify Partner
39 2 17

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

QuickEdit - Bulk Product Edit - Quick and easy bulk editor for products, variants, and collections.
SafeShip - Address Validator - International address validation and PO box blocking at checkout for Shopify Plus merchants.
Accepted Solution (1)

DavidT
Shopify Partner
39 2 17

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.

QuickEdit - Bulk Product Edit - Quick and easy bulk editor for products, variants, and collections.
SafeShip - Address Validator - International address validation and PO box blocking at checkout for Shopify Plus merchants.

View solution in original post

Replies 2 (2)

DavidT
Shopify Partner
39 2 17

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.

QuickEdit - Bulk Product Edit - Quick and easy bulk editor for products, variants, and collections.
SafeShip - Address Validator - International address validation and PO box blocking at checkout for Shopify Plus merchants.
anitaShopify
Shopify Staff
5 0 6

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

anitaShopify_0-1721743469388.png