Signature Verification

Signature Verification

Webhook security is provided by HMAC-SHA256 signature verification. All webhook requests are signed with the X-Adisyo-Signature header.

Signature Algorithm

Signature Calculation

Message   = webhookEventType + "|" + eventTimeUtc + "|" + ApiKey
Signature = Base64(HMACSHA256(key: ApiKey, data: Message))

webhookEventType and eventTimeUtc are the fields in the body of the incoming request. The API Key is also used as the HMAC key.

Test Data

You can try your function with the values below. The result must be identical to the expected signature.

Value
API KeyADSYO-TEST-KEY
webhookEventTypeorder.created
eventTimeUtc2025-10-21T11:59:50.1855130Z
Expected signaturePnzyRcuQLC2wN763P7kyuXdEBjYQogFOM/69/e0Vb1I=

The Message built from these values:

order.created|2025-10-21T11:59:50.1855130Z|ADSYO-TEST-KEY

Header Format

X-Adisyo-Signature: <base64-encoded-signature>

Code Examples

Node.js

import { createHmac, timingSafeEqual } from 'crypto';
 
function verifySignature(payload, signature, apiKey) {
  const webhookData = JSON.parse(payload);
  const message = `${webhookData.webhookEventType}|${webhookData.eventTimeUtc}|${apiKey}`;
  const expectedSignature = createHmac('sha256', apiKey)
    .update(message)
    .digest('base64');
  
  return timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}
 
// Usage
app.post('/webhook', (req, res) => {
  const signature = req.headers['x-adisyo-signature'];
  const apiKey = process.env.ADISYO_API_KEY;
  
  if (!verifySignature(JSON.stringify(req.body), signature, apiKey)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }
  
  // Process webhook
  res.status(200).json({ success: true });
});