How to listen to Shopify webhook event data with Node.js

Shopify provides webhooks for stores. What is a webhook?

Webhooks are a useful tool for apps that want to execute code after a specific event happens on a shop, for example, after a customer creates a cart on the storefront, or a merchant creates a new product in their admin.



So let’s say we want to notify a fulfilment house (to process and ship our product) as soon as a new order is created on our Shopify store. The fulfilment house may have a very specific format in which they accept an order. So we could write a script that takes the data that Shopify sends us after an order is made, re-format it for the 3rd party, and then do a POST request to them.

There are a few steps to get this done.

Setup the webhook on Shopify

First.. we need to setup a webhook on our Shopify store that calls our script everytime an order is made.



Then we need to select which event we want to trigger for our server to be called. In this example it’ll be “Order creation”.



For the URL, we need:

  1. the domain name or IP address of the server. In this case the fictitious IP address is
  2. our Node.js server might be running on a specific port, in this case 5555
  3. and then for what path we want in our script to start processing the incoming webhook. In this case it will be /new-online-order

Setting up our script

Secondly, we’ll setup a Node.js server to process the incoming new order data sent from Shopify.

You’ll need Node.js setup on your server. I use DigitalOcean. To manually setup Node.js on Ubuntu 16.04 see this guide. Alternatively, DigitalOcean has a one-click install option for Node.js when creating a droplet with them.

For the script, I’ll be setting up a Node.js server that will use the Express module. Shopify sends a HTTP POST request, so we’ll also need the body-parser module.

The core code looks like this:

The only thing you need to change to get started is on line 31 change the path to /new-online-order and the port on line 40 to 5555.

You can then run this on your server by typing

node listen-for-shopify-webhooks.js

Testing time

Create a new order, and you should see this node server console.log a bunch of Shopify data. In this case, it’ll be the new order object where the properties are defined in the Order API.

Where to from here?

Basically just start writing out your script from line 37 in the gist. You can process the data anyway you like, and email it, post it or do anything else you like from there.

Any questions at all, just ask them below.

Have fun with it!

By |2016-11-23T13:08:07+00:00November 23rd, 2016|gist|2 Comments

About the Author:

Andrew Golightly is the lead web developer here at Golightly+. He is a passionate fullstack JavaScript developer. And creates native apps too using React Native. To balance his love for coding, he also works as a counsellor.


  1. Greggory Wiley December 6, 2018 at 10:46 pm - Reply

    Thanks man that was very helpful. Learning to deal with Node JS and the request was coming out to big to get any useful information before processing the body with body parser. I had also tried that approach before based on this , but was only getting {} as a response after that. Your article was an excellent reference point that ended a multi hour hang up.

    • Andrew December 8, 2018 at 9:05 pm - Reply

      Great Greggory. Glad it helped! That’s why I write them.. to save people time meandering online for ages.

Leave A Comment