Configuration
Set your webhook endpoint URL and shared secret in the gateway configuration:webhook-secret is used to compute the sign field in each webhook payload, allowing you to verify the notification originated from your gateway.
Payload Format
Every webhook callback is aPOST request with a JSON body following the NotifyPayload structure:
Example Payload
Signature Verification
Verify the webhook signature using yourwebhook-secret:
Algorithm
- Serialize the
dataobject (thedatafield from the payload) as compact JSON. - Compute
HMAC-SHA256(data_json, webhook_secret). - Convert to lowercase hex and compare with the
signfield.
Node.js
Python
Retry Policy
If your endpoint does not return a2xx status code within 10 seconds, XPayLabs retries the webhook with exponential backoff:
After 4 failed attempts, the notification is marked as failed. Failed webhooks are logged and can be replayed from the gateway dashboard.
Best Practices
- Respond immediately. Return
200as fast as possible, then process the event asynchronously. - Verify every payload. Always check the HMAC signature before acting on a webhook.
- Use
noncefor deduplication. Store processed nonces to handle at-least-once delivery. - Check
notifyType. Route events based on the notification type to handle each event correctly.

