Validating Webhooks
BlockWyre signs all outbound webhooks using RS512 (RSA-SHA512) detached JWS signatures. This allows you to verify that webhooks are authentic and haven't been tampered with, without needing a shared secret.
How It Works
- BlockWyre signs the exact bytes of each webhook body with an RSA private key
- The signature is sent as a detached JWS in the
X-BlockWyre-Signatureheader - You fetch BlockWyre's public key from the JWKS endpoint to verify the signature
The signature covers the body only. None of the headers — X-BlockWyre-Timestamp, X-Tenant-ID and the rest — is signed.
JWKS Endpoint
Each environment publishes its own keys, and the two environments sign webhooks with different keys. Verify a webhook with the JWKS of the environment that sent it: a sandbox webhook does not verify against the production JWKS, nor the reverse.
| Environment | JWKS URL | Webhook signing key kid |
|---|---|---|
| Sandbox | https://api-sandbox.blockwyre.xyz/.well-known/jwks.json | bw-sandbox-20260915 |
| Production | https://api.blockwyre.com/.well-known/jwks.json | bw-20260201 |
The endpoint is public (no authentication required) and returns BlockWyre's current public keys in JWK Set format.
The set holds every key BlockWyre signs with: the RSA key that signs webhooks
and the Ed25519 key that signs access tokens. Pick the key whose kid matches
the signature's, never the first one in the list.
Response (production):
{
"keys": [
{
"kty": "RSA",
"kid": "bw-20260201",
"alg": "RS512",
"use": "sig",
"n": "...",
"e": "AQAB"
},
{
"kty": "OKP",
"crv": "Ed25519",
"kid": "...",
"alg": "EdDSA",
"use": "sig",
"x": "..."
}
]
}
Caching: The endpoint returns Cache-Control: public, max-age=3600. Cache the JWKS for up to 1 hour and refresh on a kid miss (indicating key rotation).
Signature Format
The signature is a detached JWS in compact serialization:
<base64url-header>..<base64url-signature>
Note the empty payload segment (two consecutive dots). The payload is the raw HTTP request body, byte for byte.
Header (decoded, production):
{
"alg": "RS512",
"kid": "bw-20260201"
}
Signature Version
| Version | Format | Algorithm |
|---|---|---|
20260209 (current) | Detached JWS | RS512 |
Verification Steps
- Read the raw body as bytes, before any JSON parsing
- Fetch the JWKS of the environment that sent the webhook (cache for 1 hour, refresh on
kidmiss) - Extract the
kidfrom the JWS header (base64url-decode the part before..) - Find the matching key in the JWKS by
kid - Reconstruct the full JWS by inserting the raw request body (base64url-encoded) between the two dots
- Verify the RS512 signature using the public key from JWKS
- Parse the verified bytes as JSON, and deduplicate on
webhookId(see Replay Protection)
The signature is over the exact bytes BlockWyre sent. Parsing the body and
serializing it again (for example JSON.stringify(req.body)) can change those
bytes — escapes such as \u003c for <, \u003e for > and \u0026 for
&, spacing, number formatting or key order, depending on your language — and
the signature then no longer verifies. Capture the raw body before any JSON
middleware.
Code Examples
Node.js (Express)
Uses the jose library. createRemoteJWKSet caches the key set and fetches it again when a signature names a kid it does not have.
import express from "express";
import { compactVerify, createRemoteJWKSet } from "jose";
// The JWKS of the environment your target receives webhooks from.
// Sandbox: https://api-sandbox.blockwyre.xyz/.well-known/jwks.json
// Production: https://api.blockwyre.com/.well-known/jwks.json
const JWKS = createRemoteJWKSet(
new URL("https://api-sandbox.blockwyre.xyz/.well-known/jwks.json"),
{ cacheMaxAge: 60 * 60 * 1000 } // 1 hour
);
async function verifyWebhook(rawBody, headers) {
const signatureVersion = headers["x-blockwyre-signature-version"];
if (signatureVersion !== "20260209") {
throw new Error(`Unsupported signature version: ${signatureVersion}`);
}
// Detached JWS: "<header>..<signature>"
const parts = String(headers["x-blockwyre-signature"] ?? "").split("..");
if (parts.length !== 2) {
throw new Error("Invalid signature format");
}
// Put the raw body bytes, base64url-encoded, between the two parts.
const fullJWS = `${parts[0]}.${rawBody.toString("base64url")}.${parts[1]}`;
const { payload } = await compactVerify(fullJWS, JWKS, { algorithms: ["RS512"] });
// Parse only the bytes that were verified.
return JSON.parse(new TextDecoder().decode(payload));
}
const app = express();
// express.raw keeps req.body as the exact bytes received (a Buffer).
// Do not run express.json() on this route.
app.post("/webhooks/blockwyre", express.raw({ type: "application/json" }), async (req, res) => {
let event;
try {
event = await verifyWebhook(req.body, req.headers);
} catch {
return res.status(401).end();
}
res.status(204).end();
// Then deduplicate on event.webhookId and process the event asynchronously.
});
In other frameworks, do the same: read the request body as raw bytes before any JSON parser runs, verify those bytes, then parse them.
Replay Protection
X-BlockWyre-Timestamp is not covered by the signature, and BlockWyre sets it
fresh on every delivery attempt. Anyone holding a copy of a request can send it
again with a new timestamp, so a time window does not protect you from replays.
- Deduplicate on
webhookId. It is in the signed body, it is unique per event per target, and it stays the same across that event's retries and resends. Record eachwebhookIdyou have processed and drop a repeat. TheX-BlockWyre-Webhook-IDheader carries the same value but is not signed. - Treat
X-BlockWyre-Timestampas a freshness hint only — for example, to log or alert on deliveries that arrive late. If you do reject on it, allow for clock skew. - Do not reject on the body's
timestamp. It is when the event occurred, and a retry (up to about 14 minutes later) or a resend from the dashboard keeps it.
Key Rotation
BlockWyre may rotate signing keys. A new key is published in the JWKS under a
new kid.
Your implementation handles this automatically if you:
- Look up keys by
kid(not by index) - Refresh the JWKS cache when you encounter an unknown
kid
Support and Resources
If you need assistance or have any questions, our support team is here to help. You can contact our support team at support@blockwyre.com.
Stay Updated
Stay up-to-date with the latest news, updates, and features from BlockWyre by following us on social media:
- Instagram: BlockWyre Instagram
- Twitter: BlockWyre Twitter
- Facebook: BlockWyre Facebook
- LinkedIn: BlockWyre LinkedIn
We are excited to have you on board and look forward to seeing how you leverage BlockWyre's powerful tools to enhance your financial operations. Happy integrating!