Skip to content

Verify the sender's signature

Services like GitHub and Stripe sign every webhook they send with a secret you share with them. Turn on Verify the sender's signature on an endpoint, and it accepts only requests carrying a valid signature from that sender. Anything else is refused before it reaches your targets.

With this on, the endpoint no longer needs your API key. That matters for senders whose webhook settings take only a URL: there is no key to put in it.

This checks webhooks coming in to us. To let your receiver check our deliveries, see Verify a delivery came from us; every key, token and secret by direction is on Which key, token or secret goes where.

Set it up

  1. Open Credentials in the project menu and save a credential of type Signing secret (from the sender). Paste the secret you gave the sender: GitHub's webhook secret, or Stripe's whsec_… endpoint secret.
  2. Open the endpoint, turn on Verify the sender's signature, pick the sender and the credential, and publish the line.
  3. In the sender's webhook settings, use the endpoint's URL as it is, with no key.
Sender What we check
GitHub X-Hub-Signature-256
Stripe Stripe-Signature, and that its timestamp is within 5 minutes of now
Standard Webhooks webhook-id, webhook-timestamp and webhook-signature, with the same 5-minute window
Custom (HMAC) The header you name, with the algorithm, encoding, prefix and message you set. With a timestamp header, the same 5-minute window

Standard Webhooks covers any sender that follows that specification and signs with a shared whsec_ secret. Senders that sign with a public key instead (v1a signatures) aren't supported.

Custom (HMAC) is for any other sender that signs the request with an HMAC, such as Shopify or Slack. Copy the settings from the sender's webhook documentation: the header, the algorithm (SHA-256, SHA-512 or SHA-1), the encoding (hex or base64), any prefix such as v0=, and what is signed. The Shopify and Slack buttons fill them in for you.

The check runs on the exact bytes the sender sent, before validation or mapping. So a mapping can reshape the event for your target without breaking the signature. The signature headers are not passed on to your targets.

Limits

  • One sender per endpoint. Two senders need two endpoints.
  • A signed request body can be up to 188 KiB.
  • A signature header may carry up to 8 signatures. GitHub sends one; Stripe and Standard Webhooks send more than one while you rotate the secret.
  • With Custom (HMAC), a prefix can be up to 32 bytes and the signed message up to 256 bytes.
  • The signing secret is stored like every other credential: encrypted, and never shown again after you save it.

When it fails

  • A request with no signature, a wrong one, or a stale timestamp is refused with 401 invalid_signature. It is not charged and never reaches your targets.
  • A signed body over 188 KiB is refused with 413.
  • If we briefly cannot check signatures, signed requests are refused with 401 too, rather than let through unchecked. Stripe retries a failed webhook on its own. GitHub does not: redeliver it from the webhook's Recent Deliveries tab.
  • A signing-secret credential can't be deleted while an endpoint or an unpublished draft uses it.

What it costs

Nothing extra. A request that passes the check is charged like any other request, and a refused one is not charged.

Try it

Sign a request the way GitHub does and send it to an endpoint set up for GitHub. Use the same secret you saved in the credential:

# not run headless: needs an endpoint with Verify the sender's signature turned on
ENDPOINT_URL='https://…'           # the endpoint's URL, as shown in the panel
SECRET='the secret you saved'
BODY='{"action":"opened","issue":{"number":1}}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')
curl -sS -X POST "$ENDPOINT_URL" -H "Content-Type: application/json" \
  -H "X-Hub-Signature-256: sha256=$SIG" -d "$BODY"

Change one character of BODY after computing SIG and send it again: the endpoint answers 401 invalid_signature.

FAQ

Do I still need an API key for this endpoint?

No. The sender's signature replaces it. Your other endpoints keep using API keys.

Can I filter which events the sender delivers?

Not here. Choose the events in the sender's own webhook settings. A mapping can pass a field such as GitHub's action through, so your target decides what to act on.