Intercom webhook verification. Intercom signs each notification with X-Hub-Signature: sha1=<hex>, the HMAC-SHA1 of the raw JSON body keyed with your app's client_secret (Developer Hub → your app → Basic information). Intercom signs no timestamp, so there is no replay window; deduplicate on the notification id (Intercom may resend when your endpoint is slow). See https://developers.intercom.com/docs/references/webhooks/webhook-models.

Context Vars

Optional
  • intercom.client.secret

Functions

signature-from-header

fn (header: Str): Str

Extract the hex digest from an X-Hub-Signature value. Only the sha1= scheme is accepted; anything else yields "", which never verifies. Exposed for testing.

Example

::intercom::webhooks/signature-from-header("sha1=abc123")  // "abc123"
::intercom::webhooks/signature-from-header("sha256=abc123")  // ""

verify-request

fn (request: Map): Bool
fn (request: Map, secret: Str): Bool

Verify an Intercom webhook request: the x-hub-signature header must be sha1= plus the hex HMAC-SHA1 of the raw body under the app's client secret, compared in constant time. Uses the intercom.client.secret context variable by default (failing when it is unset), or accepts an explicit secret. An empty explicit secret never verifies.

Example

intercom-webhook
meta {webhook: {service: "intercom", path: "/intercom/webhook"}}
fn (request) {
  if(not(::intercom::webhooks/verify-request(request)),
    ::hot::http/HttpResponse({status: 401, body: "invalid signature"}),
    ::hot::http/HttpResponse({status: 200, body: "ok"}))
}
Context Vars: intercom.client.secret