Ad

How To Create Multiple Webhooks On Shopify Using API At Once

- 1 answer

I am able to create a single webhook using Shopify API for my app.

I'm having hard time finding out a way to make multiple webhooks at once. I want to setup multiple webhooks at once.

Awaiting setup for webhooks one by one takes in a lot of time (not ideal for production).

I have created a shopify service that takes in 2 arguments

  • topic of the webhook (e.g. 'products/create')

  • url for the webhook (e.g. 'mywebsite.com/api/products/create') await shopifyService.createWebhook(ShopifyWebhook.productsUpdate, `${origin}/${ShopifyWebhookUrl.productsUpdate}`);

I would like something like an array of [topic,webhookUrl] that I could send to shopify in one go to create all the webhooks for client.

Much thanks in advance for any kind of help :)

Ad

Answer

If you have a look at Shopify API reference for Webhooks then there is no method for bulk adding Webhooks. Moreover, as much I have worked with Shopify API, I have not found any API method that allows bulk processing not even the ones like bulk product or variant updates etc.

Looking at the code snippet you provided, you are using await that is not required logically because you don't have to wait for the Shopify response to create next webhook as they are independent of each other. So just make your code asynhcronus and send new requests without waiting for the response of previous requests. You may log or retry based on API response when recieved.

Another approach may be is to use Queues where you push all the required jobs and then execute keeping the Shopify API limit in mind. You can also have a look at Shopify Recommendations for such scenarios.

Maximize Your Use of The Shopify API

Ad
source: stackoverflow.com
Ad