How to verify webhook signatures (Node.js, PHP, Python)
By Konkon Live team · Reviewed by Lawrence Attah, founder of Konkon Social Ltd · Updated 30 November 2026 · 4 min read
Konkon signs every webhook. Take the timestamp and the signature from the Konkon-Signature header, compute an HMAC-SHA256 of the timestamp, a dot and the raw request body using your endpoint's signing secret, and compare it in constant time. Reject the request if it does not match.
Your webhook address is public. Anyone who finds it can send it a message that says an order is paid. If your system believes that message, you could dispatch goods for money that never arrived. Checking the signature is how you know a message really came from Konkon.
What Konkon sends
For each event, Konkon sends a POST with a JSON body to your active endpoints for that mode (test or live). The body carries an id, a type, an api_version, a livemode flag, a created_at time, a sequence number and the data. Three headers matter:
| Header | What it holds |
|---|---|
| Konkon-Signature | The timestamp and the signature, in the form t=...,v1=.... |
| Konkon-Event-Id | The same as the id in the body. It stays the same on every retry. |
| Konkon-Delivery-Attempt | 1 for the first try, then 2, 3 and so on. |
The checks, in order
- Read the raw body. Use the bytes exactly as they arrived. If your framework parses the JSON first and you serialise it again, the spacing can change and the signature will fail.
- Read the Konkon-Signature header and pull out the timestamp (t) and the v1 value.
- Check the timestamp. Reject it if it is too old. The documentation sample allows five minutes. This stops someone replaying an old message.
- Compute the signature. HMAC-SHA256, as hex, of the timestamp, then a dot, then the raw body, keyed with your endpoint's signing secret (it starts with whsec_).
- Compare in constant time. Use the safe compare function in your language, not a plain equals check.
- Answer 400 if anything fails. If it passes, answer with a 2xx status quickly and do the heavy work afterwards.
When you rotate a signing secret, the header can carry two v1 values for a while. Accept the message if either one matches.
Node.js (Express)
Use express.raw on this route so you get the raw body, not parsed JSON.
const crypto = require('crypto');
const express = require('express');
const app = express();
app.post('/konkon-webhook', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('Konkon-Signature') || '';
const parts = Object.fromEntries(header.split(',').map(p => p.split('=')));
const t = parts.t;
const sigs = header.split(',').filter(p => p.startsWith('v1=')).map(p => p.slice(3));
const age = Math.abs(Date.now() / 1000 - Number(t));
const expected = crypto.createHmac('sha256', process.env.KONKON_WHSEC)
.update(t + '.' + req.body.toString('utf8')).digest('hex');
const ok = age <= 300 && sigs.some(s => s.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
if (!ok) return res.status(400).end();
res.status(200).end(); // answer first
// then process JSON.parse(req.body)
});PHP
$raw = file_get_contents('php://input');
$header = $_SERVER['HTTP_KONKON_SIGNATURE'] ?? '';
$t = null; $sigs = [];
foreach (explode(',', $header) as $part) {
[$k, $v] = array_pad(explode('=', $part, 2), 2, '');
if ($k === 't') $t = $v;
if ($k === 'v1') $sigs[] = $v;
}
$expected = hash_hmac('sha256', $t . '.' . $raw, getenv('KONKON_WHSEC'));
$ok = $t !== null && abs(time() - (int)$t) <= 300;
$match = false;
foreach ($sigs as $s) { if (hash_equals($expected, $s)) $match = true; }
if (!$ok || !$match) { http_response_code(400); exit; }
http_response_code(200);Python
import hmac, hashlib, time
def verify_konkon(secret, raw: bytes, header, tolerance=300):
parts = [p.split('=', 1) for p in header.split(',') if '=' in p]
t = next((v for k, v in parts if k == 't'), None)
sigs = [v for k, v in parts if k == 'v1']
if t is None or abs(time.time() - int(t)) > tolerance:
return False
signed = t.encode() + b'.' + raw
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(expected, s) for s in sigs)Keep the signing secret in an environment variable or your secrets store. Never put it in your front-end code or in a public repository.
After the signature passes
- Expect the same event more than once. Delivery is at least once. Save the event id and ignore ids you have already handled.
- Do not rely on order. Events can arrive out of order. Use the sequence number to ignore a stale event, or fetch the transaction to see its current state.
- Answer quickly. Reply with a 2xx status within the time the documentation gives, then do the work. A slow or failed reply is retried several times, and a delivery that keeps failing is eventually marked dead.
- Test first. Send a webhook.test event from the sandbox and make sure your code passes it before you switch to live mode. Live mode is switched on only after Konkon approves your business.
Event names and the full list of fields are in the API documentation. To see what the order stages mean, read how a delivery code releases payment.
Frequently asked questions
What does the Konkon-Signature header look like?
It holds a timestamp and one or more signatures, for example t=1732442531,v1=.... The v1 value is an HMAC-SHA256 in hex.
What exactly is signed?
The timestamp from the header, a dot, and the raw request body exactly as received, keyed with your endpoint's whsec_ signing secret.
Why does my signature never match?
The most common cause is a parsed or re-serialised body. Make sure your code uses the raw bytes. Also check that you are using the signing secret for the right endpoint and the right mode, test or live.
Why are there two v1 values in the header?
This happens while a signing secret is being rotated. Accept the message if either value matches.
Can I get the same webhook twice?
Yes. Delivery is at least once, and the event id stays the same on retries, so save ids and skip ones you have handled.
Keep reading
What escrow is and how it works for online shops in Nigeria
Escrow means a third party holds the buyer's money until the buyer has the goods. How it works step by step, what it changes for a shop, and what it does not do.
Konkon ProtectHow a delivery code releases payment to the seller
After a buyer pays on Konkon Protect they are emailed a 6-digit delivery code. They give it only when they have the goods. What happens next, and the stages an order moves through.
Ready to try it?
Read the API docs and run the whole flow in the sandbox before any real money moves.
Read the API docsHow we wrote this. This guide is based on the Konkon Protect API documentation at api.konkon.ng/docs, read on 30 November 2026. The code samples are short examples written for this guide from the documented steps. Test them in the sandbox with a webhook.test event before you rely on them. It does not cover other companies' webhooks. Fees, limits and rules can change, so check the product page for the latest. Last reviewed 30 November 2026.
About Konkon. Konkon Live is a map-based marketplace for Nigeria. Konkon Protect, Konkon Logistics and Brand HQ are products for businesses, run by Konkon Social Ltd (CAC RC 7858508).