Functions
verify-request
fn (request: Map): Bool
fn (request: Map, auth-token: Str): Bool
fn (request: Map, auth-token: Str, url: Str): Bool
Verify a Twilio webhook request signature using HMAC-SHA1. Returns true if the request is authentic.
Uses the twilio.auth.token context variable by default, or accepts an explicit auth token as a second argument.
For form-encoded callbacks Twilio signs the full request URL plus all
POST body parameters sorted by key. For JSON callbacks (configured with
a bodySHA256 query parameter) it signs the URL alone, and the body is
checked against the SHA-256 in the query. Both modes are handled
automatically, keyed on the presence of bodySHA256.
The URL is taken from request.original-url (the URL as Twilio
requested it, delivered by the platform). The 3-arity form takes the
URL explicitly for when the reconstructed value differs from what is
configured at Twilio — e.g. a rewriting proxy in front, or a plain
http:// endpoint behind an edge that doesn't set
x-forwarded-proto (reconstruction defaults to https).
Example
check fn (request: ::hot::http/HttpRequest): Bool {
// Using context variable (1-arity)
a ::twilio::webhooks/verify-request(request)
// With explicit auth token (2-arity)
b ::twilio::webhooks/verify-request(request, "your-auth-token")
// With the exact configured URL (3-arity)
c ::twilio::webhooks/verify-request(request, "your-auth-token", "https://example.com/hooks/sms")
and(a, b, c)
}
twilio.auth.token