
Webhooks with Headless Shopify
Shopify provides webhooks as a way for your store to “talk to” external applications, sending data upon certain actions that might occur in Shopify.
For example, a webhook notification can be dispatched by Shopify each time a new order comes in, or every time a product in the store is updated by a staff member. An external application can then be configured to listen, and respond to these events.
Webhooks have a powerful place in multi-application, cross-platform, or composable setups, where providing a way for external apps to be notified when something specific occurs in Shopify.
They’re commonly used for two primary reasons in headless builds – to automate processes that would otherwise require manual action, or to connect and integrate other applications with Shopify so that they can respond to events that take place in the store.
Some practical examples:
External search application
Headless Shopify builds commonly use external search platforms for frontend search implementation, as they bring a wealth of targeted, additional functionality which helps to augment and enhance frontend search experiences for your store’s customers.
An external, composable search platform may even be a mandatory addition for headless Shopify stacks that integrate with a headless CMS, as the search index must be populated with records from multiple applications (i.e. both Shopify and the headless CMS), which Shopify’s native search functionality doesn’t cater to.
By using webhooks, product records in the external search platform can be updated immediately upon changes made within the Shopify store.
External CMS
A sizable number of our headless Shopify builds are coupled with a separate headless CMS that aids content creation and improves the workflow of editorial teams. This “separation of concerns” between Shopify and a headless CMS requires a connection between the two if data housed in Shopify needs to be referenced from within the headless CMS.
For example, creating a landing page within the headless CMS that requires a “recommended products” grid will require some kind of data synchronization or at least availability from within the headless CMS to reference products held in Shopify (unless the headless CMS is the principle source of truth for product data as well as content).
With webhooks, changes or additions to Shopify-held product data can be synchronized or made-available to an external headless CMS, allowing greater flexibility for content creation within editorial and marketing departments.
To trigger a rebuild of the frontend
For static Shopify stores that use SSG, rebuilds of the frontend can be automated through event triggers, such as webhooks. Upon updating content in the Shopify store, select webbooks can be dispatched in order to trigger a site rebuild, or a partial rebuild, in order to maintain fresh content on the frontend. Many continuous delivery platforms, such as Netlify, offer API access which allows rebuilds to triggered automatically.
Third party software such as ERP, OMS, and CRM integration
Many of the popular ERPs, OMSs and CRMs have de facto integrations or Shopify apps that can connect directly with Shopify to sync up your data. But in particularly nuanced cases, where your project requires a different formatting of data compared to what an app provides, you’ll need to rely on a custom, events-based integration that maps and transforms data from Shopify into your preferred format within the external software.
This is particularly the case for things like custom Draft Orders or custom line item attributes (or meta fields) which you need available in your external software. Using webhooks in a scenario like this will allow for Shopify data to be transformed by a middleware (such as a serverless function hosted on the edge), and then injected into an external ERP (or any external application) in the format that you explicitly require.
We're the experts in Headless Shopify.
Your search for answers ends here. Discover our services.
Explore Headless Shopify ServicesGot more questions? Speak with a Pro.
More on Headless Shopify
Let's talk Shopify.
We build modern digital experiences for disruptive brands.
Tell us about your project, and we'll get back to you with details on how we can make this happen.