# Update a customer

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Updates the details of the specified [customer](/docs/api/customers).

Use this API to modify customer information, including standard attributes and any configured [custom attributes](/docs/api/advanced-features).

-   To update the billing address or VAT number, use the [Update billing info for a customer](/docs/api/customers/update-billing-info-for-a-customer) API instead.
-   The Account Hierarchy (Parent-Child Relationship) cannot be updated using this API.
    -   To add a child to a Parent Account, use the [Link a customer to an account](/docs/api/customers/link-a-customer) API.
    -   To remove a child from a Parent Account, use the [Unlink a customer from its parent account](/docs/api/customers/delink-a-customer) API.

### Impacts

**

Invoices

**

-   See [`auto_collection`](/docs/api/customers/update-a-customer#auto_collection) parameter to understand the impact on invoices.
-   See [`taxability`](/docs/api/customers/update-a-customer#taxability) parameter to understand how taxes on invoices are impacted.

**

CRM integrations

**

When you update customer details in Chargebee using this API, the corresponding records are synced with integrated CRM systems, such as [HubSpot](https://www.chargebee.com/docs/billing/2.0/integrations/hubspot) or [Salesforce](https://www.chargebee.com/docs/billing/2.0/integrations/chargebee-salesforce), depending on your integration configuration.

#### Related APIs

Update billing info for a customer

Link a customer to an account

Unlink a customer from its parent account

## Sample Request

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWlFGC2di \
     -u {site_api_key}:\
     -d first_name="Denise" \
     -d last_name="Barone" \
     -d locale="fr-CA"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.Update("__test__KyVnHhSBWlFGC2di")
		.FirstName("Denise")
		.LastName("Barone")
		.Locale("fr-CA")
		.Request();

Customer customer = result.Customer;
Card card = result.Card;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    customerAction "github.com/chargebee/chargebee-go/v3/actions/customer"
    "github.com/chargebee/chargebee-go/v3/models/customer"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := customerAction.Update("__test__KyVnHhSBWlFGC2di", &customer.UpdateRequestParams{
        FirstName : "Denise",
        LastName : "Barone",
        Locale : "fr-CA",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
        Card := res.Card
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CustomerUpdateRequest{
    FirstName : "Denise",
    LastName : "Barone",
    Locale : "fr-CA",
}
  res, err := client.Customer.Update("__test__KyVnHhSBWlFGC2di", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
        Card := res.Card
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Customer.update("__test__KyVnHhSBWlFGC2di")
            .firstName("Denise")
            .lastName("Barone")
            .locale("fr-CA")
            .request();

        Customer customer = result.customer();
        Card card = result.card();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.customer.params.CustomerUpdateParams;
import com.chargebee.v4.models.customer.responses.CustomerUpdateResponse;

public class CustomerUpdate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CustomerUpdateParams params = CustomerUpdateParams.builder()
            .firstName("Denise")
            .lastName("Barone")
            .locale("fr-CA")
            .build();

        CustomerUpdateResponse response = client
            .customers()
            .update("__test__KyVnHhSBWlFGC2di", params);

        Customer customer = response.getCustomer();
        Card card = response.getCard();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.customer.update("__test__KyVnHhSBWlFGC2di", {
        first_name: "Denise",
        last_name: "Barone",
        locale: "fr-CA"
    });

    console.log(result);
    const customer = result.customer;
    const card = result.card;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->customer()->update("__test__KyVnHhSBWlFGC2di", [
    "first_name" => "Denise",
    "last_name" => "Barone",
    "locale" => "fr-CA"
]);
$customer = $result->customer;
$card = $result->card;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Customer.update("__test__KyVnHhSBWlFGC2di",
    cb_client.Customer.UpdateParams(
        first_name="Denise",
        last_name="Barone",
        locale="fr-CA"
    )
)
customer = response.customer
card = response.card
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Customer.update("__test__KyVnHhSBWlFGC2di",{
  :first_name => "Denise",
  :last_name => "Barone",
  :locale => "fr-CA"
})

customer = result.customer
card = result.card
```

### Turn on auto-collection, enable direct debit payments, while disabling consolidated invoicing for a customer.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/customer_4 \
     -u {site_api_key}:\
     -d auto_collection="ON" \
     -d allow_direct_debit="true" \
     -d consolidated_invoicing="false"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;
using ChargeBee.Models.Enums;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.Update("customer_4")
		.AutoCollection(AutoCollectionEnum.On)
		.AllowDirectDebit(true)
		.ConsolidatedInvoicing(false)
		.Request();

Customer customer = result.Customer;
Card card = result.Card;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    customerAction "github.com/chargebee/chargebee-go/v3/actions/customer"
    "github.com/chargebee/chargebee-go/v3/models/customer"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := customerAction.Update("customer_4", &customer.UpdateRequestParams{
        AutoCollection : enum.AutoCollectionOn,
        AllowDirectDebit : chargebee.Bool(true),
        ConsolidatedInvoicing : chargebee.Bool(false),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
        Card := res.Card
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CustomerUpdateRequest{
    AutoCollection : chargebee.AutoCollectionOn,
    AllowDirectDebit : chargebee.Bool(true),
    ConsolidatedInvoicing : chargebee.Bool(false),
}
  res, err := client.Customer.Update("customer_4", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
        Card := res.Card
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Customer.update("customer_4")
            .autoCollection(AutoCollection.ON)
            .allowDirectDebit(true)
            .consolidatedInvoicing(false)
            .request();

        Customer customer = result.customer();
        Card card = result.card();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.customer.params.CustomerUpdateParams;
import com.chargebee.v4.models.customer.responses.CustomerUpdateResponse;

public class CustomerUpdate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CustomerUpdateParams params = CustomerUpdateParams.builder()
            .autoCollection(CustomerUpdateParams.AutoCollection.ON)
            .allowDirectDebit(true)
            .consolidatedInvoicing(false)
            .build();

        CustomerUpdateResponse response = client
            .customers()
            .update("customer_4", params);

        Customer customer = response.getCustomer();
        Card card = response.getCard();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.customer.update("customer_4", {
        auto_collection: "on",
        allow_direct_debit: true,
        consolidated_invoicing: false
    });

    console.log(result);
    const customer = result.customer;
    const card = result.card;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->customer()->update("customer_4", [
    "auto_collection" => "on",
    "allow_direct_debit" => true,
    "consolidated_invoicing" => false
]);
$customer = $result->customer;
$card = $result->card;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Customer.update("customer_4",
    cb_client.Customer.UpdateParams(
        auto_collection=chargebee.AutoCollection.ON,
        allow_direct_debit=True,
        consolidated_invoicing=False
    )
)
customer = response.customer
card = response.card
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Customer.update("customer_4",{
  :auto_collection => "ON",
  :allow_direct_debit => "true",
  :consolidated_invoicing => "false"
})

customer = result.customer
card = result.card
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "on",
    "card_status": "no_card",
    "created_at": 1517505760,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "Denise",
    "id": "__test__KyVnHhSBWlFGC2di",
    "last_name": "Barone",
    "locale": "fr-CA",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505760000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505760
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/customers/{customer-id}

## Input Parameters

- `first_name` (optional, string, max chars=150)
  First name of the customer.

- `last_name` (optional, string, max chars=150)
  Last name of the customer.

- `email` (optional, string, max chars=70)
  Email of the customer. Configured email notifications will be sent to this email.

- `preferred_currency_code` (optional, string, max chars=3)
  The currency code (ISO 4217 format) of the customer. Applicable if Multicurrency is enabled.

- `phone` (optional, string, max chars=50)
  Phone number of the customer.

- `company` (optional, string, max chars=250)
  Company name of the customer.

- `auto_collection` (optional, enumerated string, default=on)
  Determines whether payments should be collected automatically for this customer.
  
  **Note** This setting can be overridden at the [subscription level](/docs/api/subscriptions/update-subscription-for-items#auto_collection).
  Possible enum values:
    - `on`
      Payments are automatically collected for new invoices. For existing invoices, Chargebee attempts collections through [dunning](https://www.chargebee.com/docs/payments/2.0/dunning/dunning-v2) as per the configured schedule.
    - `off`
      Payments are not automatically collected for this customer.

- `allow_direct_debit` (optional, boolean, default=false)
  Whether the customer can pay via Direct Debit.

- `net_term_days` (optional, integer, default=0)
  The number of days from [`invoice.date`](/docs/api/invoices/invoice-object#date) until payment for the invoice is due.

- `taxability` (optional, enumerated string, default=taxable)
  Specifies whether taxes are applicable to invoices generated for this customer.
  Possible enum values:
    - `taxable`
      Taxes are calculated for this customer based on the [site's tax configuration](https://www.chargebee.com/docs/tax.html). In some regions, [shipping\_address](/docs/api/customers) is required for tax computation. If a shipping address is not provided, the [billing\_address](/docs/api/customers) is used. If neither address is available, no tax is applied.
    - `exempt`
      The customer is exempt from tax.
      
      -   If you use Chargebee [Taxes](https://www.chargebee.com/docs/tax.html) or the [TaxJar integration](https://www.chargebee.com/docs/taxjar.html), no additional action is required.
      -   If you use the [Avalara integration](https://www.chargebee.com/docs/avalara.html), optionally specify the `entity_code` or `exempt_number` attributes with [AvaTax for Sales](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption), or the `exemption_details` attribute with [AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html). Avalara may still apply tax depending on the values of `entity_code`, `exempt_number`, or `exemption_details`, and the jurisdiction (state, region, or province) of the taxable address.

- `exemption_details` (optional)
  Indicates the exemption information. You can customize customer exemption based on specific Location, Tax level (Federal, State, County and Local), Category of Tax or specific Tax Name. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration. To know more about what values you need to provide, refer to this [Avalara's API document](https://developer.avalara.com/communications/dev-guide_rest_v2/customizing-transactions/sample-transactions/exemption/) .

- `customer_type` (optional, enumerated string)
  Indicates the type of the customer. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
  Possible enum values:
    - `residential`
      When the purchase is made by a customer for home use
    - `business`
      When the purchase is made at a place of business
    - `senior_citizen`
      When the purchase is made by a customer who meets the jurisdiction requirements to be considered a senior citizen and qualifies for senior citizen tax breaks
    - `industrial`
      When the purchase is made by an industrial business

- `client_profile_id` (optional, string, max chars=50)
  Indicates the Client profile id for the customer. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.

- `taxjar_exemption_category` (optional, enumerated string)
  Indicates the exemption type of the customer. This is applicable only if you use Chargebee's TaxJar integration.
  Possible enum values:
    - `wholesale`
      Whole-sale
    - `government`
      Government
    - `other`
      Other

- `locale` (optional, string, max chars=50)
  Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.

- `entity_code` (optional, enumerated string)
  The exemption category of the customer, for USA and Canada. Applicable if you use Chargebee's [AvaTax for Sales integration](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption) .
  Possible enum values:
    - `a`
      Federal government
    - `b`
      State government
    - `c`
      Tribe/Status Indian/Indian Band
    - `d`
      Foreign diplomat
    - `e`
      Charitable or benevolent organization
    - `f`
      Religious organization
    - `g`
      Resale
    - `h`
      Commercial agricultural production
    - `i`
      Industrial production/manufacturer
    - `j`
      Direct pay permit
    - `k`
      Direct mail
    - `l`
      Other or custom
    - `m`
      Educational organization
    - `n`
      Local government
    - `p`
      Commercial aquaculture
    - `q`
      Commercial Fishery
    - `r`
      Non-resident
    - `med1`
      US Medical Device Excise Tax with exempt sales tax
    - `med2`
      US Medical Device Excise Tax with taxable sales tax

- `exempt_number` (optional, string, max chars=100)
  Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable if you use Chargebee's [AvaTax for Sales integration](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption) .

- `offline_payment_method` (optional, enumerated string)
  The preferred offline payment method for the customer.
  Possible enum values:
    - `no_preference`
      No Preference
    - `cash`
      Cash
    - `check`
      Check
    - `bank_transfer`
      Bank Transfer
    - `ach_credit`
      ACH Credit
    - `sepa_credit`
      SEPA Credit
    - `boleto`
      Boleto
    - `us_automated_bank_transfer`
      US Automated Bank Transfer
    - `eu_automated_bank_transfer`
      EU Automated Bank Transfer
    - `uk_automated_bank_transfer`
      UK Automated Bank Transfer
    - `jp_automated_bank_transfer`
      JP Automated Bank Transfer
    - `mx_automated_bank_transfer`
      MX Automated Bank Transfer
    - `custom`
      Custom

- `invoice_notes` (optional, string, max chars=2000)
  A customer-facing note added to all invoices associated with this API resource. This note becomes one among [all the notes](/docs/api/invoices/invoice-object#notes) displayed on the invoice PDF.

- `auto_close_invoices` (optional, boolean)
  Override for this customer, the [site-level setting](https://www.chargebee.com/docs/billing/2.0/usage-based-billing/metered_billing#configuring-metered-billing) for auto-closing invoices. Only applicable when auto-closing invoices has been enabled for the site. This attribute is also available at the [subscription level](/docs/api/subscriptions/subscription-object#auto_close_invoices) which takes precedence.

- `meta_data` (optional, jsonobject)
  A collection of key-value pairs that provides extra information about the customer.
  
  **Note:** There's a character limit of 65,535.
  
  [Learn more](/docs/api/advanced-features) .

- `fraud_flag` (optional, enumerated string)
  Indicates whether or not the customer has been identified as fraudulent.
  Possible enum values:
    - `safe`
      The customer has been marked as safe
    - `fraudulent`
      The customer has been marked as fraudulent

- `consolidated_invoicing` (optional, boolean)
  Indicates whether invoices raised on the same day for the `customer` are consolidated. When provided, this overrides the default configuration at the [site-level](https://www.chargebee.com/docs/consolidated-invoicing.html#configuring-consolidated-invoicing). This parameter can be provided only when [Consolidated Invoicing](https://www.chargebee.com/docs/consolidated-invoicing.html) is enabled.
  
  **Note:**
  
  Any invoices raised when a subscription activates from `in_trial` or `future` `status`, are not consolidated by default. [Contact Support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=support) to enable consolidation for such invoices.
  
  .

- `tax_providers_fields` (optional, array)
  Parameters for tax\_providers\_fields
  - `provider_name` (optional, string, max chars=50)
    Name of the tax provider.
  - `field_id` (optional, string, max chars=50)
    Field id of the attribute which tax vendor has provided while getting onboarded with Chargebee.
  - `field_value` (optional, string, max chars=50)
    The value of the related tax field

## Returns

- `customer` (Customer object)
  Resource object representing customer

- `card` (Card object)
  Resource object representing card
