DaletGuard supports civilians affected by armed conflict through Families Beyond War. All sides, no political affiliation. About our humanitarian work

CRM Webhook Signature Verification Step by Step

Webhook signature verification is the check that stops a stranger from posting fake events to your endpoint and starting jobs. Without it, anyone who finds the address can create records, start jobs or flood your logs with noise every day. With it, you accept a message only when the sender knew a shared secret and the whole body arrived unchanged. DaletPipe signs every outbound event with an HMAC signature, so your receiver can run the same check at once, today. This article walks through the check, a worked example, the replay rules and the retry waits, in a clear order.

The wider design choices sit in the CRM integration guide.

Illustration of shield, key, puzzle for webhook signature verification
Key takeaway

Verify the signature over the exact raw body, compare in constant time and drop repeats by event id. Then fetch the current record before you act. A signature proves who sent the bytes, not that the event is new or complete.

How do you run webhook signature verification in six steps?

Also, a receiver runs six webhook signature verification steps in a fixed order. First, it stops at the first failure and does not continue.

People new to the constant-time compare should start with the guides.

Short answers on the webhook signature verification are kept up to date. In fact, share what you learn about the constant-time compare with your whole team. Questions about the replay protection are welcome in the contact form.

Teams often ask us about the raw body in practice. Each page on the shared secret is reviewed before it is published.

  1. Read the raw request body as bytes before any parsing.
  2. Read the signature header and strip the scheme prefix, which is sha256 followed by an equals sign.
  3. Compute an HMAC signature digest of those exact bytes with your stored secret, written as lowercase hex.
  4. Compare your digest with the header value in constant time.
  5. Reject the request with a 4xx status when the values differ.
  6. Parse the JSON, read the event id and check it against the ids you have seen.

In addition, each step of this webhook signature verification flow has a clear reason. Raw bytes matter because a re-serialized body can differ from the original. In addition, the prefix must be removed, or every compare fails.

Parsing comes last because a parser is attack surface. Therefore, run it only on trusted input.

Moreover, keep the secret out of source code and logs. Indeed, the webhook signature verification secret is only as strong as the place where it is stored. Indeed, every webhook signature verification check depends on that secret. If it leaks, rotate it at once.

How does one worked example of the check look in code?

Notably, suppose the sender posts a JSON envelope for the event record.synced. The envelope holds an event id, a tenant id, a timestamp and a data block. In fact, it also sends X-Dalet-Signature with the value sha256 followed by a 64-character hex string.

Each count is checked against the source.

Teams often ask us about the webhook signature verification in practice. Also, teams often ask us about the replay protection in practice.

Our team writes about the webhook signature verification in plain words. Each page on the constant-time compare is reviewed before it is published. Each page on the raw body is reviewed before it is published.

Teams often ask us about the shared secret in practice.

DaletPipe connections list screen
For example, the connections list screen of DaletPipe.

How is the signature header laid out on the wire?

The header holds the word sha256, an equals sign and the hex digest.

Each step is recorded with its date.

Readers often return to the webhook signature verification when plans change.

Short answers on the webhook signature verification are kept up to date. Thus, a short checklist keeps the shared secret under control.

Teams often ask us about the constant-time compare in practice. A second look at the constant-time compare pays off. Every claim about the raw body is checked against the code.

Short answers on the shared secret are kept up to date.

Indeed, in this webhook signature verification test, your receiver reads the body bytes and keeps them untouched. Next, it computes the HMAC signature digest of those bytes with the shared secret. The result is 32 bytes, written as 64 hex characters.

Besides, it builds the string sha256 plus that hex and compares it with the header. This webhook signature verification header match is the whole check.

Specifically, if one character of the body differs, the two strings differ completely. For example, add a space, change the key order or round a number, and the check fails. Notably, that is the point of the design.

Furthermore, a match means the receiver holds exactly the bytes the sender signed. The webhook signature verification code is short for that reason.

Now the receiver reads the event id from the envelope and looks it up in a store of processed ids. Additionally, when the id is new, the receiver records it and handles the event. When the id was seen before, the receiver returns 200 and does nothing else. Also, returning success on a repeat stops the sender from retrying.

Illustration for CRM Webhook Signature Verification Step by Step

Why should a compare of two hashes take constant time?

In addition, a normal string compare is a trap in any webhook signature verification code. Indeed, it stops at the first different character. Therefore, the time it takes leaks how many leading characters matched.

An attacker who can measure that time may guess a valid HMAC signature one character at a time. Moreover, over a network the signal is faint, but the fix costs nothing.

Notes on the constant-time compare are dated and reviewed by a second person.

Our team writes about the webhook signature verification in plain words. Readers often return to the constant-time compare when plans change. Each page on the raw body is reviewed before it is published.

Short answers on the raw body are kept up to date.

Notably, use the compare function your language provides for secrets. Python offers hmac.compare_digest, and most languages have an equivalent. Also compare values of equal length and format.

Do not lowercase or trim inside a hand-written loop. The reason is that that weakens the HMAC signature check.

In fact, treat the secret as a credential. Give each subscription its own secret, so one leak reaches one endpoint only. Schedule rotation as well: accept two secrets for a short window, switch the sender, then drop the old one.

Indeed, DaletPipe accepts a secret of up to 512 characters per subscription. Therefore, limit who can read the store that holds it, and rotate on any doubt. Besides, the credential custody article shows how CRM tokens differ from webhook secrets.

DaletPipe connector catalog screen
For example, the catalog shows each provider with its status and API style.

How does replay protection use an event id and a clock?

Besides, webhook signature verification alone does not make a message fresh. The reason is that a valid HMAC signature can be sent twice. An attacker who captures one request can send it again, and the signature stays valid.

The result is stored with the run.

Specifically, two layers of replay protection stop that: an event id and a time check. The replay protection step costs one lookup per message.

Each page on the webhook signature verification is reviewed before it is published. Every claim about the raw body is checked against the code.

Questions about the webhook signature verification are welcome in the contact form. Teams often ask us about the constant-time compare in practice. Also, teams often ask us about the raw body in practice.

Each page on the shared secret is reviewed before it is published.

Furthermore, the event id is a unique value in the envelope and in a header. Store each id you process, and keep it longer than the sender's retry window. Then drop every repeat today.

Additionally, this event id store absorbs honest duplicates that retries cause. A replay protection store can stay small, since ids expire after the retry window.

Also, a timestamp adds a second replay protection guard. Reject messages whose timestamp sits far from your clock, with a tolerance that covers clock skew and retries. In addition, DaletPipe's envelope carries a timestamp.

Also, the event id in the body matches the X-Dalet-Event-ID header. Likewise, the webhook-timestamp header also gives the time of each attempt. That event id match lets a receiver run replay protection on either value.

Moreover, treat the payload as a hint rather than a copy of the record. The event record.synced carries a connection id, an entity and a count of records processed. In addition, it is a notice that a pull finished.

Therefore, fetch the records through the API when you need them. Notably, the signed webhooks page describes the full event.

DaletPipe field mapping workbench screen
For example, field mappings are previewed and each field gets a named outcome.

How does DaletPipe send events and retry the failed ones?

In fact, the sender's retry rules decide how your receiver should answer after the webhook signature verification result is known. A webhook signature verification failure should end with a clear 4xx answer. DaletPipe posts a JSON body with a timeout of 10 s.

Indeed, it sends three headers: X-Dalet-Signature, X-Dalet-Event-Type and X-Dalet-Event-ID. The signature header carries the HMAC signature.

Our team writes about the event ID in plain words. Questions about the shared secret are welcome in the contact form.

A second look at the constant-time compare pays off. Our team writes about the replay protection in plain words. Overall, each page on the raw body is reviewed before it is published.

Notes on the shared secret are dated and reviewed by a second person.

Besides, your response status steers what happens next. A 2xx status counts as delivered. Specifically, a 4xx status marks the delivery failed at once, with no retry. A 5xx status, a timeout or a connection error counts as retryable.

Each delivery gets three attempts. After the first failure the next try comes after 5 s, and after the second it comes after 30 s. Moreover, after the third failure the delivery gets the status dead letter. Each delivery row keeps the attempt count, the last HTTP status, the last error and the next attempt time.

So choose status codes with care. Return 401 or 400 for a bad signature, because a retry cannot fix it. Return 500 only for a fault on your side that may clear. Answer quickly and do slow work after you reply, since a 10 s timeout counts as a failure.

DaletPipe sync activity outcomes screen
For example, every sync run ends in a named outcome you can read.

How does DaletPipe verify each of the inbound CRM webhooks?

Everything above covers events that DaletPipe sends. Events that CRMs send to DaletPipe are a different matter. Each CRM signs differently, or not at all. Some send a header token, some sign a URL plus the body, and some send partial data.

Every figure is taken from the code.

A second look at the replay protection pays off.

Short answers on the webhook signature verification are kept up to date. In fact, share what you learn about the constant-time compare with your whole team. Share what you learn about the raw body with your whole team.

A second look at the shared secret pays off.

The generic inbound route accepts only verified events. Each connector's verified webhook operation checks that provider's own scheme. A signature header alone is not authentication, so the route fails closed.

Inbound notifications arrive on connection-bound routes, and Pipedrive v2 person notifications are one example. Indeed, each tenant connects its route with its own secret, a public HTTPS base URL and a worker database role. A valid create or change event makes a worker fetch the current record.

The callback data itself is never used as the record. Delete and merge notices keep evidence and never delete local records.

If you also run a receiver of your own for a CRM, verify with that CRM's documented scheme. The incremental sync article describes the polling safety net. Meanwhile, the warehouse feed page shows a downstream use of signed events. Also, for background, read RFC 2104 (opens in new tab) and the Python hmac notes (opens in new tab).

How can your team make this check a routine habit?

Webhook signature verification is six small steps. Read the raw bytes, strip the prefix, compute the HMAC signature and compare in constant time. Then reject on mismatch and run replay protection with the event id. Thus, each step closes one attack.

Every change is reviewed by a second person.

Share what you learn about the webhook signature verification with your whole team. Our team writes about the raw body in plain words.

A second look at the webhook signature verification pays off. A second look at the constant-time compare pays off. People new to the raw body should start with the guides.

Share what you learn about the shared secret with your whole team.

Handle the edges as well. Pick status codes that match the sender's retry rules and rotate secrets on a schedule. Finally, test the whole webhook signature verification path in a sandbox. Send a good message, a tampered one and a repeat, then confirm each outcome.

A diagram with the topic at the centre and four connected parts: Event id, Raw body, Shared secret.

Questions and answers on this topic from the product team

What does a webhook signature prove?

It proves the sender knew the shared secret and that the body was not altered on the way. It does not prove that the event is new, complete or in order. A replayed copy of a valid message carries a valid signature, so you also need an event id check.

Why must I sign and verify the raw body?

The signature is computed over exact bytes. If you parse the JSON and serialize it again, spacing, key order or number formatting can change, and the check fails or, worse, passes on altered content. Read the raw bytes first, verify, then parse.

What headers does DaletPipe send?

Each outbound delivery carries X-Dalet-Signature, in the form sha256 equals the hex digest, plus X-Dalet-Event-Type and X-Dalet-Event-ID. The body is JSON with an envelope that also holds the event id. Verify the signature first, then use the other two headers.

How does DaletPipe retry failed deliveries?

A 2xx response is success; a 4xx response fails at once with no retry. A 5xx response, a timeout or a connect error is retried: three attempts in all, with waits of 5 s and then 30 s. After that the delivery gets the status dead_letter.

Does DaletPipe accept webhooks from CRMs?

Yes. Inbound notifications arrive on connection-bound routes that verify each signature, with Pipedrive v2 person events as one example. Any receiver of your own also needs webhook signature verification.

See how DaletPipe fits the providers your team uses today

Book a short meeting for a walkthrough with your own providers in mind, or join an in-person class to learn the method first.