Webhook request validation.
Verifies that incoming HTTP requests are genuinely from Twilio using HMAC-SHA1 signature verification.
Form-encoded webhooks (standard)
url = "https://myapp.com/webhooks/twilio"
signature = get_req_header(conn, "x-twilio-signature") |> List.first()
Twilio.Webhook.valid?(url, params, signature, auth_token)JSON-bodied webhooks
Twilio.Webhook.valid_body?(url, raw_body, signature, auth_token)
Summary
Functions
Build the SHA256 hash of a request body (for JSON webhook validation).
Build the expected HMAC-SHA1 signature for a request.
Validate an incoming webhook request signature.
Validate a webhook with a JSON body.
Functions
Build the SHA256 hash of a request body (for JSON webhook validation).
Build the expected HMAC-SHA1 signature for a request.
Validate an incoming webhook request signature.
Concatenates the URL with sorted POST parameters, computes HMAC-SHA1 with the auth token, and compares to the signature.
Validate a webhook with a JSON body.
For JSON-bodied requests, Twilio signs the URL with the body's SHA256 hash
appended as a bodySHA256 query parameter.