Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
Hi,
Working on a custom app for a client, the APP is created under the new Shopify app rule as "Custom APP" since we are only going to use it on a particular client's store. We uses Node.js + Express in developing the app backend. We want the APP to register some webhooks, "ORDERS_UPDATED" for example.
During the installation, we make sure the APP has correct access scopes to following:
const scopes = [ 'read_orders', 'read_shipping', 'read_fulfillments', 'read_analytics', 'read_marketing_events', 'read_resource_feedbacks', ];
however, during testing, we got error while trying to create webhook via admin graphQL on ORDERS_UPDATED :
[ { field: [ 'webhookSubscription' ], message: 'You cannot create a webhook subscription with the specified topic' } ]
Here is how we compose the API call:
// Mutation mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) { webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) { userErrors { field message } webhookSubscription { id } } } // Variable { topic: 'ORDERS_UPDATED', webhookSubscription: { callbackUrl: `https://xxx/yyy`, format: 'JSON', }, }
We then tried to create webhook on APP_SUBSCRIPTIONS_UPDATE by just changing the topic to that, it works. We also tried on other webhook topics, looks like anything that is not APP_XXX will fail. We also tried use REST API which failed too with error "status is 422 unprocessable entity"
We are not sure if this is some sort of limitation of the new "Custom APP" (like it cannot be as a sales channel?) or we missed something in access scope definition. Anyone run into the same problem ?
Thanks!!
Solved! Go to the solution
This is an accepted solution.
Hey @yangli_1r ,
It appears that your app may not be correctly getting access scopes from the Shopify merchant's store. The error message you are seeing is typically associated with trying to subscribe to a webhook topic that your app does not have access scope permission for. That would explain why your app can only subscribe to the APP_XXX webhook topics but not any of the store related topics. Can you verify that when the merchant installed the app onto their store that they received a screen in which they had to accept/grant all of the access scopes your app specified? If not, then chances are your app is not properly requesting these scopes, which is why you are getting errors when trying to subscribe to webhooks.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hey @yangli_1r ,
It appears that your app may not be correctly getting access scopes from the Shopify merchant's store. The error message you are seeing is typically associated with trying to subscribe to a webhook topic that your app does not have access scope permission for. That would explain why your app can only subscribe to the APP_XXX webhook topics but not any of the store related topics. Can you verify that when the merchant installed the app onto their store that they received a screen in which they had to accept/grant all of the access scopes your app specified? If not, then chances are your app is not properly requesting these scopes, which is why you are getting errors when trying to subscribe to webhooks.
To learn more visit the Shopify Help Center or the Community Blog.