Webhooks

Webhooks are outbound user-defined HTTP callbacks that originates from Tirix in response to a defined event. An example could be that a shipment has been sent or an article has decreased in stock. When that event occurs and a webhook is configured that matches the events circumstances, Tirix makes an HTTP request to the URL configured for the webhook.

Polling vs subscribing

Webhooks is an alternative to polling for information.

Polling means that you on intervals (every {n} minutes) request information from a service.

The reverse of polling would be to setup that the service on invervals sends information to an external system.

Webhooks by contrast is triggered by an internal event, which has various implications.

Everytime a webhook is triggered, something has happened. What has happened is what is being transmitted to the webhook URL.

Security

Webhook requests made by Tirix include a Signature header. It contains a string generated by hashing the data sent to your webhook endpoint with a secret key. The secret key is a random string that is generated when you create a webhook.

Verifying a signature:

var crypto = require('crypto');
var secret = /* webhook secret */;
var signature = /* signature header */;
var body = /* webhook body */;

var hmac = crypto.createHmac('sha256', secret).update(body).digest('hex');
var signature_verified = (hmac == signature);
$secret = /* webhook secret */;
$signature = /* signature header */;
$body = /* webhook body */;

$hmac = hash_hmac('sha256', $body, $secret);
$signature_verified = hash_equals($signature, $hmac);

Schema: Webhook

PropertyTypeDescription
idObjectIdUnique identifier
nameStringOptional naming of the resource
eventString (Event)Event type that should trigger the webhook
urlStringEndpoint which Tirix should make its HTTP request to
enabledBooleanWebhook only triggers if the enabled property is set to 'TRUE'
tenantObjectIdTenant identifier
secretStringRandom string used to verify a webhook signature
createdDateTime when the webhook was created
updatedDateTime when the webhook was last modified

Enum: Event

EventDescription
webhook.createdA new webhook has been created
webhook.modifiedA webhook has been modified
webhook.deletedA webhook has been deleted
article.createdA new article has been created
article.stock_changedThe stock of an article has changed
delivery.createdA new delivery has been created
delivery.modifiedA delivery has changed
delivery.sentA delivery has been sent

Get a list of webhooks

If you want to retrieve a list of webhooks, use this GET request:

GET https://api.tirix.io/webhooks

Get a webhook

If you want to fetch an individual webhook, use this GET request:

GET https://api.tirix.io/webhooks/{webhook_id}

Create a webhook

If you want to create a new webhook, use this POST request:

POST https://api.tirix.io/webhooks

Modify a webhook

If you want to modify a specific webhook, use this PUT request:

PUT https://api.tirix.io/webhooks/{webhook_id}

Delete a webhook

If you want to remove a specific webhook, use this DELETE request:

DELETE https://api.tirix.io/webhooks/{webhook_id}

TIP

This request will irreversibly delete the webhook. You can alternatively suspend/resume the webhook by modifying its 'enabled' property.

Last Updated: