Merge Customers

Accepts details of two customer objects that you want to merge.

Examples
# Example using Customer UUIDs for identifying customers to merge

curl -X POST "https://api.chartmogul.com/v1/customers/merges" \
       -u YOUR_API_KEY: \
       -H "Content-Type: application/json" \
       -d '{
             "from": {"customer_uuid": "cus_5915ee5a-babd-406b-b8ce-d207133fb4cb"},
             "into": {"customer_uuid": "cus_2123290f-09c8-4628-a205-db5596bd58f7"}
           }'
           
# Example using Data Source UUIDs and External IDs for identifying customers to merge

curl -X POST "https://api.chartmogul.com/v1/customers/merges" \
       -u YOUR_API_KEY: \
       -H "Content-Type: application/json" \
       -d {
             "from": {"data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
                      "external_id": "cus_187544"},
             "into": {"data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
                      "external_id": "34916129"}
           }
# Example using Customer UUIDs

from_customer = ChartMogul::Customer.retrieve('cus_5915ee5a-babd-406b-b8ce-d207133fb4cb')
into_customer = ChartMogul::Customer.retrieve('cus_2123290f-09c8-4628-a205-db5596bd58f7')

from_customer.merge_into!(into_customer)
// Example using Customer UUIDs
ChartMogul.Customer.merge(config, {
  "from": {"customer_uuid": "cus_5915ee5a-babd-406b-b8ce-d207133fb4cb"},
  "into": {"customer_uuid": "cus_2123290f-09c8-4628-a205-db5596bd58f7"}
})
<?php

// Example using Customer UUIDs
ChartMogul\Customer::merge([
    "customer_uuid" => "cus_5915ee5a-babd-406b-b8ce-d207133fb4cb"
        ], [
    "customer_uuid" => "cus_2123290f-09c8-4628-a205-db5596bd58f7"
]);
?>
// Example using Customer UUIDs
api.MergeCustomers(&cm.MergeCustomersParams{
  From: cm.CustID{CustomerUUID: "cus_5915ee5a-babd-406b-b8ce-d207133fb4cb"},
  Into:   cm.CustID{CustomerUUID: "cus_2123290f-09c8-4628-a205-db5596bd58f7"},
})
# Example using Customer UUIDs
chartmogul.Customer.merge(config, data={
    "from": {
        "customer_uuid": "cus_5915ee5a-babd-406b-b8ce-d207133fb4cb"
    },
    "into": {
        "customer_uuid": "cus_2123290f-09c8-4628-a205-db5596bd58f7"
    }
})
Result Format
{ }
true
{ }
true
None
<Customer{}>

Once a valid request is received by the API, it will respond with 202 - Accepted, and the merging function will proceed to work asynchronously.

📘

Automatic merging of duplicate customers

ChartMogul allows you to create an automation to merge duplicate customers based on their external ID, domain (website URL), or company name. Learn more.
For accounts created on or after May 21, 2024, this automation is enabled by default. ChartMogul automatically merges customers with matching external IDs or domains.

📘

Merged customers

When customers are merged, two or more data source customer objects become the children of one customer object. Data associated with each data source customer, such as invoices and transactions, remains in the source where it was originally added. Learn more.

The merged customer will have the ChartMogul Customer UUID, email address, and location of the customer identified using the into key. Both customers’ external IDs, tags, custom attributes, and notes will be preserved. Subscriptions, MRR movements, and transactions will be collated and ordered by date. If both customers have the same custom attribute with different values, the value retained for the field will be that of the customer specified in into.

You can see the merged customer reported in your ChartMogul account.

For uploading Invoices to the merged customer, additional data (data_source_uuid and customer_external_id) needs to be provided in the invoice object. Details of the implementation can be found in Import Invoices section of the documentation.

Language
Authorization
Basic
base64
: