Sentry integration-platform webhook verification. Sentry signs each delivery with Sentry-Hook-Signature: the hex HMAC-SHA256 of the raw body, keyed with the integration's client secret. It also sends Sentry-Hook-Resource (issue, error, event_alert, metric_alert, comment, installation, seer, …), Sentry-Hook-Timestamp (Unix seconds), and Request-ID. See https://docs.sentry.io/organization/integrations/integration-platform/webhooks/.

The timestamp is not covered by the signature, so it cannot prove freshness; verify-request checks it only when given a max-age-seconds.

Functions

hook-resource

fn (request: Map): Str?

The Sentry-Hook-Resource header: what the delivery is about (issue, error, event_alert, metric_alert, comment, installation, …), or null.

Example

::sentry::webhooks/hook-resource({headers: {"sentry-hook-resource": "issue"}})  // "issue"

hook-timestamp

fn (request: Map): Int?

The Sentry-Hook-Timestamp header as Unix seconds, or null when absent or malformed.

Example

::sentry::webhooks/hook-timestamp({headers: {"sentry-hook-timestamp": "1762689600"}})  // 1762689600
::sentry::webhooks/hook-timestamp({headers: {"sentry-hook-timestamp": "soon"}})  // null

request-id

fn (request: Map): Str?

The delivery's Request-ID header (a UUID), useful for de-duplicating retries.

Example

::sentry::webhooks/request-id({headers: {"request-id": "9a1b2c3d"}})  // "9a1b2c3d"

verify-request

fn (request: Map): Bool
fn (request: Map, secret: Str?): Bool
fn (request: Map, secret: Str?, max-age-seconds: Int): Bool

Verify a Sentry integration webhook: Sentry-Hook-Signature must be the hex HMAC-SHA256 of the raw body under the client secret (constant-time compare). Uses sentry.webhook.secret by default (failing when it is unset), or an explicit secret, which is masked in call records — an empty secret never verifies. The 3-arity form also rejects deliveries whose Sentry-Hook-Timestamp is more than max-age-seconds from now (0 or less skips the check).

Example

sentry-webhook
meta {webhook: {service: "sentry", path: "/sentry/webhook"}}
fn (request) {
  cond {
    not(::sentry::webhooks/verify-request(request)) => {
      ::hot::http/HttpResponse({status: 401, body: "invalid signature"})
    }
    eq(::sentry::webhooks/hook-resource(request), "issue") => {
      println(`issue ${request.body.action}: ${request.body.data.issue.title}`)
      ::hot::http/HttpResponse({status: 200, body: "ok"})
    }
    => { ::hot::http/HttpResponse({status: 200, body: "ignored"}) }
  }
}
Context Vars: sentry.webhook.secret