# Add contacts to a customer

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


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

Add a [contact](/docs/api/contacts) to a [customer](/docs/api/customers) resource.

### Prerequisites & Constraints

-   The customer must have fewer than 10 contacts already added.

### Impacts

**

Email notifications

**

-   If you set `contact[send_billing_email]` to `true`, the contact receives [billing emails](https://www.chargebee.com/docs/billing/2.0/customers/customers#billing-emails).
-   If you set `contact[send_account_email]` to `true`, the contact receives [account emails](https://www.chargebee.com/docs/billing/2.0/customers/customers#account-emails).

### Implementation Notes

Check the customer's [`contacts[]`](/docs/api/customers/customer-object#contacts) array and ensure it contains fewer than 10 contacts before calling this API.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWl5C82b2/add_contact \
     -u {site_api_key}:\
     -d "contact[first_name]"="Jane" \
     -d "contact[last_name]"="Doe" \
     -d "contact[email]"="jane@test.com" \
     -d "contact[label]"="dev" \
     -d "contact[enabled]"="true" \
     -d "contact[send_billing_email]"="true" \
     -d "contact[send_account_email]"="true"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.AddContact("__test__KyVnHhSBWl5C82b2")
		.ContactFirstName("Jane")
		.ContactLastName("Doe")
		.ContactEmail("jane@test.com")
		.ContactLabel("dev")
		.ContactEnabled(true)
		.ContactSendBillingEmail(true)
		.ContactSendAccountEmail(true)
		.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.AddContact("__test__KyVnHhSBWl5C82b2", &customer.AddContactRequestParams{
        Contact : &customer.AddContactContactParams{
            FirstName : "Jane",
            LastName : "Doe",
            Email : "jane@test.com",
            Label : "dev",
            Enabled : chargebee.Bool(true),
            SendBillingEmail : chargebee.Bool(true),
            SendAccountEmail : chargebee.Bool(true),
        },
    }).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.CustomerAddContactRequest{
    Contact : &chargebee.CustomerAddContactContact{
        FirstName : "Jane",
        LastName : "Doe",
        Email : "jane@test.com",
        Label : "dev",
        Enabled : chargebee.Bool(true),
        SendBillingEmail : chargebee.Bool(true),
        SendAccountEmail : chargebee.Bool(true),
    },
}
  res, err := client.Customer.AddContact("__test__KyVnHhSBWl5C82b2", 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.addContact("__test__KyVnHhSBWl5C82b2")
            .contactFirstName("Jane")
            .contactLastName("Doe")
            .contactEmail("jane@test.com")
            .contactLabel("dev")
            .contactEnabled(true)
            .contactSendBillingEmail(true)
            .contactSendAccountEmail(true)
            .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.CustomerAddContactParams;
import com.chargebee.v4.models.customer.responses.CustomerAddContactResponse;

public class CustomerAddContact {

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

        CustomerAddContactParams.ContactParams contactParams =
            CustomerAddContactParams.ContactParams.builder()
                .firstName("Jane")
                .lastName("Doe")
                .email("jane@test.com")
                .label("dev")
                .enabled(true)
                .sendBillingEmail(true)
                .sendAccountEmail(true)
                .build();

        CustomerAddContactParams params = CustomerAddContactParams.builder()
            .contact(contactParams)
            .build();

        CustomerAddContactResponse response = client
            .customers()
            .addContact("__test__KyVnHhSBWl5C82b2", 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.addContact("__test__KyVnHhSBWl5C82b2", {
        contact: {
            first_name: "Jane",
            last_name: "Doe",
            email: "jane@test.com",
            label: "dev",
            enabled: true,
            send_billing_email: true,
            send_account_email: true
        }
    });

    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()->addContact("__test__KyVnHhSBWl5C82b2", [
    "contact" => [
        "first_name" => "Jane",
        "last_name" => "Doe",
        "email" => "jane@test.com",
        "label" => "dev",
        "enabled" => true,
        "send_billing_email" => true,
        "send_account_email" => true
    ]
]);
$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.add_contact("__test__KyVnHhSBWl5C82b2",
    cb_client.Customer.AddContactParams(
        contact=cb_client.Customer.AddContactContactParams(
            first_name="Jane",
            last_name="Doe",
            email="jane@test.com",
            label="dev",
            enabled=True,
            send_billing_email=True,
            send_account_email=True
        )
    )
)
customer = response.customer
card = response.card
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Customer.add_contact("__test__KyVnHhSBWl5C82b2",{
  :contact => {
    :first_name => "Jane",
    :last_name => "Doe",
    :email => "jane@test.com",
    :label => "dev",
    :enabled => "true",
    :send_billing_email => "true",
    :send_account_email => "true"
  }
})

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

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "on",
    "card_status": "no_card",
    "contacts": [
      {
        "email": "jane@test.com",
        "enabled": true,
        "first_name": "Jane",
        "id": "contact___test__KyVnHhSBWl5Cy2b4",
        "label": "dev",
        "last_name": "Doe",
        "object": "contact",
        "send_account_email": true,
        "send_billing_email": true
      },
      {..}
    ],
    "created_at": 1517505721,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "John",
    "id": "__test__KyVnHhSBWl5C82b2",
    "last_name": "Doe",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505721000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505721
  }
}
```

## URL Format

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

## Input Parameters

- `contact` (optional, string)
  Parameters for contact
  - `id` (optional, string, max chars=150)
    Unique reference ID provided for the contact.
  - `first_name` (optional, string, max chars=150)
    First name of the contact.
  - `last_name` (optional, string, max chars=150)
    Last name of the contact.
  - `email` (required, string, max chars=70)
    Email of the contact.
  - `phone` (optional, string, max chars=50)
    Phone number of the contact.
  - `label` (optional, string, max chars=50)
    Label/Tag provided for contact.
  - `enabled` (optional, boolean, default=false)
    Contact enabled / disabled
  - `send_billing_email` (optional, boolean, default=false)
    Whether Billing Emails option is enabled for the contact.
  - `send_account_email` (optional, boolean, default=false)
    Whether Account Emails option is enabled for the contact.

## Returns

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

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