TABLE OF CONTENTS
- What are Webhooks?
- How can I add a Webhook?
- When you receive a Webhook, you can expect statuses with the following content
- Response Code
What are Webhooks?
A webhook in web development is a method of augmenting or altering the behaviour of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Jeff Lindsay in 2007 from the computer programming term "hook".
When an event occurs, information is sent to the endpoint via an API key. Webhook event data can be stored as JSON or XML.
Common cases where webhook is used include the following:
- Send notifications to clients for quick access
- Collection of data for storage
- Integration with accounting software
- Filtering order items and informing ordering companies
- Customer data is removed from the database
How can I add a Webhook?
Go into your control panel > Settings > Webhooks > Add a webhook.
API key - From here, you select the API key. You can add "Default": This is the one you have automatically created in your store. You can also create a new API Key from the Settings > API keys.
Destination URL - This is the URL where the webhook will be sent.
Fire when - Here you choose the action for when the webhook will be executed.
Use new hook structure - Gives you the ability to use a webhook with orders
An example I: If there is a new order, the action will execute the webhook to the destination of the specified URL.
An example II: You can see an example Webhook here: Order.json
When you receive a Webhook, you can expect statuses with the following content:
Order status: pending, voided, timeouted, cancelled, failed, refunded, paid, complete
Payment status: requested, pending, held, completed, failed, refunded, cancelled, timeouted
Fulfilment status: not_fulfilled, fulfilled
There is a mechanism that monitors the response code returned by the recipient. If the response code is 200, everything will be fine. If the response code is different from 200 or delays more than 5 seconds with the answer we will repeat the attempts to deliver the information up to 5 times.
Тime interval between attempts:
1 - Sent in real-time
2 - Sent after 60 seconds from the previous one
3 - Sent after 120 seconds from the previous one
4 - Sent 180 seconds from the previous one
5 - Sent after 240 seconds from the previous one
6 - Sent after 300 seconds from the previous one
After 6 unsuccessful attempts, if the information is not received, it will not be sent again. If we receive response codes 400, 401, 403, 404, 405, 406, 410, 411 we will deactivate the webhook in the store administration. If we receive in the answer the text "please unsubscribe me" then this webhook will be deleted from the administration of the store.