Plans: Premium, Enterprise Platforms: All Platforms
Overview
Webhooks act as a gateway to receive raw data at a particular destination that you define. Webhook is used to ask AfterShip to push back any updates to your system. This is used when the store wants to send out notifications by itself or receive the latest delivery status/checkpoint. Users can select when to ask AfterShip pushes back delivery updates when using webhook.
How to setup webhook
Go to notification settings in your AfterShip Tracking admin.
Add webhook URL (up to 10).
Select Events to start receiving updates.
AfterShip verifies the webhook by sending a POST request to the provided URL. The webhook would be added successfully upon responding 200 HTTP status code.
How to secure webhooks
Webhooks(v4.3 or above) include a calculated digital signature for verification. Each webhook request includes an aftership-hmac-sha256 header. The signature is a base64-encoded HMAC generated using the SHA-256 algorithm with the webhook request body and webhook secret of your account.
Each webhook request could be verified by comparing the computed HMAC digest and the attached HMAC digest in the header.
The following Node.js example demonstrates the computation of a webhook signature.
const crypto = require('crypto');
const WEBHOOK_SECRET = "....."; // your webhook secret
function generateSignature(requestBodyString) {
return crypto
.createHmac('sha256', WEBHOOK_SECRET)
.update(requestBodyString, 'utf8', 'hex')
.digest('base64');
}
Please note that the webhook secret can be obtained by going to Settings > Notifications.
In case you need any further assistance, please contact our support team.