Webhooks allow you to receive real-time notifications when events occur in your Unter account, such as successful payments or payment failures. Instead of constantly polling our API for updates, webhooks push notifications directly to your server when something important happens.
How Webhooks Work
Configure your webhook URL - Tell Unter where to send notifications
Event occurs - A payment succeeds, fails, etc.
Unter sends HTTP POST - We POST event data to your URL
Your server responds - Return 200 OK to acknowledge receipt
Retry if needed - We retry failed deliveries with exponential backoff
Webhook Events
payment.succeeded
Fired when a payment is successfully confirmed on the blockchain.
Unter signs all webhook payloads using HMAC-SHA256 with your webhook secret. This ensures the webhook is actually from Unter and hasn't been tampered with.
Getting Your Webhook Secret: You can find your webhook secret in the Unter merchant portal under the webhook settings section. The secret is automatically generated when you first configure your webhook URL.
Signature Verification
Each webhook includes a Unter-Signature header with the following format:
Where:
t = Unix timestamp when the signature was generated
v1 = HMAC-SHA256 hex digest of the signed payload
Verifying Signatures
Step 1: Extract timestamp and signature
Step 2: Create signed payload
Concatenate the timestamp, a period, and the raw request body:
Step 3: Generate expected signature
Step 4: Compare signatures Use constant-time comparison to prevent timing attacks:
Step 5: Check timestamp tolerance Reject webhooks older than 5 minutes (300 seconds) to prevent replay attacks:
Retry Logic
Unter automatically retries failed webhook deliveries using exponential backoff:
Attempt 1: Immediately
Attempt 2: After 1 minute
Attempt 3: After 3 minutes
Attempt 4: After 5 minutes
Attempt 5: After 10 minutes
Attempt 6: After 30 minutes
Attempt 7: After 2 hours
A webhook is considered failed if:
Your server doesn't respond within 10 seconds
Your server returns a non-2xx HTTP status code
Network connection fails
After 7 failed attempts, we stop retrying and mark the webhook as permanently failed.
Implementation Examples
JavaScript (Node.js with Express)
Best Practices
1. Always Verify Signatures
Never process webhooks without verifying the signature. This prevents malicious actors from sending fake webhooks to your server.
2. Handle Idempotency
The same webhook may be delivered multiple times. Use the event ID to ensure you only process each event once:
3. Respond Quickly
Respond with 200 OK as quickly as possible. Do heavy processing (database updates, email sending) asynchronously:
4. Handle Failures Gracefully
Your webhook endpoint should be fault-tolerant and handle errors gracefully:
Common Issues
1. Signature Verification Failures
Causes:
Wrong webhook secret
Modifying request body before verification
Clock synchronization issues
Solutions:
Verify you're using the correct secret from the webhook settings
Verify signature before parsing/modifying the request body
Ensure server time is synchronized with NTP
2. Webhook Timeouts
Causes:
Slow database queries in webhook handler
Synchronous external API calls
Heavy processing in webhook handler
Solutions:
Respond with 200 OK immediately
Process webhooks asynchronously
Optimize database queries
3. Duplicate Processing
Causes:
Not implementing idempotency
Multiple server instances processing same webhook
Solutions:
Use event ID to track processed webhooks
Implement proper database locking/transactions
Security Considerations
Always verify signatures - Never trust unverified webhooks
Validate timestamp - Reject old webhooks to prevent replay attacks