Shopify webhooks are a way for developers to create integrations with Shopify. Webhooks can be used to automate your Shopify store, send notifications about events that occur on the Shopify platform, and more.

They may be utilized to automate Shopify store activities, such as creating a new order in Shopify when an item from Shopify’s marketplace is purchased.

Shopify supports extensibility with Shopbot’s webhooks, which allow businesses to integrate third-party applications or platforms into their store. This might imply refreshing inventory levels after a transaction is completed on the Shopify store (so that the Shopify store can remain up to date on how much product is available).

Webhooks may be used to connect Shopify to an app and convey information from a store to the program as a notification. The alert Shopify sends contains data about the occurrence that caused the event.

The ability to respond to Shopify data updates using webhooks eliminates the extra cost of manually polling the Shopify API for new information. In this post, we’ll look at Shopify webhooks and provide best practices for utilizing them.

Shopify Webhooks overview

Webhooks are a useful tool for apps that want to sync with Shopify or execute code after a certain event happens in a shop. For example, you could want to perform an activity whenever a company adds a new product in Shopify’s admin or when a client places an order.

This article explains how webhooks work and how to set up a webhook for your app as well as handle webhooks for different API versions.

What is Shopify webhooks?

A Shopify webhook is a single message sent to an app’s webhook subscription endpoint by Shopify. The body of a shopify webhook is made up of JSON or XML, while the headers include metadata.

Webhooks are currently being used by most business owners for the following purposes:

  • Changing the price of a product
  • Creating an order is easy.
  • Accountancy software is integrated.
  • Notifying your pager or IM clients when you are disconnected
  • Getting data to the warehouse
  • When a customer uninstalls the program, the data is permanently deleted from your database.
  • Notifying carriers about shipments and filter orders.

How do Shopify webhooks work?

When an event matching the topic your app is subscribed to occurs, the webhook subscription sends a webhook to an endpoint.

An app server generates a webhook subscription on the orders/create the topic and an HTTPS endpoint hosted by the app server, for example. When an order is placed on the shop, the webhook subscription sends a webhook with an order payload to the registered endpoint.

Orders’ information might change frequently. Instead of polling for order changes constantly, you may receive a webhook whenever a certain event occurs.

Diagram showing how webhooks work

Establishing Shopify webhooks

Webhooks are notifications that may be used to update applications. To receive webhook events, you must create an endpoint that receives them and designate them as the destination for the webhook subscription.

Webhook subscriptions are registered only to the app that they’re linked to. When a webhook subscription is created for an app, it is scoped to that particular program and can’t be viewed, modified, or deleted by other programs.

Always replace your local shop data with the webhook payload if your application must keep up with Shopify.

To learn more about setting up shopify webhooks, see the overview of webhook configuration.

Shopify Webhook headers

A message’s payload and body both contain a number of headers that provide further information.

For example, a webhook for orders/create contains the following headers:

  • X-Shopify-API-Version: 2021-07
  • X-Shopify-Topic: orders/create
  • X-Shopify-Shop-Domain: johns-apparel.myshopify.com
  • X-Shopify-Webhook-Id: b54557e4-bdd9-4b37-8a5f-bf7d70bcd043
  • X-Shopify-Hmac-Sha256: XWmrwMey6OsLMeiZKwP4FppHH3cmAiiJJAweH5Jo4bM=

Some headers are particularly beneficial to your app. For example, X-Shopify-Hmac-Sha256 is used to validate webhooks sent via HTTPS, X-Shopify-Webhook-Id is used to identify distinct webhooks, and X-Shopify-Shop-Domain is used to identify the store that they belong to.

Shopify Webhook ordering

Webhooks are sent in chronological order for each resource and subject combination. This implies that each product/update webhook for the same product is delivered one after another.

However, the ordering of separate subjects for the same resource is not guaranteed. It’s conceivable that a products/update webhook will arrive before the product/create webhook.

Supported Shopify webhook events and topics

We learned about Shopify webhooks and the ways they’re used. The following is a list of Shopify webhook events and topics that are supported.

  • add table here

The following is a quick rundown of all you can accomplish with Shopify’s webhook resource. Let’s look at how to create Shopify webhooks in just a few easy steps now.

How to create Shopify webhooks?

Step 1: Go to Notifications

You’re probably on your Shopify admin page right now. After that, be sure to select Settings from the left-hand menu and then Notifications.

How to create Shopify webhooks

Step 2: Go to the Webhooks section

To locate the Webhooks portion, scroll down.

How to create Shopify webhooks

Step 3: Click Create webhook

To create a webhook, click the Create webhook button after you’ve found the Webhooks section. A new dialog will appear when you select it now.How to create Shopify webhooks

Step 4: Select Event

The drop-down menu for this option is called “Receive an Event.” It contains the following options:

How to create Shopify webhooks
  • Cart creation: a webhook will be sent every time a cart is created.
  • Cart update: a webhook will be sent every time a cart is updated.
  • Checkout creation: a webhook will be sent every time a checkout is created.
  • Checkout deletion: a webhook will be sent every time a checkout is deleted.
  • Checkout update: a webhook will be sent every time a checkout is updated.
  • Collection creation: a webhook will be sent every time a collection is created.
  • Collection deletion: a webhook will be sent every time a collection is deleted.
  • Collection update: a webhook will be sent every time a collection is updated.
  • Customer group creation: a webhook will be sent every time a customer group is created.
  • Customer group deletion: a webhook will be sent every time a customer group is deleted.
  • Customer group update: a webhook will be sent every time a customer group is updated.
  • Customer creation: a webhook will be sent every time a new customer is created.
  • Customer deletion: a webhook will be sent every time a customer record is deleted.
  • Customer disable: a webhook will be sent every time a customer account is disabled.
  • Customer enable: a webhook will be sent every time a customer account is enabled.
  • Customer update: a webhook will be sent every time a customer record is updated.
  • Draft order creation: a webhook will be sent every time a draft order is created.
  • Draft order deletion: a webhook will be sent every time a draft order is deleted.
  • Draft order update: a webhook will be sent every time a draft order has been updated.
  • Fulfillment creation: a webhook will be sent every time a fulfillment is created on an order.
  • Fulfillment update: a webhook will be sent every time fulfillment is updated on an order.
  • Order cancellation: a webhook will be sent every time an order is canceled.
  • Order creation: a webhook will be sent every time an order is created.
  • Order deletion: a webhook will be sent every time an order is deleted.
  • Order fulfillment: a webhook will be sent every time an order is fulfilled.
  • Order payment: a webhook will be sent every time an order has been paid.
  • Order update: a webhook will be sent every time an order has been updated.
  • Product creation: a webhook will be sent every time a product has been created.
  • Product deletion: a webhook will be sent every time a product has been deleted.
  • Product update: a webhook will be sent every time a product has been updated.
  • Refund create: a webhook will be sent every time a refund is issued.
  • Shop update: a webhook will be sent every time a shop property is updated.
  • Theme creation: a webhook will be sent every time a theme is created.
  • Theme deletion: a webhook will be sent every time a theme is deleted.
  • Theme update: a webhook will be sent every time a theme property is updated.

Step 5: Select the format between JSON or XML

The next drop-down is where you should change the content type. Select between JSON or XML as the format you expect to receive data from Shopify.

How to create Shopify webhooks

Step 6: Enter the URL

How to create Shopify webhooks

The URL section is where you may enter a URL to save data. Please keep in mind that webhooks do not accept the following URLs:

  • Any URL that ends with the word internal (i.e. thisshop.com/i Internal)
  • Localhost
  • Shopify domain names (i.e. shopify.com and myshopify.com)
  • FAKE domains like http://www.example.com

Step 7: Tap on Add webhook

Once you’ve entered the URL, enable the Save webhook button. You may now view your webhook in the Webhooks field.

Step 8: Optional: Test your webhook

You can test your webhook by clicking on the send test notification link to ensure that the information you want is sent to the correct URL. To ensure that your webhook is sending data as intended, check out the URL you’ve provided.

How to create Shopify webhooks

Best Practices for Working with Shopify Webhooks

This portion goes through some of the greatest practices for working with shopify webhooks.

#1. Respond to webhooks quickly

It’s critical to respond to a webhook request with a 200 OK as soon as possible after receiving one using an HTTPS endpoint.

A typical implementation is to queue the payload for later processing by a background employee. This lowers the risk of the request failing due to timeouts and triggering an error status on webhook delivery.

#2. Recover webhooks

You can restore your webhook after your app goes down for an extended amount of time by re-registering it and importing the lost data if required.

To re-register a webhook, look at the source code that originally set up the webhook. You may use a check to register only those webhooks that are required.

You can use your webhook processing code to import the missing data.

#3. Delayed webhooks

In extreme cases, you might not receive webhooks for a short period of time. Webhooks are always sent with the most up-to-date data for each resource, however.

The payload of the webhook should represent the most up-to-date properties of the resource between the moment of the webhook’s activation and when it is delivered.

If webhooks are received up to a day late, we recommend comparing the time stamp on the webhook to today’s date.

#4. Implement reconciliation jobs

Your app shouldn’t be solely reliant on Shopify webhooks for data. Because webhook delivery isn’t always guaranteed, you should use reconciliation jobs to retrieve data from Shopify on a regular basis.

#5. Use supported filter parameters

Both the created_at_min and updated_at on a job’s query endpoints allow both of these parameters. These filters may be used to construct a process that retrieves all resources that have been generated or last modified since the previous execution of the task.

#6. Build a scalable and reliable system

When you’re first getting started with Shopify, it might be difficult to keep track of all the traffic coming your way.

You may use subscriptions to send webhooks to Amazon EventBridge and Google Cloud Pub/Sub if you need to manage a high number of event notifications in order to create a scalable and reliable system.

How to Configure Shopify webhooks?

Shopify’s webhooks can be configured in 2 methods: using the API or setting them up in your Shopify admin.

You must create an HTTP POST request if you want to utilize the API. Then, send it to the Webhook resource in the REST Admin API.

You can follow 3 easy steps to set up your Shopify webhook from shopify admin:

  • Step 1: Make certain to visit the Notifications section on your admin page and check Settings.
  • Step 2: Tap on Create a webhook in the Webhooks field.
  • Step 3: Select the format between JSON or XML that you expect to listen to.

You’ll need to validate the integrity of your Webhooks after you finish making them. Continue reading to learn how to test Shopify webhooks in this section of the tutorial.

How to test Shopify webhooks?

You can utilize a publicly accessible service like Beeceptor, or you may even operate the local server.

If you want to run a local server, such as one for development or testing, you’ll need to make it public using a service like ngrok or Pagekite.

The following URLs are not valid webhook endpoints:

  • Any URL that ends with the word internal (i.e. thisshop.com/i Internal)
  • Localhost
  • Shopify domain names (i.e. shopify.com and myshopify.com)
  • FAKE domains like http://www.example.com

You can test your shopify webhook by entering the following commands in your Shopify admin:

  • Step 1: Look for the Webhooks option in the Notifications field.
  • Step 2: Tap the Send test notification button beside the webhook you anticipate will be tested.

You may see a test webhook sent to the specified webhook URL.

How to create an endpoint for Shopify webhooks?

You must keep in mind that your endpoint’s security requirements must be met by the fact that it has an HTTPS webhook address with a valid SSL certificate.

It also ensures that Shopify event notifications are handled appropriately. Furthermore, you must implement a verification procedure to guarantee that the webhook requests come from Shopify.

#1. Payloads

Each payload will contain an XML or JSON object, as well as data for the webhook event, for each request. The form and content of each payload vary depending on the event that has been registered.

#2. Receiving a webhook

Every time an event occurs, Shopify sends you an HTTP POST request via the webhook URL you just registered. The request contains data in the JSON / XML format, including POST variables. The event’s parameters have been activated by these values.

If you’re uploading payloads to Shopify’s webhook HTTPs, it will check the SSL certificate. Make sure your server has a standard HTTPS configuration. In addition, the SSL certificate is verified.

#3. Responding to a webhook

It’s clear that your webhook sends data back by returning a 200 OK response. Because of this, you will not receive webhooks for any response outside the 200 range (including 3XX HTTP redirect code).

If you don’t use a redirect in your webhook notification, Shopify will label it as an error response and will not record webhook responses.

#4. Frequency

For each webhook, Shopify has set a five-second waiting period. This means Shopify will wait five seconds before responding to each request for a webhook.

Shopify has also included a retry period for subscriptions. It will attempt to reconnect 19 times per next 48 hours in the event of a failure or lack of response.

The session will be deleted if all 19 test attempts are unsuccessful in a row. The subscription of the application’s emergency developer will be canceled with an email notice.

To avoid such problems, consider delaying application processing until you’ve successfully provided webhook feedback.

How to delete Shopify webhooks?

As a business owner, you can make excellent judgments when running the store. Webhooks are an efficient tool if you use them correctly.

Everything, however, has two aspects. So if you no longer want to use webhooks or find them inconvenient, please follow these four easy instructions below.

Step 1: Go to Notification

You should be on your Shopify admin page right now. Then, go to the Notifications setting and choose it.

How to delete Shopify webhooks

Step 2: Find the Webhooks section

To discover the error, go to Settings -> Look for the Webhooks section at the bottom of the page.

How to delete Shopify webhooks

Step 3: Find a little trash can icon

There must be a webhook you wish to delete. Look for a little trash can symbol next to the webhook.

How to delete Shopify webhooks

Step 4: Tap on the trash can icon

You’re almost done. The last thing you have to do is tap the trash can icon. Everything is finished.

Conclusion

So far, we’ve gone through Shopify webhooks in detail. Hopefully, you’ll gain a better understanding of webhooks and how to use them properly after this lesson. Otherwise, you may just remove it with these easy steps above.

Author

CEO and co founder of AdNabu. Exploring the intersection of data and marketing