Free tool · runs in your browser
Twilio webhook signature validator: check X-Twilio-Signature
This page validates a Twilio webhook in your browser: paste the auth token, the exact URL Twilio requested, the X-Twilio-Signature header and the form body, and it tells you whether Twilio sent it and why validation fails.
Verify a Twilio signature
The verifier opens on a sample Twilio request signed with a demo secret. Replace the secret, headers and body with your own. Everything is computed in your browser; nothing you paste is sent.
The interactive tool needs JavaScript. The same core runs locally: npx @teamshift/webhook-inspect
How Twilio signs a webhook
| Header | X-Twilio-Signature |
|---|---|
| Signed content | The full URL Twilio requested, including the query string, followed by every POST parameter sorted by name, each name and value appended with no separator |
| Algorithm and encoding | HMAC-SHA1, base64 |
| Secret | The auth token of the account or subaccount that owns the number |
| Replay protection | None in the signature. Deduplicate on the message or call SID (MessageSid, CallSid). |
A minimal check in Node.js
import crypto from 'node:crypto';
const sameBytes = (a, b) => a.length === b.length && crypto.timingSafeEqual(a, b);
// rawBody: the form-encoded POST body exactly as it arrived
export function verifyTwilio(url, rawBody, header, authToken) {
if (typeof header !== 'string') return false;
// Every name and value appended to the URL, sorted by name. A repeated name contributes each distinct value, sorted.
const pairs = [...new Set([...new URLSearchParams(rawBody)].map(([name, value]) => JSON.stringify([name, value])))].map((pair) => JSON.parse(pair));
pairs.sort(([a, x], [b, y]) => (a < b ? -1 : a > b ? 1 : x < y ? -1 : x > y ? 1 : 0));
const data = pairs.reduce((text, [name, value]) => text + name + value, url);
const expected = crypto.createHmac('sha1', authToken).update(data).digest('base64');
return sameBytes(Buffer.from(header), Buffer.from(expected));
}Pass the body exactly as it arrived, before any parsing. The tool on this page runs the same check and, when it fails, tries the common fixes to tell you which one applies.
Why Twilio verification fails
- The URL differs. Twilio signs the public URL it called. Behind a proxy or tunnel your server may see
http://or an internal host instead of the publichttps://address. - The query string or a trailing slash was dropped. Both are part of the signed URL.
- The wrong auth token was used. A subaccount signs with its own token, and rotating the token changes signatures at once.
- The body is JSON. For JSON webhooks Twilio signs the URL alone and adds a
bodySHA256query parameter that hashes the body.
Test your own endpoint
Enter your endpoint URL under "Send a signed test request to your endpoint" and the tool writes a curl command signed the way Twilio signs. Run it in a POSIX shell (macOS, Linux, WSL or Git Bash) to confirm your handler accepts a good signature, then change one character of the body and confirm it is rejected.
Other providers
- Stripe webhook signature verifier
- GitHub webhook signature verifier
- Shopify webhook signature verifier
- Slack webhook signature verifier
The main verifier also handles any generic HMAC header.
FAQ
How do I validate a Twilio webhook signature?
Take the exact URL Twilio requested, append each POST parameter name and value in alphabetical order of name, compute HMAC-SHA1 with your auth token, base64-encode it, and compare it to the X-Twilio-Signature header in constant time.
Why does Twilio signature validation fail behind a proxy or ngrok?
Because the URL your code rebuilds is not the URL Twilio signed. Use the public https URL configured in Twilio, including its query string, not the scheme and host your server sees after the proxy.
Is it safe to paste my secret here?
The page sends nothing: the signature is computed in your browser with WebCrypto, and no field is stored or uploaded. Even so, prefer a test secret, and rotate any live secret you have pasted into a tool you do not control.