#
Webhooks
Webhooks allow you to receive real-time updates about SMS delivery statuses and other events by automatically sending data to a specified URL whenever an event occurs.
During the onboarding process, please provide us with the webhook URL you'd like to use for receiving delivery reports.
#
Authorization
To ensure webhook requests are secure and come from us, each request will include an X-Signature header.
You can verify this signature using your Webhook Secret and the raw payload of the request.
import crypto from "crypto"
export function verifyWebhookSignature(receivedSignature, secret, payload) {
const expectedSignature = crypto
.createHmac("sha256", secret)
.update(payload)
.digest("hex")
const receivedBuffer = Buffer.from(receivedSignature)
const expectedBuffer = Buffer.from(expectedSignature)
// Ensure both Buffers have the same length
if (receivedBuffer.length !== expectedBuffer.length) {
return false
}
// Perform constant-time comparison
return crypto.timingSafeEqual(receivedBuffer, expectedBuffer)
}
<?php
function verifyWebhookSignature($receivedSignature, $secret, $payload) {
// Generate the expected signature using HMAC-SHA256
$expectedSignature = hash_hmac("sha256", $payload, $secret);
// Use hash_equals for constant-time comparison
return hash_equals($expectedSignature, $receivedSignature);
}
#
Request
A webhook request is sent as a JSON object and contains the following body:
#
Message status
The following statuses are available: