Which is the best way of adding webhook in shopify?

One method is by adding the webhooks in the shopify.app.toml file, and the other is by using a GraphQL mutation query to set up the webhooks.

Like anything, it depends.

shopify.app.toml approach

Pros

  • Faster to get started
  • No need to manually managed webhook registration

Cons

  • Cannot modify webhooks per merchant

GraphQL manual registration

Pros

  • More granular control, you can create specific webhooks for specific merchants
  • You can also define filters per merchant

Cons

  • You have to manage registering/removing webhooks based on installs or settings changes
1 Like

Just to add to what @Dylan said, the main reason I’ve seen for still using the GraphQL manual registration is if you want to configure webhooks to receive messages from specific metafieldNamespaces. That’s still not supported with the shopify.app.toml approach.

If you know you’re going to have the same webhooks for all stores though, and you don’t need to use metafieldNamespaces, the shopify.app.toml method is probably best.

Also, in case you haven’t seen it, there’s also a good comparison of the two methods in the Shopify docs that might help you to decide.