Skip to main content
Every call Widgetic makes to your server is signed: partner webhooks and MCP events alike. Anyone can send a request to a public address, so check the signature before you trust a call. The scheme is Standard Webhooks. A library for it checks a call (see Use a library), and the examples below need no library at all.

What is signed

Three headers go with every call. The signature is an HMAC-SHA256, in base64, of the text <webhook-id>.<webhook-timestamp>.<raw body>. To check a call:
  1. Take your secret (it starts with whsec_), drop that prefix and decode the rest from base64. Those bytes are the key.
  2. Join the webhook-id, a dot, the webhook-timestamp, a dot and the raw body.
  3. Sign it with HMAC-SHA256 under the key, encode the result in base64 and put v1, in front.
  4. Compare it, in constant time, with each signature in the header. One match is enough.
  5. Refuse a call whose webhook-timestamp is more than five minutes away from your clock.
Sign the raw body, exactly as it arrived, and not a copy that your framework parsed and wrote out again: one space or one key in another place breaks the signature. Get the raw body shows where it is in the common frameworks.

Check a call

Each example takes the raw body, the three headers and your secret, and throws (Go returns an error) when the call does not come from Widgetic. The last argument is the current time: leave it out, and the example reads the clock. A test passes the time of its sample call.

Get the raw body

Every framework has a way to hand you the body before it parses it.

Use it in a receiver

This Express receiver keeps the body as it arrived, checks it, drops an event it has already handled and answers quickly. The same steps fit any framework.

Use a library

Standard Webhooks publishes a library for C#, Elixir, Go, Java, JavaScript, PHP, Python, Ruby and Rust. It reads the secret as Widgetic gives it, with the whsec_ prefix, and checks the five minutes for you. In JavaScript:

Rotate a secret

A secret can change while calls are on their way. For a while, Widgetic signs each call with the old secret and the new one, and lists both signatures in webhook-signature, separated by a space. The examples above accept a call when either one matches, so you can switch your receiver to the new secret before the old one stops signing.
  • For partner webhooks, rotate the secret with POST /partners/{partnerId}/notifications/webhook-secret. The old one keeps signing for .
  • For MCP events, send events/subscribe again with a new secret. The old one keeps signing for .

Check your code against a known call

Use this call to try your code before the first real event. It is made up: the secret signs nothing else. The body is this text, in one line and without a line break at the end:
Call your check with these values and 1794303005 as the current time. It must accept the call. Change one character of the body, or of the secret, and it must refuse it. The clock is a separate check: with a current time more than 300 seconds away from 1794303005, it must refuse a call whose signature is right.

When the signature does not match

  • You signed a copy of the body. Parsing the JSON and writing it out again changes the bytes. Use the raw body.
  • Something changed the body on its way. A proxy or a middleware that reads the body first, or one that changes its encoding, breaks the signature. Look at the bytes your application receives.
  • It is the secret of another source. A partner webhook and every MCP subscription have a secret of their own. A partner secret is shown once, when you set the address or rotate it; an MCP secret is the one you gave to events/subscribe.
  • You used the secret as text. The key is the base64-decoded part after whsec_, as bytes.
  • Your clock is off. A call whose webhook-timestamp is more than five minutes away from your clock is refused, even with a right signature. Keep the clock of your servers in step with a time service.
  • Your framework lower-cases or merges header names. Header names are not case-sensitive, so look them up in a way that is not either.
To see what Widgetic sent for a partner webhook, and how your receiver answered, read the delivery log, or send a test event.

Partner webhooks

Set an address, choose events, answer and retries

MCP events

Be called when a visitor sends an entry