The Webhooks configuration API, including the Webhook Settings and Webhook Rules resources, has been released as a Public Beta product. Before Twilio declares this product as Generally Available, the information contained in this document might change. Twilio might implement additional features or change others. No Twilio SLA covers Public Beta products.
By default, Twilio signs webhooks with your account authentication token and you validate that signature to confirm a request came from Twilio. A SharedKey replaces that token with a signing key you create and control.
Two reasons to use one. It isolates webhook signing from your master account credential, so a key exposed in one integration doesn't implicate your account token. And it lets you rotate signing keys without touching account credentials.
Signing is independent of authentication. A signature proves the request wasn't altered in transit; authentication proves Twilio is allowed to call your endpoint. Use at least one, over HTTPS.
How signing with a shared key works
You create a SharedKey and store the returned secret.
You create a Webhook Setting whose signature names that key and a signing algorithm.
You apply the Setting to your webhooks with a Webhook Rule.
Twilio signs each matching webhook with the key and sends the signature in X-Twilio-Signature, along with the key's identifier in X-Twilio-Signature-Key-Sid.
Your endpoint validates the signature using the stored secret.
The X-Twilio-Signature-Key-Sid header tells you which secret signed a request. When it's absent, Twilio signed with your account authentication token.
SharedKey properties
Property
Type
Necessity
Description
id
string
read-only
The key's identifier, in the form webhooks_sharedkey_ plus 26 characters.
friendlyName
string
optional
A name to identify the key. Up to 255 characters. Defaults to blank.
secret
string
read-only
The signing secret. Returned only when you create the key.
createdAt
string
read-only
When the key was created, as an ISO 8601 timestamp.
updatedAt
string
read-only
When the key last changed, as an ISO 8601 timestamp.
Sign your webhooks with a shared key
Use a test account with non-production traffic first.
Get an API key SID and secret. Create one of type Main or Standard if you don't have one.
The secret appears only in this response. No later request returns it, and it can't be recovered. Store it in your secrets manager before you continue.
Extend your webhook endpoint so it validates signatures with the new secret as well as your account authentication token, choosing between them on the presence of X-Twilio-Signature-Key-Sid. Supporting both is what makes the cutover and any later rotation zero-downtime.
Create a Setting that signs with the key. algorithm accepts HMAC_SHA1 or HMAC_SHA256, and can't be changed after creation. auth is required, so use scheme: NONE if Twilio shouldn't also authenticate itself.
Poll the returned Operation until its status is COMPLETED. Propagation takes 30 to 60 seconds, and matching webhooks may use the previous configuration until then.
Choose a signing algorithm
algorithm
Notes
HMAC_SHA256
Preferred for new integrations.
HMAC_SHA1
Matches Twilio's legacy signature scheme.
Because algorithm is fixed at creation, changing it means creating a new Setting and moving your Rule onto it.
Rotate a signing key with no downtime
SharedKeys are immutable apart from friendlyName, and a Setting's signature can't be edited, so rotation replaces both.
Create a new SharedKey and store its secret.
Add the new secret to your endpoint's validation logic, keyed on X-Twilio-Signature-Key-Sid, while keeping the old one.
Move your Rule onto the new Setting, gradually if you want to validate on live traffic first.
Once the Operation completes and traffic is fully on the new key, delete the old Setting, then the old SharedKey, then remove the old secret from your endpoint.