Skip to main content
Always verify a webhook before you process it. Never trust an unverified payload.

Why verify?

Anyone who finds your webhook URL can send it fake requests. Verification proves the request came from OpenMail. Always verify in production.

Pick your scheme

Each endpoint uses one scheme. OpenMail picks it from the Auth header or secret field when you add or edit the endpoint on the Webhooks page: The endpoint page shows which scheme it uses under Authentication.

OpenMail signature

Leave the field empty and OpenMail generates a secret for the endpoint. Every request carries:

Signature format

  • timestamp = value of the X-Timestamp header
  • raw_json_payload = raw request body as a string (do not parse the JSON first)

Verification steps

  1. Read the raw request body as a string.
  2. Get X-Timestamp and X-Signature from the headers.
  3. Compute HMAC-SHA256(secret, timestamp + "." + body) as hex.
  4. Compare it with X-Signature using constant-time comparison (e.g. crypto.timingSafeEqual in Node.js, hmac.compare_digest in Python).
  5. Check X-Timestamp is within 5 minutes of the current time (replay protection).
Use constant-time comparison to prevent timing attacks. Do not use == or string equality.

Getting your secret

Open the endpoint on the Webhooks page. Under Authentication, click the eye icon to reveal the signing secret, or the copy icon to copy it. Store it in an environment variable (e.g. OPENMAIL_WEBHOOK_SECRET) and never commit it to version control. To replace it, open the endpoint’s actions menu and click Rotate secret. The old secret stops working immediately.

Standard Webhooks

Paste a whsec_ secret and OpenMail signs each request per the Standard Webhooks spec. Use this for receivers that already verify Standard Webhooks, such as Grok automations. The part after whsec_ must be base64. Every request carries:

Signature format

Verification steps

  1. Read the raw request body as a string.
  2. Strip whsec_ from your secret and base64-decode the rest. This is the HMAC key.
  3. Compute the signature over {webhook-id}.{webhook-timestamp}.{body}.
  4. Compare it with the value after v1, in webhook-signature, in constant time.
  5. Check webhook-timestamp is within 5 minutes of the current time.
You can also use the official Standard Webhooks libraries, which check the timestamp for you.

Getting your secret

You create the whsec_ secret, or the receiving platform gives you one. To make your own:
OpenMail never shows a pasted secret again; the endpoint page shows only its last four characters. To change it, click Replace under Authentication and paste a new one.

Bearer token

Paste any other value and OpenMail sends it as a bearer token. You can paste the whole Authorization: Bearer … header or just the token. Every request carries: The request is not signed and has no timestamp. Compare the token with the one you expect, in constant time:
Node.js
A bearer token proves who sent the request, but not that the body is unchanged, and it gives no replay protection. Use it for receivers that only accept a token, and only over HTTPS. Prefer a signature when your receiver supports one.
As with whsec_ secrets, OpenMail never shows the token again. Click Replace under Authentication to change it.

Troubleshooting

See Setup for full server examples and local development.