Webhooks
Get a signed POST to your server for delivery reports, inbound messages and campaign events.
A webhook tells your server what happened, so you do not have to keep asking.
Set your webhook URLs
In the dashboard open Developers then Webhooks, or call the API (scope webhooks):
curl -X PUT "https://api.sms.jtnoble.com/v1/webhooks" \
-H "Authorization: Bearer $JTSMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"dlr_url":"https://example.mw/sms/dlr","mo_url":"https://example.mw/sms/inbound","campaign_url":"https://example.mw/sms/campaign"}'const resp = await fetch('https://api.sms.jtnoble.com/v1/webhooks', {
method: 'PUT',
headers: { Authorization: `Bearer ${process.env.JTSMS_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({"dlr_url":"https://example.mw/sms/dlr","mo_url":"https://example.mw/sms/inbound","campaign_url":"https://example.mw/sms/campaign"}),
});
console.log(resp.status, await resp.text());import os
import requests
resp = requests.put(
"https://api.sms.jtnoble.com/v1/webhooks",
headers={"Authorization": f"Bearer {os.environ['JTSMS_API_KEY']}"},
json={"dlr_url":"https://example.mw/sms/dlr","mo_url":"https://example.mw/sms/inbound","campaign_url":"https://example.mw/sms/campaign"},
timeout=30,
)
print(resp.status_code, resp.text)<?php
$ch = curl_init('https://api.sms.jtnoble.com/v1/webhooks');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('JTSMS_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"dlr_url":"https://example.mw/sms/dlr","mo_url":"https://example.mw/sms/inbound","campaign_url":"https://example.mw/sms/campaign"}',
]);
$body = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $body, PHP_EOL;| Field | Receives |
|---|---|
dlr_url | Delivery reports: message.delivered, message.failed and so on. |
mo_url | Inbound messages: message.inbound. See Two-way. |
campaign_url | Campaign events. See Campaigns. |
is_active | false stops all webhooks. |
- The URL must be public. A private or local address is refused with HTTP
400and codeinvalid_webhook_url. Use HTTPS. - An empty string clears a URL. Leaving a field out keeps it.
GET /v1/webhooksshows the current settings and your signing secret.POST /v1/webhooks/testsends a test event to each URL, signed like a real one.POST /v1/webhooks/rotate-secretmakes a new signing secret. Update your server first: the old secret stops at once.
What we send
We POST JSON when a message reaches a final status:
{
"event": "message.delivered",
"message_id": "6f1c2b9e-1d2a-4c55-9a0e-2b7f0c1d3e4f",
"status": "delivered",
"phone": "+2348030000000",
"sender_id": "MYSHOP",
"segments": 1,
"encoding": "GSM7",
"environment": "live",
"livemode": true,
"cost": 35.0,
"cost_currency": "USD",
"batch_id": null,
"campaign_id": null,
"error_code": null,
"error_message": null,
"retry_count": 0,
"delivered_at": "2026-11-05T08:30:06+00:00",
"failed_at": null
}event is message. then the status. batch_id and campaign_id are set on bulk and campaign messages. Sandbox messages have "livemode": false.
Headers:
| Header | Meaning |
|---|---|
X-Webhook-ID | The event id, for example evt_1ac441e57e41455a. It stays the same on every retry. Use it to skip duplicates. |
X-Webhook-Timestamp | Unix seconds of this attempt. |
X-Webhook-Signature-V2 | sha256= then the hex HMAC-SHA256 of <timestamp>.<body>, keyed with your signing secret. Check this one. |
X-Webhook-Signature | sha256= then the hex HMAC-SHA256 of the body alone. Kept for older receivers. |
Check the signature (V2)
Always check before you trust the body:
- Read the raw body, before any JSON parsing.
- Refuse a timestamp more than 5 minutes from your clock. This stops replays.
- Build
<timestamp>.<body>, sign it with your secret, and compare in constant time.
import hashlib, hmac, time
def is_valid(raw_body: bytes, timestamp: str, signature: str, secret: str) -> bool:
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300:
return False
signed = timestamp.encode() + b"." + raw_body
expected = "sha256=" + hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature or "")import crypto from 'node:crypto';
export function isValid(rawBody, timestamp, signature, secret) {
if (!/^\d+$/.test(timestamp ?? '') || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(`${timestamp}.`).update(rawBody).digest('hex');
const a = Buffer.from(expected);
const b = Buffer.from(signature ?? '');
return a.length === b.length && crypto.timingSafeEqual(a, b);
}<?php
function is_valid(string $rawBody, string $timestamp, string $signature, string $secret): bool {
if (!ctype_digit($timestamp) || abs(time() - (int) $timestamp) > 300) {
return false;
}
$expected = 'sha256=' . hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
return hash_equals($expected, $signature);
}
$raw = file_get_contents('php://input');
$ok = is_valid($raw, $_SERVER['HTTP_X_WEBHOOK_TIMESTAMP'] ?? '', $_SERVER['HTTP_X_WEBHOOK_SIGNATURE_V2'] ?? '', getenv('JTSMS_WEBHOOK_SECRET'));Answer quickly
- Reply with a status below
400within 15 seconds. Do slow work after you reply. - If your server fails, we try again after 1 minute, 5 minutes, 30 minutes, 2 hours and 8 hours. That is 6 attempts in all, and they survive a restart on our side.
- Each attempt has a fresh timestamp and signature, and the same
X-Webhook-ID. - The same event can arrive more than once. Use
X-Webhook-IDto ignore repeats.
Delivery log
GET /v1/webhook-deliveries lists recent attempts with the status code your server gave and the start of its answer. POST /v1/webhook-deliveries/{id}/replay sends one again.
See all webhook routes.