Difference between revisions of "API Webhook"

From Spiffy Stores Knowledge Base

(Created page with "Placeholder for API Webhook")
 
Line 1: Line 1:
Placeholder for API Webhook
+
Webhooks are a useful tool for apps that want to execute code after a specific event happens on a store, for example, after a customer creates a cart on the storefront, or a merchant creates a new product in their admin.
 +
 
 +
Instead of telling your app to make an API call every X number of minutes to check if a specific event has occurred on a shop, you can register webhooks, which send an HTTP request from the store telling your app that the event has occurred. This uses far less API requests overall, allowing you to build more robust apps, and update your app instantly after a webhook is received.
 +
 
 +
Webhooks are scoped to the app they're registered to. This means that when a webhook is registered to an app, other apps can't view, modify, or delete it.
 +
 
 +
===Anatomy of a Webhook===
 +
 
 +
When an event occurs in a shop that corresponds to a registered webhook, Spiffy Stores sends a webhook notification to the specified URL. The webhook contains a payload formatted as JSON, as well applicable HTTP headers. For example, the following headers are sent as part of the orders/create webhook.
 +
 
 +
X-Spiffy-Topic: orders/create
 +
X-Spiffy-Hmac-Sha256: XWmrwMey6OsLMeiZKwP4FppHH3cmAiiJJAweH5Jo4bM=
 +
X-Spiffy-Shop-Domain: johns-apparel.spiffystores.com
 +
etc.
 +
 
 +
Some of the returned HTTP headers can be useful for your app. For example, X-Spiffy-Hmac-Sha256 is used to authenticate webhooks, and  X-Spiffy-Shop-Domain is useful for determining the store context. See the webhooks tutorial for more information concerning authenticating webhooks, and the OAuth docs for general information concerning authentication.
 +
 
 +
===List of Supported Webhook Topics===
 +
 
 +
Event data can be stored as JSON or XML. Webhooks can be registered for the following events:

Revision as of 14:10, 10 April 2017

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

Instead of telling your app to make an API call every X number of minutes to check if a specific event has occurred on a shop, you can register webhooks, which send an HTTP request from the store telling your app that the event has occurred. This uses far less API requests overall, allowing you to build more robust apps, and update your app instantly after a webhook is received.

Webhooks are scoped to the app they're registered to. This means that when a webhook is registered to an app, other apps can't view, modify, or delete it.

Anatomy of a Webhook

When an event occurs in a shop that corresponds to a registered webhook, Spiffy Stores sends a webhook notification to the specified URL. The webhook contains a payload formatted as JSON, as well applicable HTTP headers. For example, the following headers are sent as part of the orders/create webhook.

X-Spiffy-Topic: orders/create X-Spiffy-Hmac-Sha256: XWmrwMey6OsLMeiZKwP4FppHH3cmAiiJJAweH5Jo4bM= X-Spiffy-Shop-Domain: johns-apparel.spiffystores.com etc.

Some of the returned HTTP headers can be useful for your app. For example, X-Spiffy-Hmac-Sha256 is used to authenticate webhooks, and X-Spiffy-Shop-Domain is useful for determining the store context. See the webhooks tutorial for more information concerning authenticating webhooks, and the OAuth docs for general information concerning authentication.

List of Supported Webhook Topics

Event data can be stored as JSON or XML. Webhooks can be registered for the following events: