Skip to main content
Technical Guides

Secure Your Rodz Webhooks: HMAC-SHA256 Verification

Peter Cools · · Updated on November 23, 2026 · 16 min read

TL;DR: Any endpoint exposed on the internet can receive requests from anyone. Without verification, a third party can send fake leads to your server and corrupt your data. Rodz signs every webhook delivery with your API key’s secret: the X-Webhook-Signature header holds the hex-encoded HMAC-SHA256 of timestamp.raw body, where timestamp is the value of X-Webhook-Timestamp. Your server recomputes this signature before processing the lead. This guide shows how to do it in Node.js and Python, then how to test the verification with test-webhook (reserved for partner accounts: 403 PARTNER_ACCESS_REQUIRED otherwise).

Why Webhook Security Matters

When you set the webhookUrl of a signal, you expose an HTTP endpoint on the internet. Your server accepts incoming POST requests and processes the data they carry. But anyone can send a POST request to that URL. A malicious actor could forge fake leads, inject corrupted data into your CRM or trigger your automated workflows on false information.

Without a verification mechanism, your server cannot tell a request sent by Rodz from one made up by a third party. That is the job of the HMAC-SHA256 signature: it proves that the request comes from Rodz and that its content was not altered in transit.

If you have not connected a webhook yet, start with the Rodz webhook setup guide. For an overview of the API, see the endpoint reference and the API documentation.

Prerequisites

  1. A Rodz API key. Create it under Integrations → API in the dashboard. Each API key has a webhook secret, generated automatically.
  2. A signal created with that API key. When no API key is linked to the signal, deliveries go out unsigned.
  3. A public URL that Rodz can reach. In development, a tunnel (ngrok, for example) is enough.
  4. Node.js 18+ or Python 3.8+, depending on your language.
  5. openssl and cURL to compute and send a signature by hand.

How HMAC-SHA256 Verification Works

The Principle in Three Points

HMAC-SHA256 is a hash-based message authentication code. The mechanism rests on three elements:

  • A shared secret. Each API key has its own webhook secret. Only you and Rodz know it.
  • A signature in the header. On every delivery, Rodz computes the HMAC-SHA256 of the message timestamp.raw body with that secret, then puts the result, hex-encoded and without any prefix, in X-Webhook-Signature. The timestamp is the value of X-Webhook-Timestamp.
  • A check on your server. Your server recomputes the same HMAC with the same secret and compares the result to the header. If both match, the request is authentic.
sequenceDiagram
    participant R as Rodz
    participant S as Your server
    R->>S: POST webhookUrl + X-Webhook-Id, X-Webhook-Timestamp, X-Webhook-Signature
    S->>S: HMAC-SHA256(secret, timestamp + "." + raw body)
    alt signature matches
        S-->>R: 200 (the lead is processed after the response)
    else signature differs
        S-->>R: 401 (request rejected)
    end

The Three Headers of a Delivery

HeaderContent
X-Webhook-SignatureHMAC-SHA256 signature, hex-encoded
X-Webhook-TimestampUnix timestamp used in the signature
X-Webhook-IdDelivery identifier, the same on the first attempt and on every retry

Why HMAC-SHA256 and Not a Plain Hash?

A SHA256 hash without a secret key proves nothing: anyone can compute the SHA256 of a request body. HMAC adds the secret key. Without it, producing a valid signature is impossible, and that is what guarantees the authenticity of the message.

Step 1: Get Your Webhook Secret

In the Rodz dashboard, open Integrations → API. Each API key has its webhook secret there. You can view it or regenerate it on the same page.

Store it in an environment variable on your server. Never hardcode it in your source code.

export RODZ_WEBHOOK_SECRET="your_webhook_secret"

Step 2: Create the Signal With Its webhookUrl

The webhook is set per signal. Request bodies are camelCase: webhookUrl takes your endpoint’s URL. This example creates a fundraising signal; without status, the signal is created as a draft.

curl -X POST https://api.rodz.io/api/v1/signals/fundraising \
  -H "Authorization: Bearer $RODZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Series A in France",
    "webhookUrl": "https://your-server.com/webhooks/rodz",
    "dailyLeadLimit": 50,
    "config": {
      "investmentTypes": ["series_a"],
      "announcedPeriod": "30d",
      "hqLocations": ["France"]
    }
  }'

The 201 response contains the signal’s id, its status, its webhookUrl and its config. Keep the id: the test and replay routes need it. To activate the signal later, send "status": "active" with PATCH /api/v1/signals/{signal_id}. If the account is out of credits, creating or activating a signal answers 402 with the code INSUFFICIENT_CREDITS.

Errors carry error.code and error.message; depending on the route, that object may be nested under detail (for example the 401, 402 and some 400 responses): read both places. Example:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Detailed error description"
  }
}

Step 3: Implement Verification in Node.js

Here is an implementation with Express. The key point: capture the raw request body, not the JSON-parsed version, because the signature covers the exact bytes that were sent.

const express = require('express');
const crypto = require('crypto');

const app = express();
const WEBHOOK_SECRET = process.env.RODZ_WEBHOOK_SECRET;
const seen = new Set(); // in production: Redis or your database

function isValid(rawBody, signature, timestamp) {
  if (!signature || !timestamp) {
    return false;
  }

  // Signed message: timestamp + "." + raw body
  const expected = crypto
    .createHmac('sha256', WEBHOOK_SECRET)
    .update(Buffer.concat([Buffer.from(`${timestamp}.`, 'utf8'), rawBody]))
    .digest('hex');

  // Constant-time comparison, after checking the length
  const a = Buffer.from(expected, 'utf8');
  const b = Buffer.from(signature, 'utf8');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

// Capture the raw body BEFORE any JSON parsing
app.post('/webhooks/rodz', express.raw({ type: 'application/json', limit: '1mb' }), (req, res) => {
  const signature = req.get('X-Webhook-Signature');
  const timestamp = req.get('X-Webhook-Timestamp');

  if (!isValid(req.body, signature, timestamp)) {
    console.error('Invalid signature, request rejected');
    return res.status(401).json({ error: 'Invalid signature' });
  }

  // Retries carry the same X-Webhook-Id: deduplicate on it
  const deliveryId = req.get('X-Webhook-Id');
  if (deliveryId && seen.has(deliveryId)) {
    return res.status(200).json({ received: true, duplicate: true });
  }
  if (deliveryId) seen.add(deliveryId);

  const lead = JSON.parse(req.body.toString('utf8'));
  res.status(200).json({ received: true }); // respond first

  // Process afterwards
  setImmediate(() => {
    // The webhookUrl also receives events: they carry an `event` key, no lead has one
    if (lead.event) return console.log('Event ignored:', lead.event);
    if (lead.signal.is_test) return console.log('Test payload received');
    console.log('Verified lead:', lead.signal.type, lead.company && lead.company.name);
  });
});

app.listen(3000, () => {
  console.log('Webhook server listening on port 3000');
});

Key Points in the Node.js Code

  • express.raw() instead of express.json(). The express.json() middleware parses the body into a JavaScript object. If you serialize it again with JSON.stringify(), the result can differ from the original body (whitespace, key order). The HMAC must be computed on the exact bytes received.
  • crypto.timingSafeEqual() for the comparison. Never compare signatures with ===: standard equality stops at the first difference, which lets an attacker guess the signature by measuring response time. timingSafeEqual() requires two buffers of the same length, hence the check beforehand.
  • No prefix to strip. X-Webhook-Signature is a raw hex string, without sha256=.
  • The secret comes from an environment variable. Never from the source code.
  • The response goes out before processing. Answer with a 2xx quickly and move heavy work to a queue or a background task.
  • The webhookUrl also receives events. They are recognizable by the event key, which no lead carries: ignore the ones you do not handle, as the code above does.

Step 4: Implement Verification in Python

Here is the equivalent in Python with Flask:

import hashlib
import hmac
import os

from flask import Flask, jsonify, request

app = Flask(__name__)
WEBHOOK_SECRET = os.environ['RODZ_WEBHOOK_SECRET']
seen = set()  # in production: Redis or your database


def is_valid(raw_body: bytes, signature: str, timestamp: str) -> bool:
    if not signature or not timestamp:
        return False

    # Signed message: timestamp + "." + raw body
    message = f"{timestamp}.".encode('utf-8') + raw_body
    expected = hmac.new(
        WEBHOOK_SECRET.encode('utf-8'),
        message,
        hashlib.sha256,
    ).hexdigest()

    # Constant-time comparison
    return hmac.compare_digest(expected, signature)


@app.route('/webhooks/rodz', methods=['POST'])
def handle_webhook():
    signature = request.headers.get('X-Webhook-Signature', '')
    timestamp = request.headers.get('X-Webhook-Timestamp', '')
    raw_body = request.get_data()  # raw body, not request.json

    if not is_valid(raw_body, signature, timestamp):
        return jsonify({'error': 'Invalid signature'}), 401

    # Retries carry the same X-Webhook-Id: deduplicate on it
    delivery_id = request.headers.get('X-Webhook-Id')
    if delivery_id and delivery_id in seen:
        return jsonify({'received': True, 'duplicate': True}), 200
    if delivery_id:
        seen.add(delivery_id)

    lead = request.get_json()
    # The webhookUrl also receives events: they carry an `event` key, no lead has one
    if lead.get('event'):
        return jsonify({'received': True}), 200
    if lead['signal'].get('is_test'):
        print('Test payload received')
    else:
        company = lead.get('company') or {}
        print('Verified lead:', lead['signal']['type'], company.get('name'))

    return jsonify({'received': True}), 200


if __name__ == '__main__':
    app.run(port=3000)

Key Points in the Python Code

  • request.get_data() instead of request.json. As in Node.js, you must work on the raw bytes.
  • hmac.compare_digest() for the comparison. It is the Python equivalent of timingSafeEqual(): constant-time comparison.
  • WEBHOOK_SECRET.encode('utf-8'). hmac.new() expects bytes for the key.
  • This code processes the lead before responding. For long processing, move it to a queue or a background task and respond first.

Step 5: Return the Right Status Code

Rodz reads the HTTP status code of your response to decide what happens next:

Your responseEffect on Rodz’s side
2xxDelivery succeeded
Timeout, connection error or 5xxTemporary failure: Rodz retries
429Rodz slows down and retries a bit later
Any other 4xx (including 401)Permanent failure: no retry

Rodz first retries several times within about two hours, then at 30 minutes, 1 h, 2 h, 4 h, then every 6 hours, for up to 14 days after the lead was created. Every attempt sends the same payload with the same X-Webhook-Id.

The consequence: return 401 for a missing or invalid signature, never 200, or you would accept a forged request. And know that a 401 is final: if your server wrongly rejects real leads (stale secret, wrong computation), they are not retried. Fix the cause, then recover them with replay-webhook (see below).

Common Mistakes to Avoid

Parsing the Body Before Verification

This is the most frequent mistake:

// DO NOT DO THIS
const hmac = crypto.createHmac('sha256', secret);
hmac.update(JSON.stringify(req.body)); // Wrong!

The result of JSON.stringify() can differ from the original body: whitespace, key order, encoding of special characters. Always use the raw body as received.

Signing the Body Alone

The signature does not cover the body alone, but timestamp.raw body. Computing the HMAC of the body without the timestamp and the dot always gives a different signature.

Looking for a sha256= Prefix

X-Webhook-Signature is a raw hex string. Compare it as is.

Using Simple String Comparison

// DO NOT DO THIS
if (computedSignature === headerSignature) { // Vulnerable!

Attacks that measure response time (timing attacks) are realistic: === stops at the first differing character, and the response time reveals how many characters match. Use crypto.timingSafeEqual() in Node.js or hmac.compare_digest() in Python.

Hardcoding the Secret in Source Code

// DO NOT DO THIS
const SECRET = 'my_hardcoded_secret'; // Visible in Git!

If your code is in a Git repository, even a private one, the secret is exposed. Use environment variables or a secrets manager.

Forgetting to Check That the Headers Are Present

A request without X-Webhook-Signature or without X-Webhook-Timestamp must be rejected before any computation, without crashing your code.

Testing Your Verification

With the test-webhook Route

Rodz can send a sample lead to your endpoint. Call POST /api/v1/signals/{signal_id}/test-webhook. With a {"url": "..."} body, you test an address other than the saved webhookUrl, for example before saving it.

curl -X POST "https://api.rodz.io/api/v1/signals/$SIGNAL_ID/test-webhook" \
  -H "Authorization: Bearer $RODZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://your-server.com/webhooks/rodz"}'

The response gives success (true when your endpoint answered with a 2xx or 3xx), the statusCode your server returned, the payloadSent (with signal.is_test set to true), the first bytes of your responseBody and signed. If signed is false, no API key is linked to the signal: the test went out unsigned, and a warning says so. On a transport failure, success is false and error explains why.

This route is limited to 10 calls per minute per key and 100 per day per account (code HELPER_RATE_LIMIT_EXCEEDED, with a Retry-After header). It answers 403 (PARTNER_ACCESS_REQUIRED) for an account that is not approved as a partner: write to support@rodz.io to have it enabled.

By Hand With openssl

To test without going through Rodz, compute the signature yourself. The signed message is timestamp.raw body:

# Secret, timestamp and request body
SECRET="$RODZ_WEBHOOK_SECRET"
TIMESTAMP=$(date +%s)
BODY='{"signal":{"id":"d4f5a6b7-c8d9-4e0f-a1b2-c3d4e5f6a7b8","name":"Series A in France","type":"fundraising","last_signal":"Fundraising","last_signal_date":"2026-11-23","heat_score":72,"funding_stage":"Series A","funding_amount_usd":5500000,"announcement_date":"2026-11-20"},"contact":"","company":{"name":"Northwind Robotics","website":"https://northwind-robotics.example"}}'

# Signature: hex HMAC-SHA256 of "timestamp.body"
SIGNATURE=$(printf '%s.%s' "$TIMESTAMP" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | awk '{print $NF}')

echo "Signature: $SIGNATURE"

Then send the request to your local server:

curl -X POST http://localhost:3000/webhooks/rodz \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Id: 7f3c2a9e-1b4d-4c8e-9a01-5d6e7f8a9b0c" \
  -H "X-Webhook-Timestamp: $TIMESTAMP" \
  -H "X-Webhook-Signature: $SIGNATURE" \
  -d "$BODY"

If your implementation is correct, the server answers 200. To check the rejection, change one character of the signature and run it again: the server must answer 401. The payload above follows the schema of a funding-round lead: contact is "" for a lead without a person, and the fields of signal vary with the signal type.

Additional Best Practices

Deduplicate on X-Webhook-Id

Delivery is at-least-once: the same lead can arrive several times. Store the X-Webhook-Id values already processed, with a lifetime of at least 14 days, the length of the retries (Redis SET NX EX, for example), rather than in memory. For a lead without a person, this header is also the lead’s identifier: contact is "" and there is no contact.lead_id.

Check the Age of the Request (Optional)

The X-Webhook-Timestamp header lets you reject requests that are too old, as protection against replaying a captured request. The API documentation sets no tolerance window and does not say whether the timestamp is renewed on each attempt. So pick a wide window and test it: since a 4xx is final, a window that is too tight would lose real leads.

const timestamp = parseInt(req.get('X-Webhook-Timestamp'), 10);
const now = Math.floor(Date.now() / 1000);
const MAX_AGE = 3600; // adjust: the window is your choice

if (Math.abs(now - timestamp) > MAX_AGE) {
  return res.status(401).json({ error: 'Request too old' });
}

Log Failed Attempts

Record every request with an invalid signature: source IP address, timestamp and a few characters of the received signature, not all of it. This lets you spot attack attempts and configuration errors.

Regenerate the Secret If in Doubt

If you think the secret leaked, regenerate it under Integrations → API, then update your server’s environment variable right away. The secret belongs to the API key.

Recover Leads After an Outage

If your server was down for longer than the retries last, or rejected real leads, POST /api/v1/signals/{signal_id}/replay-webhook resends the leads the signal already produced, with no request body. Each lead goes out again in the same shape as its first delivery, with the same X-Webhook-Id and signal.is_replay set to true. Disqualified leads are not resent. The response gives total, sent, failed and skippedDisqualified.

curl -X POST "https://api.rodz.io/api/v1/signals/$SIGNAL_ID/replay-webhook" \
  -H "Authorization: Bearer $RODZ_API_KEY"

Your deduplication prevents processing a lead you already received twice. To read leads without a webhook, GET /api/v1/signals/{signal_id}/leads returns them in the same format, with since, limit (1 to 100, 25 by default) and offset.

FAQ

What happens if I do not verify the signature?

Your endpoint accepts every request without distinction. A third party can send fake leads, trigger your workflows on made-up data or probe your server with injections. It is the equivalent of leaving the front door open.

Is HMAC-SHA256 enough to secure my webhooks?

It guarantees authenticity (the request comes from Rodz) and integrity (the content was not modified). For an endpoint that receives leads, it is the main control. Combine it with an encrypted transport (HTTPS), deduplication on X-Webhook-Id and, if you wish, a timestamp check.

Where do I find the webhook secret?

Under Integrations → API in the dashboard. Each API key has its secret, generated automatically, which you can view or regenerate on the same page. After a regeneration, update the environment variable on your server.

Why does verification fail when the secret is right?

Almost always because the signature is recomputed on JSON that was parsed and re-serialized instead of the raw bytes. Read the body before any JSON parser (express.raw, request.get_data()). Also check that you sign timestamp.raw body, not the body alone, and that you compare the hex string without a prefix. Finally, run test-webhook: if signed is false, no API key is linked to the signal and there is no signature to verify.

Can I use the same secret for several endpoints?

The secret is the API key’s, and each API key has its own. If you want separate secrets, for example one per environment, use one API key per environment.

What does Rodz do if my server returns an error?

A 2xx marks the delivery as successful. A timeout, a connection error, a 5xx or a 429 is retried. Any other 4xx (bad URL, authentication, validation) is final and is not retried.

Why can the same lead arrive twice?

Because retries guarantee at-least-once delivery: if your response gets lost, Rodz sends again. The X-Webhook-Id header is identical on every attempt; deduplicate on it.

How do I test verification in development?

Use test-webhook with a public URL: the URL must be reachable from the internet, so a tunnel such as ngrok works for a local server. You then receive a real signature computed by Rodz. The openssl method described above lets you test offline.

Does HMAC verification slow down webhook processing?

No. Computing an HMAC-SHA256 is negligible next to the rest of the work on a lead (database writes, API calls).

What if verification fails in production when it used to work?

Check three things in order: (1) the secret was not regenerated on Rodz’s side without being updated on your server, (2) your middleware does not modify the body before verification (compression, transformation, parsing), (3) no intermediate proxy alters the headers or the body. Once fixed, replay-webhook resends the leads rejected in the meantime. If the problem persists, see the Rodz API documentation or contact support.

Wrapping Up

Your endpoints are now protected: you can build automated workflows without wondering where requests come from.

To go further:

Share:

Reach your prospects at the right moment, not randomly

Find the signals that fit your company and the tool that includes them.

Generate your outbound strategy for free

Our AI analyzes your company and creates a complete playbook: ICP, personas, email templates, call scripts.

Generate my strategy