Webhooks
Webhooks allow you to receive real-time notifications when events occur in your Huntrecht account. Instead of polling our API for changes, webhooks push event data to your endpoint as soon as events happen.
Overview
Huntrecht uses webhooks to notify your application about:
- Order events - Created, updated, paid, fulfilled, cancelled
- Payment events - Authorized, captured, refunded, failed
- Company events - Created, verified, updated
- Subscription events - Created, renewed, cancelled, payment failed
- Credit events - Score updated, limit changed
Configuration
Setting Up Webhook Endpoints
- Go to your Developer Dashboard → Webhooks
- Click Add Endpoint
- Enter your HTTPS endpoint URL
- Select the events you want to subscribe to
- Save your configuration
Webhook Payload Structure
{
"id": "evt_1234567890",
"object": "event",
"type": "order.created",
"created_at": "2026-04-02T10:30:00Z",
"data": {
"object": {
"id": "ord_abc123",
"object": "order",
"company_id": "comp_xyz789",
"status": "pending",
"amount": 5000.00,
"currency": "USD",
"created_at": "2026-04-02T10:30:00Z"
}
}
}
Event Types
Order Events
| Event | Description |
|---|---|
order.created | New order created |
order.updated | Order details modified |
order.paid | Payment received |
order.fulfilled | Order shipped/delivered |
order.cancelled | Order cancelled |
Payment Events
| Event | Description |
|---|---|
payment.authorized | Payment authorized |
payment.captured | Payment captured |
payment.refunded | Refund processed |
payment.failed | Payment failed |
Company Events
| Event | Description |
|---|---|
company.created | New company registered |
company.verified | Company KYC verified |
company.updated | Company details updated |
Subscription Events
| Event | Description |
|---|---|
subscription.created | New subscription started |
subscription.renewed | Subscription renewed |
subscription.cancelled | Subscription cancelled |
subscription.payment_failed | Subscription payment failed |
Security
Signature Verification
All webhooks include a signature header for verification:
X-Huntrecht-Signature: t=1648825200,v1=abc123def456
Verify signatures using your webhook secret:
import hmac
import hashlib
def verify_webhook(payload, signature, secret):
expected = hmac.new(
secret.encode(),
payload.encode(),
hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected, signature)
Best Practices
- Use HTTPS - Only accept webhooks over HTTPS
- Verify signatures - Always verify webhook signatures
- Respond quickly - Return 200 OK within 5 seconds
- Handle retries - Webhooks retry up to 5 times with exponential backoff
- Idempotency - Handle duplicate events using the event ID
Testing Webhooks
Local Development
Use ngrok or similar tools to test webhooks locally:
ngrok http 3000
Then configure the ngrok URL in your webhook settings.
Webhook Testing Endpoint
Test webhook reception:
curl -X POST https://api.huntrecht.com/v1/webhooks/test \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"endpoint": "https://your-endpoint.com/webhook",
"event": "order.created"
}'
Retry Policy
If your endpoint returns a non-2xx status code:
| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | 5 seconds |
| 3 | 25 seconds |
| 4 | 2 minutes |
| 5 | 10 minutes |
After 5 failed attempts, the webhook is marked as failed and you must manually retry from the dashboard.
Debugging
View Webhook Logs
Access webhook delivery logs in your dashboard:
- Go to Developer Dashboard → Webhooks
- Select your endpoint
- View Delivery History
Common Issues
| Issue | Solution |
|---|---|
| 404 Not Found | Check endpoint URL |
| 500 Server Error | Fix your server code |
| Timeout | Respond faster, process asynchronously |
| Invalid signature | Check webhook secret |
Rate Limits
- Standard Plan: 10,000 webhooks/day
- Pro Plan: 100,000 webhooks/day
- Enterprise: Custom limits