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

# ChartMogul

> Empower your product teams with richer data from your warehouse to perform deeper analysis on subscription revenue and better understand business performance.

## Setup

To find your API keys, navigate to your profile and create a private API key.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-apikey-start.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=f7f0122c3f031b1e98eed55cfa2ccca9)

## Syncing

Hightouch supports syncing to the following ChartMogul Objects:

* `Customers`
* `Invoices`
* `Transactions`

### Sync modes

This integration supports **Upsert**, **Update**, and **Insert** modes for `Customers` objects and **Insert** mode for `Invoices` and `Transactions` objects.

* **Upsert**: Upsert mode pushes new objects to ChartMogul and updates fields that change in your warehouse.
* **Update**: Update mode updates particular fields on existing objects in ChartMogul.
* **Insert**: Insert mode pushes new objects to ChartMogul, and doesn't update the objects as they change in your warehouse.

## Record matching

### Customers

In **Upsert** mode, records can be matched from your source to ChartMogul by `External ID` or `Email`.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-customer-externalIdMapping-upsert.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=e1c0ce43bc8df97a1cd5f696cede64b3)

In **Update** mode, records can be matched from your source to ChartMogul by `External ID` or ChartMogul's `Customer UUID`.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-customer-externalIdMapping-update.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=05f789593879102cea7f80ef35f2ddba)

> [!NOTE]
>
> ChartMogul doesn't consider `Email` as a unique identifier, so upserting
> records will apply to all matching emails.

## Field mapping

### Customers

You can sync columns from your source to ChartMogul's default and custom attributes. When syncing with **Upsert** or **Insert** mode, `Data Source UUID`, `Name`, and `External ID`
(depending on if `External ID` was selected in the Record Matching section) are required fields in order for the sync to run successfully. When syncing with **Update** mode, `Name`
is a required field in order for the sync to run successfully. To know more about `Customer` fields, refer to the [ChartMogul docs](https://dev.chartmogul.com/reference/customers).

Additionally when syncing custom attributes with **Upsert** or **Insert** mode, Hightouch automatically transforms your data to match the required
format that ChartMogul expects for the `custom` field. For example, say you want to enrich a customer profile by inserting `age` as a custom attribute, where the object is:

```JSON theme={null}
{
    "attributes": {
        "custom": {
          "age": 25,
        },
    }
}
```

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-customer-customMapping-insert.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=85c70b76490923d0d2807de3fb884fd0)

Hightouch will automatically detect the `type` of the record value and transform the object for you to the expected `custom` field format:

```JSON theme={null}
{
    "attributes": {
        "custom": [
            {
              "type": Integer,
              "key": "age",
              "value": 25
            },
        ]
    }
}
```

### Invoices

You can sync columns from your source to ChartMogul's default and custom attributes. `Customer UUID`, `External ID`, `Date`, `Currency`, `Line Items`, and
`Customer External ID` are required fields in order for the sync to run successfully. To know more about `Invoice` fields, refer to the [ChartMogul docs](https://dev.chartmogul.com/reference/import-customers-invoices).

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-invoice-fieldMapping-upsert.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=7db2c81ec224e74341f8db5e95c94764)

### Transactions

You can sync columns from your source to ChartMogul's default and custom attributes. `Invoice UUID`, `Date`, `Type`, and `Result` are required fields in order
for the sync to run successfully. To know more about `Transaction` fields, refer to the [ChartMogul docs](https://dev.chartmogul.com/reference/import-invoice-transaction).

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-transaction-fieldMapping.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=dcb350e4ae0d1250f534c82a8efde2e6)

## Delete mode

### Customers

You can choose what Hightouch's behavior is when records leave the query result set. The default is doing nothing, but you can also set Hightouch to delete the `Customer` record.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-customer-delete.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=1185596dd4d6c4c49f1f025f83bc5d02)

> [!NOTE]
>
> ChartMogul doesn't allow custom attributes to be cleared, so Hightouch will
> sync `"null"` to the field instead.

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).

## Common errors

### write ECONNRESET

You may receive the `write ECONNRESET` error if the model columns used for [record matching](#record-matching) or [mapping](#field-mapping) don't have an associated [data type](https://docs.hightouch.com/models/data-types-casting.md#data-types) in Hightouch.

![Model data types in the Hightouch UI](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-chartmogul-no-data-type.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=34a25d063716b950974d1c2804c5d362)

To resolve the error, ensure that each model column has the data type ChartMogul expects.
Refer to the [data types and casting docs](https://docs.hightouch.com/models/data-types-casting.md) for more information.
