# Chargebee

Teleskope integrates with Chargebee’s API to fulfill **Delete User** DSRs by clearing personal data on the customer record.

## Requirements

In order to integrate Teleskope with Chargebee for DSR requests, you must have:

* Your **Chargebee Site Name** (subdomain)
  * The default API base is `https://<site-name>.chargebee.com/api/v2`.
* Your **Chargebee API key** (used for Basic Auth).
* *(Optional)* **API URL override**
  * If you use a non-standard or regional base URL, provide it here. Otherwise Teleskope constructs `https://<site-name>.chargebee.com/api/v2` automatically.
* The user’s **email address** as the identifier (used to look up the customer).

### Integrating with Chargebee

To integrate Teleskope with Chargebee

1. Navigate to **Data Subject Rights → Third Party Integrations** and pick **Chargebee**.
2. Enter the required fields for the integration and click **Save**:
   * **API Key** (required)
   * **Site Name** (required)
   * **API URL** (optional; leave blank to use `https://<site>.chargebee.com/api/v2`)

### Parameter Defaults

* When Teleskope sends a **Delete User** request to Chargebee, it performs these steps by default:
  * **Lookup by email**:\
    `GET /customers?email[is]={email}`
  * If a match is found, **clear personal data** on the first customer returned:\
    `POST /customers/{customerId}/clear_personal_data`
  * **Authentication & headers**:
    * `Authorization`: Basic Auth (API key as username, empty password)
    * `Accept`: `application/json`
    * `Content-Type`: `application/x-www-form-urlencoded`
  * **Expected success codes**: `200` or `204`
* **Default Identifier for Chargebee = `email`**\
  (The handler uses the user’s email to find the customer ID.)

### Behavior and Notes

* If multiple customers are returned for the email lookup, the **first** one in the list is used.
* If **no customer** is found for the provided email, the request fails with an error.
* On success, Teleskope logs the operation and returns a standard “vendor deletion request submitted” message.

#### Helpful Links

[Chargebee: How to delete the personal data of my customers](https://www.chargebee.com/docs/billing/2.0/kb/billing/how-to-delete-the-personal-data-of-my-customers)

[Chargebee API docs](https://apidocs.chargebee.com/docs/api/customers)
