API Version
Product Catalog
Library

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 event [ JSON ]

{ "event": { "api_version": "v1", "content": { "customer": { "account_credits": 0, "allow_direct_debit": false, "auto_collection": "on", "card_status": "no_card", "created_at": 1517506759, "excess_payments": 0, "id": "__test__5SK0bLNFRFuCIi8Nj", "object": "customer", "refundable_credits": 0, "taxability": "taxable" }, "subscription": { "created_at": 1517506759, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__5SK0bLNFRFuCIi8Nj", "object": "subscription", "plan_id": "plan1", "plan_quantity": 1, "started_at": 1517506759, "status": "in_trial", "trial_end": 1518802759, "trial_start": 1517506759 } }, "event_type": "subscription_created", "id": "ev___test__5SK0bLNFRFuCIipNm", "object": "event", "occurred_at": 1517506759, "source": "api", "user": "full_access_key_v1", "webhook_status": "scheduled" } }

API Index URL

https://{site}.chargebee.com/api/v1/events

Model Class

id
string, max chars=40

Uniquely identifies a event


occurred_at
timestamp(UTC) in seconds

Timestamp indicating when this event had occurred.


source
enumerated string, default=none

Source of the event


Possible values are
admin_console

Operation made through the Chargebee admin UI

api

Operation made through the API

scheduled_job

Operation made through the Scheduled Jobs

hosted_page

Operation made through the Hosted Pages

Show all values[+]
user
optional, string, max chars=150

event_type
optional, enumerated string

The types of event provided by chargebee. Refer event types for all the event types provided by us currently.


Possible values are
customer_created

Sent when a customer is created. This event happens when only a new customer is created or when a customer is automatically created during new subscription creation.

customer_changed

Sent when a customer is changed

customer_deleted

Sent when a customer is deleted

subscription_created

Sent when a new subscription is created.

Show all values[+]
api_version
optional, enumerated string, default=v1

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.


Possible values are
v1

Chargebee API version V1

v2

Chargebee API version V2

Show all values[+]
content
jsonobject

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.


optional, list of webhook

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.

This is a list of the event types we currently support. We will continue to add more events moving forward. All events follow a uniform pattern - <resource>_<event_name>. The resources that will be present in the event content are provided beneath each event type's description.

Note: If consolidated invoicing is enabled, the attributes invoice.subscription_id and credit_note.subscription_id should not be used (as it will not be present if the invoice / credit note has lines from multiple subscriptions). Instead to know the related subscriptions, their line_items' subscription_id attribute should be referred.

id id
string, max chars=40

Uniquely identifies a event


occurred_at occurred_at
timestamp(UTC) in seconds

Timestamp indicating when this event had occurred.


source source
enumerated string, default=none

Source of the event


Possible values are
admin_console

Operation made through the Chargebee admin UI

api

Operation made through the API

scheduled_job

Operation made through the Scheduled Jobs

hosted_page

Operation made through the Hosted Pages

Show all values[+]
user user
optional, string, max chars=150

event_type event_type
optional, enumerated string

The types of event provided by chargebee. Refer event types for all the event types provided by us currently.


Possible values are
customer_created

Sent when a customer is created. This event happens when only a new customer is created or when a customer is automatically created during new subscription creation.

customer_changed

Sent when a customer is changed

customer_deleted

Sent when a customer is deleted

subscription_created

Sent when a new subscription is created.

Show all values[+]
api_version api_version
optional, enumerated string, default=v1

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.


Possible values are
v1

Chargebee API version V1

v2

Chargebee API version V2

Show all values[+]
content
jsonobject

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.


webhooks
optional, list of webhook

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.


Retrieves list of events.

Sample Request
curl  https://{site}.chargebee.com/api/v1/events \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=2 \
     -d "event_type[in]"="subscription_created", "customer_created" 
copy
Click to Copy
200:
OK
STATUS

Sample Response [ JSON ]

Show more...
{
    "list": [
        {
            "event": {
                "api_version": "v1",
                "content": {
                    "customer": {
                        "account_credits": 0,
                        "allow_direct_debit": false,
                        "auto_collection": "on",
                        "card_status": "no_card",
                        "created_at": 1517506759,
                        "excess_payments": 0,
                        "id": "__test__5SK0bLNFRFuCIi8Nj",
                        "object": "customer",
                        "refundable_credits": 0,
                        "taxability": "taxable"
                    },
                    "subscription": {
                        "created_at": 1517506759,
                        "due_invoices_count": 0,
                        "has_scheduled_changes": false,
                        "id": "__test__5SK0bLNFRFuCIi8Nj",
                        "object": "subscription",
                        "plan_id": "plan1",
                        "plan_quantity": 1,
                        "started_at": 1517506759,
                        "status": "in_trial",
                        "trial_end": 1518802759,
                        "trial_start": 1517506759
                    }
                },
                "event_type": "subscription_created",
                "id": "ev___test__5SK0bLNFRFuCIipNm",
                "object": "event",
                "occurred_at": 1517506759,
                "source": "api",
                "user": "full_access_key_v1",
                "webhook_status": "scheduled"
            }
        },
        {..}
    ]
}

URL Format GET

https://{site}.chargebee.com/api/v1/events

Method

limit[]
optional, integer, default=10, min=1, max=100
The number of resources to be returned.
offset[]
optional, string, max chars=1000
Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set 'offset' to the value of 'next_offset' obtained in the previous iteration of the API call.
start_time[]
optional, timestamp(UTC) in seconds

Returns only the events that occured at/after this time.

end_time[]
optional, timestamp(UTC) in seconds

Returns only the events that occured at/before this time.

webhook_status[]
optional, enumerated string

Returns the events (occurred in the past 6 days) which has this status in any of the events' webhooks. Note: To retrieve events which have occurred before the 6 day period, use the occurred_at(start_time/end_time) attribute.

Possible values are
not_configured

Webhook was not configured when this event occurred

scheduled

Webhook call has been scheduled.

succeeded

Webhook call was successful.

re_scheduled

Webhook call has been rescheduled due failure(s) in previous call(s)

Show all values[+]
event_type[]
optional, enumerated string

Specify it if you need to fetch events of a particular type.

Possible values are
customer_created

Sent when a customer is created. This event happens when only a new customer is created or when a customer is automatically created during new subscription creation.

customer_changed

Sent when a customer is changed

customer_deleted

Sent when a customer is deleted

subscription_created

Sent when a new subscription is created.

Show all values[+]
event event
always returned
Resource object representing event
next_offset next_offset
optional, string, max chars=1000
This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter `offset`.

Sample admin console URL

https://{site}.chargebee.com/admin-console/events/123x

Retrieves a specific event identified by a unique event identifier.

Sample Request
curl  https://{site}.chargebee.com/api/v1/events/ev___test__5SK0bLNFRFuCIloNr \
     -u {site_api_key}:
copy
Click to Copy
200:
OK
STATUS

Sample Response [ JSON ]

Show more...
{
    "event": {
        "api_version": "v1",
        "content": {
            "customer": {
                "account_credits": 0,
                "allow_direct_debit": false,
                "auto_collection": "off",
                "card_status": "no_card",
                "created_at": 1517506760,
                "excess_payments": 0,
                "id": "__test__5SK0bLNFRFuCIkgNn",
                "object": "customer",
                "refundable_credits": 0,
                "taxability": "taxable"
            }
        },
        "event_type": "customer_created",
        "id": "ev___test__5SK0bLNFRFuCIloNr",
        "object": "event",
        "occurred_at": 1517506760,
        "source": "api",
        "user": "full_access_key_v1",
        "webhook_status": "scheduled"
    }
}

URL Format GET

https://{site}.chargebee.com/api/v1/events/{event-id}

Method

event event
always returned
Resource object representing event

Sample admin console URL

https://{site}.chargebee.com/admin-console/events/123x