Verifying requests
Your webhook URL is reachable by anyone on the internet, so your endpoint must not trust a request just because it arrived. Use all three checks below.
1. Check the signature
Prembly signs every event on this page. The signature in X-Prembly-Signature is:
base64( HMAC-SHA256( key = your public key, message = raw request body ) )Which key:
Signed with your sandbox public key (test_pk_…) | Signed with your live public key (live_pk_…) |
|---|---|
| Sandbox SDK sessions, sandbox direct API verifications, sandbox statement analyses, and transaction monitoring events for sandbox transactions | Everything else, including events triggered from sandbox: workflow runs, async verifications, retry results, Customer 360 checks, watchlist alerts and credit events |
Your keys are on Developers → API Integrations, in the Public Key row. Switch between Sandbox Mode and Live Mode to see each one.
To check it:
- Read the raw request body as bytes, before any JSON parsing.
- Compute the HMAC-SHA256 of those bytes using the public key as the secret, and base64-encode the result.
- Compare your value with the header using a constant-time comparison. Reject the request with
401if they differ or the header is missing.
const crypto = require('crypto');
const express = require('express');
const app = express();
// Keep the raw body: express.json() would re-serialise it and break the signature.
app.post('/webhooks/prembly', express.raw({ type: 'application/json' }), async (req, res) => {
const received = req.get('x-prembly-signature') || '';
const expected = crypto
.createHmac('sha256', process.env.PREMBLY_PUBLIC_KEY)
.update(req.body) // req.body is a Buffer here
.digest('base64');
const a = Buffer.from(received);
const b = Buffer.from(expected);
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
return res.status(401).send('invalid signature');
}
const event = JSON.parse(req.body.toString('utf8'));
// Acknowledge first, then do the work in the background.
res.status(200).json({ received: true });
await queue.add('prembly-webhook', {
reference: req.get('prembly-reference'),
event,
});
});2. Confirm the result with your secret key before you act on it
The signature alone is not enough
Webhooks are signed with your public key, which is also used in client-side SDK code. Anyone who has your public key can produce a valid signature. A matching signature tells you the body wasn't changed in transit; it doesn't prove the request came from Prembly.
Before you do anything that matters — approve an account, release funds, change a user's status — fetch the result from Prembly's API with your secret key and act on that response, not the webhook body.
Treat the webhook as a notification that something changed, then confirm it:
- SDK sessions: call the session lookup API with
data.widget_info.session_id. - Everything else: fetch the record by its ID (workflow run, transaction, credit application, verification) from the matching endpoint in the API reference.
Your secret key never leaves your server, so a forged webhook can't change what that API call returns.
3. Make your URL hard to guess
Use a long, random path that only you and Prembly know, for example:
https://api.yourcompany.com/webhooks/prembly/6f1c9a3e2b7d4e0f8a5c1d9b3e7f2a6cReject requests to any other path. Change the path (and update it in the dashboard) if you think it has leaked.
Other things to know
- No timestamp is signed. A captured request can be sent to you again later and its signature will still match. Record what you've processed and skip repeats (see Duplicates).
- Regenerating your public key changes the signing key immediately. Update the key on your webhook server at the same time, or signatures will stop matching. Regenerating also invalidates the key in your mobile and web apps.
- Workflow notification nodes are not signed. A Send Notification node with the Webhook type, and the
callback_urlyou can pass when executing a workflow trigger node, post to the URL you configure without anX-Prembly-Signatureheader. Treat them as unauthenticated and always confirm with the API. - Prembly doesn't publish a fixed list of sending IP addresses, so you can't rely on an IP allowlist.
Next steps
- Delivery & retries — respond correctly, handle retries and duplicates, and resend failed deliveries