ChargebeeAPI

Create a customer

Idempotency Supported
Try in API Explorer

Creates a customer resource. Optionally, creates a payment source for the customer.

Creating payment source

Although this operation supports creation of a customer with a payment source, it is recommended to use one of the Payment Source APIs to capture payment source details instead of using this operation. This way, even if payment source creation fails due to errors at the payment gateway, the customer resource can still be created successfully.

Impacts

Customer

  • If the multi-business entity feature is enabled, the customer is linked to the business entity specified; otherwise, the customer record is linked to the default business entity defined for the site.

Invoices

  • Chargebee uses the billing_address object from the customer to set the values in the billing_address of the invoices generated for the customer.
  • If the billing_address object does not include the first_name, last_name, or company fields, Chargebee automatically uses the values from customer.first_name, customer.last_name, and customer.company (if available) when generating invoices.

Payment source

  • If payment_intent or payment_method parameter is passed, a payment_source resource of the appropriate type is created for the customer.
  • If bank_account parameter is passed, a payment_source resource of type direct_debit is created for the customer.
  • If card parameter is passed, a payment_source resource of type card is created for the customer.
Integrations
  • If CRM systems are connected to Chargebee, a corresponding record is created in the connected CRM (such as Salesforce, and HubSpot).

Use Cases

Create payment source using payment_intent

Use the payment_intent parameter to create a payment source for the customer.

Note

This works for both Strong Customer Authentication (SCA) (i.e. 3D-Secure) and non-SCA flows.

  1. Create a payment_intent resource by calling the Create a payment intent API.
  2. Pass the payment_intent object to your frontend and use Chargebee.js to capture the payment source details from the customer. You can use Payment Components to capture the payment source details.
  3. Listen to the payment_intent_updated event. Once the payment_intent.status is authorized, pass the payment_intent.id using the payment_intent[id] parameter in this API call.

Create payment source using payment_method

If you prefer to use the payment gateway's SDKs to capture the payment method details, you can then use the payment_method parameter in this API to pass the payment method token and other details.

  1. Use the JavaScript library of your payment gateway to capture the payment method details. Examples include:
  1. Pass the payment method token using the payment_method[reference_id] or payment_method[tmp_token] parameter along with any additional parameters required by the payment gateway to create the payment source.

Create payment source using bank_account

You can pass raw bank account details via this API. Use the bank_account parameter to pass the bank account details.

Create payment source using card

If you are PCI compliant, you can pass raw card details via this API. Use the card parameter to pass the card details.

Sample Request

URL Format

POST https://[site].chargebee.com/api/v2/customers

Input Parameters

id
optional, string, max chars=50

Id for the new customer. If not given, this will be auto-generated.

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 address of the customer. Configured email notifications are sent to this email address. Invalid email address will result in an error.

preferred_currency_code
optional, string, max chars=3

The currency code (in ISO 4217 format) of the customer.

Prerequisites

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

Whether payments needs to be collected automatically for this customer.

Constraints

  • offline_payment_method cannot be passed when auto_collection is set to on.
Possible Enum Values
on

Whenever an invoice is created, an automatic attempt to charge the customer's payment method is made.

off

Automatic collection of charges will not be made. All payments must be recorded offline.

net_term_days
optional, integer, default=0

The number of days within which the customer has to make payment for the invoice.

allow_direct_debit
optional, boolean, default=false

Whether the customer can pay via Direct Debit.

vat_number
optional, string, max chars=20

The VAT/tax registration number for the customer. For customers with billing_address

country as XI (which is United Kingdom - Northern Ireland ), the first two characters of the full VAT number can be overridden by setting vat_number_prefix .

vat_number_prefix
optional, string, max chars=10

An overridden value for the first two characters of the full VAT number. Only applicable specifically for customers with billing_address

country as XI (which is United Kingdom - Northern Ireland ).

When you have enabled EU VAT in 2021 or have manually enabled the Brexit configuration, you have the option of setting billing_address

country as XI. That's the code for United Kingdom - Northern Ireland. The first two characters of the VAT number in such a case is XI by default. However, if the VAT number was registered in UK, the value should be GB. Set vat_number_prefix to GB for such cases.

entity_identifier_scheme
optional, string, max chars=50

The Peppol BIS scheme associated with the vat_number of the customer. This helps identify the specific type of customer entity. For example, DE:VAT is used for a German business entity while DE:LWID45 is used for a German government entity. The value must be from the list of possible values and must correspond to the country provided under billing_address.country. See list of possible values .

Tip:

If there are additional entity identifiers for the customer not associated with the vat_number, they can be provided as the entity_identifiers[] array.

entity_identifier_standard
optional, string, default=iso6523-actorid-upis, max chars=50

The standard used for specifying the entity_identifier_scheme. Currently only iso6523-actorid-upis is supported and is used by default when not provided.

Tip:

If there are additional entity identifiers for the customer not associated with the vat_number, they can be provided as the entity_identifiers[] array.

registered_for_gst
optional, boolean

Confirms that a customer is registered under GST. If set to true then the Reverse Charge Mechanism is applicable. This field is applicable only when Australian GST is configured for your site.

is_einvoice_enabled
optional, boolean

Determines whether the customer is e-invoiced. When set to true or not set to any value, the customer is e-invoiced so long as e-invoicing is enabled for their country (billing_address.country ). When set to false , the customer is not e-invoiced even if e-invoicing is enabled for their country.

Tip:

It is possible to set a value for this flag even when E-Invoicing is disabled. However, it comes into effect only when E-Invoicing is enabled.

einvoicing_method
optional, enumerated string

Determines whether to send an e-invoice manually or automatic.

Possible Enum Values
automatic

Use this value to send e-invoice every time an invoice or credit note is created.

manual

When manual is selected the automatic e-invoice sending is disabled. Use this value to send e-invoice manually through UI or API.

site_default

The default value of the site which can be overridden at the customer level.

taxability
optional, enumerated string, default=taxable

Specifies if the customer is liable for tax.

Possible Enum Values
taxable

Computes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that's not available either, the tax is taken as zero.

exempt
  • Customer is exempted from tax. When using Chargebee's native Taxes feature or when using the TaxJar integration, no other action is needed.
  • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee's AvaTax for Sales or specify exemption_details attribute if you use Chargebee's AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
exemption_details
optional, jsonarray

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 integration. To know more about what values you need to provide, refer to this Avalara's API document .

customer_type
optional, enumerated string

Indicates the type of the customer. This is applicable only if you use Chargebee's AvaTax for Communications 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 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

business_customer_without_vat_number
optional, boolean

Confirms that a customer is a valid business without an EU/UK VAT number.

locale
optional, string, max chars=50

Determines which region-specific language Chargebee uses to communicate with the customer. Use the language pack to customize the translations for each locale.

Constraints

Prerequisite

Default behavior

  • If you don't pass locale, or if you pass it but it is not added and activated in Chargebee, then the primary language for customers would be used.
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 .

Possible Enum Values
a

Federal government

b

State government

c

Tribe/Status Indian/Indian Band

d

Foreign diplomat

e

Charitable or benevolent organization

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 .

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 .

offline_payment_method
optional, enumerated string

The preferred offline payment method for the customer.

Constraints

Prerequisites

Possible Enum Values
no_preference

No Preference

cash

Cash

check

Check

bank_transfer

Bank Transfer

ach_credit

ACH Credit

auto_close_invoices
optional, boolean

Override for this customer, the site-level setting 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 which takes precedence.

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. This parameter can be provided only when Consolidated Invoicing is enabled.

Note:

Any invoices raised when a subscription activates from in_trial or future status, are not consolidated by default. Contact Support to enable consolidation for such invoices.

.

token_id
optional, string, max chars=40

The Chargebee payment token generated by Chargebee JS.

Note: The payment token created via Chargebee JS uses the gateway selected through Smart Routing. Explicitly passing a gateway_id in this API call will not override the gateway associated with the token.

business_entity_id
optional, string, max chars=50

The unique ID of the business entity this customer should be linked to. An alternative way of passing this parameter is by means of a custom HTTP header.

Prerequisites

  • Multiple business entities have been created for the site.

Default behavior

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 displayed on the invoice PDF.

card
optional, string

Parameters for card. Use this parameter to pass raw card details.

Passing raw card data via API involves PCI liability at your end due to the sensitivity of the data.

bank_account
optional, string

Parameters for bank_account

payment_method
optional, enumerated string

Parameters for payment_method

payment_intent
optional, string

Parameters for payment_intent

billing_address
optional, string

Parameters for billing_address

entity_identifiers
optional, string

Parameters for entity_identifiers

tax_providers_fields
optional, string

Parameters for tax_providers_fields

Returns

customerCustomer object

Resource object representing customer

cardCard object

Resource object representing card