Whenever any important changes happen in your Chargebee site, they are recorded as Events. Event contains data about affected resources and additional details such as when it occurred.
You could listen to the events in your application by configuring Webhook url and handle it based on the type of event. We post the event data as request body with content type set as application/json to your webhook url.
For example, when a subscription is cancelled due to non payment, an event "subscription_cancelled" is recorded and fired to your webhook url.
To mark a webhook notification successful, we expect the HTTP status code to be 200 from your webhook url. If we don't receive 200 response code, we retry calling your webhook with exponential time interval for next 2 days. You could also try resending it from our admin console.
API Version: Chargebee supports multiple API versions now. The api_version attribute indicates the API version based on which the event content is structured. While processing webhooks, ensure the api_version is same as the API version used by your webhook server's client library.
Securing your Webhook URL:
You can have basic authentication for the webhook url.
- In the Webhook Settings page (Settings > Webhooks), check the option My webhook URL is protected by basic authentication.
- Enter Username and Password and click Update Webhook URL OR Generate a random key and have it as part of your webhook url eg. http://yourapp.com/chargebee-webhook/cuktqaem0i2fkd5jt9cdtojcn9cvb3Y
In addition to securing your webhook, you can always fetch the event from Chargebee using Retrieve an Event API call.
Ensure that you keep the secrets secret :)
Sample EventJSON
API Index URL
Events attributes
Source of the event
Operation made through the Chargebee admin UI
Operation made through the API
Operation made through the Scheduled Jobs
Operation made through the Hosted Pages
Operation made through Self-Serve Portal
Operation that are triggered by ChargeBee System
If no source can be identified for an operation
Operation made through the JS API
Deprecated
Operation that are triggerd through bulk operation.
The types of event provided by chargebee. Refer event types for all the event types provided by us currently.
The Chargebee API Version used for rendering this event content. While processing webhooks, ensure this version is same as the API version used by your webhook server's client library.
Chargebee API version V1
Chargebee API version V2
The JSON data associated with this event. Has resources (subscription , invoice etc) based on the event type. These resources are structured based on the Chargebee API version indicated by the api_version attribute.
Array of webhook call statuses: one for each of the webhooks configured for the site. This object is only available after the first webhook call for the event has completed or timed out. Also, creation/updation of the webhook
object data is a queued operation and hence there can be an additional delay of up to 5 seconds.