Overview
Webhooks allow you to receive HTTP notifications when specific events occur in your Smartbills account. Instead of polling the API for changes, Smartbills pushes notifications to your server in real-time.Real-time updates: Webhooks are delivered within seconds of the event occurring, making them ideal for automation and integrations.
How Webhooks Work
1
Event Occurs
An action happens in Smartbills (e.g., expense created, report approved)
2
Webhook Triggered
Smartbills prepares a webhook payload with event details
3
HTTP POST Sent
Smartbills sends an HTTP POST request to your configured endpoint
4
Your Server Responds
Your server processes the webhook and returns a 200 OK response
Setting Up Webhooks
Register Your Webhook
Register your endpoint with Smartbills via the API:Response
Available Events
Expense Events
Expense Report Events
Bill Events
Business Events
Webhook Payload Structure
All webhooks follow this structure:Payload Fields
Webhook Security
Verify Signatures
Always verify webhook signatures to ensure requests are from Smartbills. Smartbills signs every webhook payload using HMAC-SHA256 with your webhook secret:Retry Policy
Smartbills automatically retries failed webhook deliveries:
Retry conditions:
- HTTP status code >= 500
- Connection timeout
- Connection refused
- DNS resolution failure
- HTTP status code < 500 (including 4xx errors)
- Invalid SSL certificate
Managing Webhooks
List Webhooks
Update Webhook
Delete Webhook
Test Webhook
Send a test event to verify your endpoint is working:Best Practices
Respond Quickly
Respond Quickly
Return a 200 OK response within 5 seconds. Acknowledge receipt immediately and process the event asynchronously using a job queue.
Handle Idempotency
Handle Idempotency
Webhooks may be delivered more than once. Store event IDs and check for duplicates before processing.
Verify Signatures
Verify Signatures
Always verify the
x-smartbills-signature header before processing any webhook payload.Use HTTPS
Use HTTPS
Your webhook endpoint must use HTTPS in production to protect the payload in transit.
Log Everything
Log Everything
Log incoming webhook payloads, signature verification results, and processing outcomes for debugging.
Testing Webhooks Locally
Use tools like ngrok to test webhooks during local development:Related Resources
API Keys
Secure your webhook endpoints
Error Handling
Handle webhook errors
Rate Limits
API rate limiting
Environments
Sandbox and production