Skip to main content

1. Overview

When business state changes occur, EasyBilling sends webhook notifications as HTTP POST requests with a JSON body.

1.1 Supported Event Types

1.2 Standard Payload Structure

All webhook events are wrapped in a common envelope:
  • id: Globally unique event ID (UUID v4)
  • type: Event type
  • createdAt: Event creation timestamp
  • data.object: Event business payload
The id remains unchanged across retries and should be used as your idempotency key for deduplication.

Example: payment.succeeded

Example: credit_schedule.depleted

Example: invoice.posted, credit_memo.posted

Example: contract.created, contract.updated, contract.cancelled

2. Signature Verification (HMAC-SHA256)

To prevent tampering and spoofing, each webhook request includes this header:
  • Header name: X-Webhook-Signature
  • Header format: t=<unix_timestamp_seconds>,v1=<hex_digest>
  • String to sign: timestamp + "." + rawBody
  • Algorithm: HMAC-SHA256 with your webhook secret

Critical Validation Rule

Always compute the signature using the raw HTTP request body bytes. Do not re-serialize parsed JSON before verification, or signature checks may fail due to formatting/key-order differences.

Python Example

3. Retry Policy and Time Window

Timestamp Tolerance

  • Recommended tolerance: 300 seconds (5 minutes)
  • If request timestamp is outside the tolerance window, reject the request
  • This helps prevent replay attacks

Delivery Retry Policy

EasyBilling automatically retries webhook delivery when:
  • Receiver returns non-2xx HTTP status
  • Network timeout/failure occurs
Defaults and behavior:
  • Default max retries: 3
  • Retry intervals: 1 minute
  • Retry with the same webhook id
  • If all retries fail, event status is marked as FAILED

5. Receiver Best Practices

  1. Return 2xx quickly after minimal validation, then process asynchronously.
  2. Use webhook id for deduplication across retries.
  3. Verify signature before any business processing.
  4. Enforce timestamp tolerance (recommended: 5 minutes).
  5. Log key metadata (id, type, createdAt, delivery timestamp, verification result).
  6. Implement safe retry handling in your own downstream processing.

6. Go-Live Checklist

  • Webhook endpoint is reachable from Billing
  • Signature verification is implemented with raw body
  • Replay protection window is enabled
  • Event deduplication by webhook id is implemented
  • Non-2xx handling and observability are in place
  • Sandbox event triggering is tested end-to-end