Webhooks

Webhooks enable external parties/applications to react on events occurring within Stoqflow. A webhook is a URL that Stoqflow calls when a specific event occurs. The external party can then take necessary actions based on the information provided in the webhook.

Via Settings > Webhooks webhooks can be created and managed. A webhook consists of a trigger, some optional filters, and a URL, and can be permanently enabled or within a specified time slot (for example to only call webhooks on orders during a temporary commercial promotion).

Fields

Triggers

For each webhook, a trigger must be chosen. An event where it is checked if the webhook should be called. Some important triggers are for example:

  • When an order is created
  • When inventory is updated
  • ...

Filters

Filters are optional and can be used to determine whether a webhook should be called or not. So, for instance, a webhook can only be called when the order needs to be sent to a specific country or when a product belongs to a specific trade name. The order/product/... must comply with all filters in the webhook before it is called.

URL

The URL that is called when the webhook is activated. This URL must be accessible from the internet and the external party must be able to process the information provided in the webhook.

When are webhooks called?

Webhooks are always executed after the trigger of the webhook has been recorded in the database. This means that if a webhook is triggered when editing an order, the forwarded data will be the updated order data, including all changes made during the edit operation.

Technical details

Webhooks are called via an HTTP POST request to the specified URL. The data provided in the webhook is a JSON object with the data on which the webhook was triggered.

?> Consult our API documentation for more information about the structure of the different objects that can be provided in webhooks.

The webhook request contains additional headers:

  • X-Hook-Trigger: The trigger of the webhook
  • X-Company-Id: The identifier of the company within Stoqflow to which the forwarded data belongs. This can be used, for example, to perform additional API requests.

!> After 5 consecutive negative responses from the specified URL, the webhook is automatically disabled. The webhook can manually be enabled again via the webhook settings.