Webhook Events Reference
Webhooks allow you to receive real-time notifications about events in your Decoda Health account. This guide documents all available event types and their payload structures.Available Event Types
The following event types can be subscribed to:| Event Type | Description | When It Fires |
|---|---|---|
PAYMENT_CREATED | A payment record is created | When a payment is initiated |
PAYMENT_COMPLETED | A payment is successfully completed | When payment processing succeeds |
PAYMENT_FAILED | A payment fails to process | When payment processing fails |
CHARGE_CREATED | A charge is created | When a new charge/bill is created |
ADJUSTMENT_CREATED | An adjustment is made to a charge | When discounts, write-offs, or adjustments are applied |
REFUND_CREATED | A refund is processed | When a refund is issued |
PATIENT_CREATED | A new patient is created | When a patient record is first created |
PATIENT_UPDATED | A patient record is updated | When patient information changes |
Event Payload Structure
All webhook events follow this structure:Common Fields
- id: Unique identifier for the webhook event
- type: The event type (see table above)
- data: Event-specific payload (varies by event type)
- createdDate: ISO 8601 timestamp when the event occurred
- alertId: Associated alert ID for tracking
Event-Specific Payloads
PAYMENT_CREATED
Fired when a payment is initiated (before processing completes).PAYMENT_COMPLETED
Fired when a payment successfully completes processing.PAYMENT_FAILED
Fired when a payment fails to process.CHARGE_CREATED
Fired when a new charge/bill is created.ADJUSTMENT_CREATED
Fired when an adjustment (discount, write-off, etc.) is applied to a charge.REFUND_CREATED
Fired when a refund is processed.PATIENT_CREATED
Fired when a new patient record is created.PATIENT_UPDATED
Fired when a patient record is updated.Webhook Delivery
Delivery Guarantees
- At-least-once delivery: Events may be delivered multiple times
- Ordering: Events are delivered in order, but network issues may cause out-of-order delivery
- Idempotency: Always check event IDs to avoid processing duplicates
Retry Logic
If your webhook endpoint returns a non-2xx status code or times out:- Immediate retry: After 1 second
- Exponential backoff: Subsequent retries after 5s, 15s, 60s, 5min, 15min
- Maximum attempts: 6 attempts over ~30 minutes
- Failure notification: Email sent to
notification_emailafter final failure
Best Practices
Idempotency
Always check event IDs to prevent duplicate processing. Store processed event IDs in your database.
Quick Response
Respond quickly (within 5 seconds) to avoid timeouts. Process events asynchronously if needed.
Error Handling
Return proper HTTP status codes. 2xx = success, anything else triggers retries.
Signature Verification
Always verify webhook signatures to ensure events are from Decoda Health.
Example Webhook Handler
Here’s a complete example of handling webhooks:Testing Webhooks
Using ngrok for Local Development
- Start your local server
- Expose it with ngrok:
ngrok http 3000 - Use the ngrok URL when creating your webhook
- Test events will be delivered to your local server
Webhook Testing Endpoint
You can manually trigger webhook events using the Send Webhook Event endpoint for testing purposes.Related Documentation
- Webhook Setup Guide - Learn how to create and configure webhooks
- Webhook Security - Understand webhook signature verification
- API Reference: Webhooks - Complete webhook API documentation
