Verifying signatures
Verify the exact webhook body, enforce timestamp tolerance and reject replayed events.
Every delivery includes Reqlo-Signature: t=<unix seconds>,v1=<lowercase hex HMAC>.
The signature is HMAC-SHA256(signing_secret, "<timestamp>.<raw body>"). Use the complete whsec_… secret as
the UTF-8 HMAC key; do not decode its hex suffix. Signing uses the time of each attempt, so old events retried later
receive a fresh signature. Each endpoint has one secret, so one signature is sent. To change the secret, add a new endpoint, switch your
receiver to it, then remove the old one.
Node.js verifier
Read the original body bytes before JSON parsing. Compare signatures in constant time, and reject timestamps more than 300 seconds in the past or future. Keep the receiver's clock synchronized.
Every SDK verifies this for you:
| SDK | Call |
|---|---|
| TypeScript | constructWebhookEvent(body, header, secret) or verifyWebhook(...) |
| Python | reqlo.webhooks.construct_event(body, header, secret) or verify(...) |
| Go | reqlo.ConstructEvent(body, header, secret, time.Now()) or VerifyWebhook(...) |
| Java | Webhooks.constructEvent(body, header, secret) or Webhooks.verify(...) |
Pass the raw request body exactly as received. Without an SDK, the check is a few lines:
import { createHmac, timingSafeEqual } from "node:crypto";
function verifyWebhookSignature(
raw: Buffer,
header: string | null,
secret: string,
nowSec = Math.floor(Date.now() / 1000)
): boolean {
const match = /^t=(\d{1,12}),v1=([a-f0-9]{64})$/.exec(header ?? "");
if (!match || !/^whsec_[a-f0-9]{64}$/.test(secret)) return false;
if (Math.abs(nowSec - Number(match[1])) > 300) return false;
const expected = createHmac("sha256", secret)
.update(match[1] + ".")
.update(raw)
.digest();
return timingSafeEqual(expected, Buffer.from(match[2], "hex"));
}For example, in a Next.js server route:
export async function POST(request: Request) {
const raw = Buffer.from(await request.arrayBuffer());
const secret = process.env.REQLO_WEBHOOK_SECRET!;
if (!verifyWebhookSignature(raw, request.headers.get("Reqlo-Signature"), secret)) {
return new Response("Invalid signature", { status: 400 });
}
const event = JSON.parse(raw.toString("utf8"));
if (event.environment_id !== process.env.REQLO_ENVIRONMENT_ID) {
return new Response("Wrong environment", { status: 400 });
}
// Your application must atomically deduplicate the event and enqueue its job.
await saveEventAndQueueOnce(event);
return new Response(null, { status: 204 });
}saveEventAndQueueOnce is your application's durable transaction, not a ReQlo SDK method. Apply a request-size
limit at your receiver and validate event fields before storing them. The published TypeScript SDK 0.1.0 does not
include a webhook signature helper; use the verifier above or your own equivalent implementation.
A valid signature proves the payload was signed with your endpoint secret. It does not prove the approval is still usable and does not authorize tool execution. Retrieve current approval state and redeem the exact original request, as described in Approval webhooks.
Timestamp checking limits replay age; persistent event-ID deduplication handles retries within that window. Store deduplication records for as long as your workflow can receive or retain duplicate jobs. The delivery system can resend after a crash, so an in-memory set is insufficient.
Something wrong or unclear? Report an issue with this page.