> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cello.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Chargebee Webhook

> Send signup and purchase events to Cello using Chargebee Webhook

Cello makes it easy to **connect securely to your Chargebee payment provider** to automate transaction events, attribution, and payouts. Transactions are monitored and used to pay out referrers based on your campaign reward rules.

# Overview

A notification event is securely sent to Cello through the webhook endpoint every time a customer makes a purchase or a customer record is created or updated. Cello checks these events to perform the following actions:

* Determine if a reward for the referrer needs to be created and paid out
* Inform the referrer about new signups and rewards
* Cancel recurring rewards if a subscription is cancelled

<Warning>
  If the automation of Cello detects unclear cases the automation will be paused and Cello will reach out to you to clarify the case.
</Warning>

<Tip>
  After setting up the webhook, check [Integration Status](/guides/support/portal/integration-status) in the Cello Portal to confirm Cello is receiving events from Chargebee. If a component shows a warning or error, open the [Event Feed](https://portal.cello.so/integrations/events-feed) to drill into individual events and see which fields are failing validation.
</Tip>

# Endpoint URLs

You will find the webhook endpoint URL for both **Sandbox** and **Production** environments in the [Cello Portal Webhooks page](https://portal.cello.so/integrations/webhooks).

# Securing the webhook

To secure the webhook in Step 5, you will find credentials for both **Sandbox** and **Production** environments in [Cello Portal Webhooks page](https://portal.cello.so/integrations/webhooks).

# Connecting Chargebee

## Prerequisites

Before configuring webhooks, ensure your Chargebee customers include the required Cello attribution fields. These information enables proper attribution and reward tracking.

<Note>
  **When to add additional fields:**

  * If you create Chargebee customers at signup → You would have already added metadata or custom fields to the customer during the [Setup Step "Track Signups"](/attribution/tracking-signups)
  * If you create Chargebee customers at purchase → Make sure to add metadata or custom fields when creating the customer
</Note>

### Required Chargebee Customer attribution fields

<Note>
  You can also choose to use **Chargebee custom fields (CF\_)** to add referral data to the event. Learn more about custom fields in the [**Chargebee documentation**](https://www.chargebee.com/docs/billing/2.0/site-configuration/custom_fields)
</Note>

Pass the following fields during checkout in the [Customer Object](https://apidocs.chargebee.com/docs/api/customers) to `meta_data` attribute or as a `cf_` custom field.

| Field                      | Description                                                                                                                               | Chargebee Object                                                                                                        |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `cello_ucc`                | Referral code identifying the referrer                                                                                                    | [Customer Object](https://apidocs.chargebee.com/docs/api/customers) to `meta_data` attribute or as a `cf_` custom field |
| `new_user_id`              | Your system's unique user ID. Same as `productUserId` used in [Referral Component](/referral-component/introduction) when booting the SDK | [Customer Object](https://apidocs.chargebee.com/docs/api/customers) to `meta_data` attribute or as a `cf_` custom field |
| `new_user_organization_id` | Organization ID (optional). Required only for organization-level referrals and rewards                                                    | [Customer Object](https://apidocs.chargebee.com/docs/api/customers) to `meta_data` attribute or as a `cf_` custom field |
| `coupon`                   | New user discount code. Learn how to apply discounts in this [guide](/attribution/apply-discounts).                                       | [Customer Object](https://apidocs.chargebee.com/docs/api/customers) to `meta_data` attribute or as a `cf_` custom field |

## Steps

You will add a webhook to your Chargebee configuration to connect Chargebee and Cello. This can be done in both test and production environments separately.

<img src="https://mintcdn.com/cello/6Zr08teY9AER0ncF/integrations/webhooks/integrations-chargebee-webhook-1.png?fit=max&auto=format&n=6Zr08teY9AER0ncF&q=85&s=5145a0ff810ec3c0b2433c927380fb6d" alt="Chargebee webhook configuration in Cello Portal" width="1100" height="1173" data-path="integrations/webhooks/integrations-chargebee-webhook-1.png" />

<Steps>
  <Step title="Log into your Chargebee Dashboard" />

  <Step title="Add a new Webhook" stepNumber={2}>
    From the sidebar, select Settings > Configure Chargebee and click on "Webhooks". Next Click on "+ Add Webhook".
  </Step>

  <Step title="Enter the Endpoint URL" stepNumber={3}>
    Choose the Endpoint URL corresponding to the environment you are setting up: **Sandbox** or **Production**.
  </Step>

  <Step title="Select the events to send" stepNumber={4}>
    Select the events you want to send under "Events to Send":

    1. `Customer Created`, `Customer Changed`, `Customer Deleted`
    2. `Payment Succeeded`, `Payment Refunded`, `Payment Failed`
  </Step>

  <Step title="Secure the webhook">
    Select "Protect webhook URL with basic authentication" and add the `product_id` and `secret` provided in the Cello Portal.

    <Warning>
      Be sure to select **Exclude card Information from webhook call**
    </Warning>
  </Step>

  <Step title="Click &#x22;Create&#x22; to enable the webhook">
    <Icon icon="check" color="#027A48" />  Webhook created!
  </Step>
</Steps>
