I have read a lot of forums and discussions about Webhooks and I just haven't had the "ah ha" moment. What I'd like to accomplish is to have an email sent to the shop owner every time a new customer account is created. I know that I need to setup a Webhook for customers/create.
What I've done so far:
So now I don't know what to do next. Where do I host the Private App files? Do they need to be on an external server apart from the Shopify store? If so, does the external server/domain need an SSL certificate? How do I get the Webhook API call to actually fire? Eventually I know I need to have the JSON contents parsed and then sent in an email to the store owner, but I just don't know how to get the Webhook working and then how to properly retrieve the contents of the JSON sent.
$shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
# Making an API request can throw an exception
$customers = $shopify('POST /admin/webhooks.json', array(), array
'webook' => array
"address": "http://webhookhandler.example.com/webhooks <---not the actual domain I use in my code",
catch (shopify\ApiException $e)
# HTTP status code was >= 400 or response contained the key 'errors'
catch (shopify\CurlException $e)
# cURL error
> Where do I host the Private App files? Do they need to be on an external server apart from the Shopify store?
The trouble with testing your webhooks through the API is that you need a publicly visible URL to handle them. Unlike client-side redirects, webhooks originate directly from the server. This means that you cannot use the following as an endpoint in your testing environment:
- Any URL ending in the word "internal" (i.e. thisshop.com/internal)
- "Fake" domains like www.example.com
- Shopify domains (i.e. shopify.com and myshopify.com)
> If so, does the external server/domain need an SSL certificate?
A Webhook is a tool for retrieving and storing data from a certain event. They allow you to register an http:// or https:// URL where the event data can be stored in JSON or XML formats.
> How do I get the Webhook API call to actually fire?
Depends on the webhook. For customers/create, create a customer.
If you could file an issue on Github, I'll try to add webhook examples into the skeleton.