API REST: Webhooks


A Webhook (also called Callback URL) is a web address called when an event occurs on your Hiboutik account.
Ex : when you close a sale (=event), Hiboutik can send the sale data to a specific Webhook Sales.
You can setup different Webhooks for many different events, in the “Settings/General settings” section of your Hiboutik account.


1/ Why a webhook is a useful tool ?

A Webhook allows a dynamic behavior like invoking one or several scripts when an event occurs.

Here are some examples :
When you close a sale, you can sync the inventory of your website or send automatically a survey to your customer.
When you create a product, you can launch a script to add also the product into your website back-office.
When you update a customer form, you can automatically send him an email confirming the modification.

In general, you can initiate one or several actions when an event occurs, like sending an SMS as well as changing the light intensity in your shop.

You don’t need anymore to ask every second or minute to Hiboutik if the event happens. Hiboutik is telling you that the event has occurred. You save resources (API calls) and time (instantly informed).


2/ How does a Webhook work in Hiboutik ?

Webhooks are specific to each point of sale in a multi-stores account.

Events that can activate a Webhook are :

Webhook name Events – notes
Sales Validation of a sale.
Add a product Adding a product to a sale.
Sales Click on the callback icon in the sale.
Payment Select/add/delete a payment method in a sale.
Customers Add/modify/delete a customer form (including updates on tags or referrers).
Store credit Add a store credit line in a customer form.
Products Add/modify/delete a product form.
Stock orders Receive/Unreceive a stock order including any update on quantities in a stock order.
The validation of an inventory count, as it generates a stock order, also activate this webhook.
Timestamp Start/stop a timeline.
Schedule Add/modify/delete a schedule event.
Transfer Validation of a transfer between stores.
Return/exchange Return/exchange of a product in a sale.


Data are sent in POST with a JSON-encoded format to you Webhooks, and are specific to the event that triggered the request.
For example, the Webhook Sales will receive the following data (resource GET /sales/{sale_id}):
– Customer information and addresses,
– Products sold with all linked data (barcode, SKU, description…),
– Tax splitting and totals,
– Payments types and due dates,
– and all specific information on the sale (notes, sales person, status,…).

If necessary, you can then use the Hiboutik API to get more information.


3/ Case study : Webhook and the loyatly program

In each product form, you can register loyalty points earned when the customer purchases the product. Loyalty points are invariable.
But if you are selling an open price product (price is entered directly in the sale and can change from a sale to another), it is not possible to link it to proportional loyalty points.
To solve this problem, we will use the Hiboutik API to recalculate loyalty points when a sale is closed.

a/ Download and install the script
Recover your API credentials in “Settings/Users/API”.
Download the following script and modify it with your account name, your email address and your API key (line 20, 21 & 22) :
Install the script on your hosting solution and make it executable.

b/ Setup your Webhook
In “Settings/General settings”, enter the URL address of your script in the “Webhook Sales” field.
Ex : http://mydomain.com/fidelite.php

Now, when a sale is closed, it will automatically recalculate your loyalty points according to the rule you enter into your script.

the owl has written 47 articles