POST /subscriptions

Note: This operation optionally supports 3DS verification flow. To achieve the same, create the Payment Intent and pass it as input parameter to this API.

Creates a new subscription along with the customer. You can attach a plan, plan quantity, one or more addons and coupon while creating this subscription.

Future Subscriptions

If the start_date is specified, the subscription will be created in 'future' state (.ie, instead of starting immediately it will be scheduled to start at the specified 'start_date'). Besides if 'trial' is specified (plan configuration or specified explicitly using trial_end), the subscription will go into 'trial' state when it starts. Otherwise it will directly become 'active' when it starts.

Trial Period

If the plan has trial period or if the trial_end is specified explicitly, the subscription will be created in 'in_trial' state.

If the card details are passed, it is not charged until the end of the trial period. Incase you need to verify the card you could enable the 'card verification option' in the gateway settings.

Invoice

If the plan does not have a trial period and if any of the recurring items has charges, then a invoice would be raised immediately. If 'auto_collection' is turned 'on', then card attributes are mandatory and subscription will be created only if the payment was successful.

Card details

Passing card details to this API involves PCI liability at your end as sensitive card information passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable

You can also use our Hosted Pages based integration.

Billing Address

Note: For the sites created before 1st Mar 2014, customer's billing address and 'vat_number' will be replaced automatically whenever the associated card gets updated. i.e existing values for billing address and 'vat_number' will be cleared and the new values will be set. This behaviour is changed now - The VAT number should always be passed along billing address and not with card address. Both the addresses have to be dealt separately.

Billing Address attributes shall be explicitly passed for customers paying offline(Cash, Check, Bank Transfer etc).

Shipping Address

The Shipping Address is significant for the Customized Tax option, because tax calculations will be based on this address. For customers without Shipping Address, Billing Address details will be used to calculate taxes. If neither of the addresses are available for a customer, taxes will not be calculated for him/her.

Related Tutorials

Servers

Request headers

Name Type Required Description
chargebee-request-origin-device String No

The device from which the customer has made the request

Content-Type String Yes The media type of the request body.

Default value: "application/x-www-form-urlencoded"

chargebee-event-webhook String No

skip only webhooks

Possible values:

  • "all-disabled"
chargebee-event-actions String No

skip all actions to be done on the events

Possible values:

  • "all-disabled"
chargebee-request-origin-user String No

The email address of your customer/user. Use this when the email address has only ASCII characters.

chargebee-request-origin-ip String No

The IP address of the customer where the request originated

chargebee-request-origin-user-encoded String No

The Base64-encoded email address of your customer/user. Use this if the email address has UTF-8 characters. When this header is provided, the header chargebee-request-origin-user is ignored.

chargebee-event-email String No

skip only emails

Possible values:

  • "all-disabled"

Request body fields

Name Type Required Description
shipping_address Object No

Parameters for shipping_address

shipping_address.first_name String No

The first name of the contact.

shipping_address.state String No

The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.

shipping_address.city String No

The name of the city.

shipping_address.line2 String No

Address line 2

shipping_address.line1 String No

Address line 1

shipping_address.email String No

The email address.

shipping_address.last_name String No

The last name of the contact.

shipping_address.company String No

The company name.

shipping_address.line3 String No

Address line 3

shipping_address.state_code String No

The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).

shipping_address.zip String No

Zip or postal code. The number of characters is validated according to the rules specified here.

shipping_address.phone String No

The phone number.

shipping_address.country String No

The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note : If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom -- Northern Ireland) is available as an option.

created_from_ip String No

The IP address of the user. Used primarly in Refersion integration. Refersion uses this field to track/log affiliate subscription.

po_number String No

Purchase order number for this subscription.

meta_data Object No

A set of key-value pairs stored as additional information for the subscription. [Learn more](./#meta_data).

payment_intent Object No

Parameters for payment_intent

payment_intent.id String No

Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.

payment_intent.gateway_account_id String No

The gateway account used for performing the 3DS flow.

payment_intent.gw_token String No

Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer 3DS implementation in Chargebee to find out the gateway-specific gw_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.

payment_intent.reference_id String No

Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.

plan_id String Yes

Identifier of the plan for this subscription.

invoice_notes String No

A customer-facing note added to all invoices associated with this subscription. This note is one among all the notes displayed on the invoice PDF.

card Object No

Parameters for card

card.billing_addr2 String No

Address line 2, as available in card billing address.

card.billing_addr1 String No

Address line 1, as available in card billing address.

card.gateway String No

Name of the gateway this payment source is stored with. * braintree - Braintree is a payment gateway. * pin - Pin is a payment gateway * authorize_net - Authorize.net is a payment gateway * nmi - NMI is a payment gateway. * not_applicable - Indicates that payment gateway is not applicable for this resource. * eway_rapid - eWAY Rapid is a payment gateway. * beanstream - Bambora(formerly known as Beanstream) is a payment gateway. * tco - 2Checkout is a payment gateway. * bluepay - BluePay is a payment gateway. * paypal_payflow_pro - PayPal Payflow Pro is a payment gateway. * paypal_pro - PayPal Pro Account is a payment gateway. * stripe - Stripe is a payment gateway. * sage_pay - Sage Pay is a payment gateway. * wirecard - WireCard Account is a payment service provider. * balanced_payments - Balanced is a payment gateway * migs - MasterCard Internet Gateway Service payment gateway. * paymill - PAYMILL is a payment gateway. * first_data_global - First Data Global Gateway Virtual Terminal Account * ogone - Ingenico ePayments (formerly known as Ogone) is a payment gateway. * chargebee - Chargebee test gateway. * worldpay - WorldPay is a payment gateway * hdfc - HDFC Account is a payment gateway. * elavon - Elavon Virtual Merchant is a payment solution. * eway - eWAY Account is a payment gateway.

Possible values:

  • "balanced_payments"
  • "first_data_global"
  • "paymill"
  • "bluepay"
  • "paypal_payflow_pro"
  • "wirecard"
  • "nmi"
  • "hdfc"
  • "ogone"
  • "stripe"
  • "migs"
  • "eway_rapid"
  • "worldpay"
  • "sage_pay"
  • "beanstream"
  • "tco"
  • "paypal_pro"
  • "braintree"
  • "elavon"
  • "chargebee"
  • "pin"
  • "eway"
  • "authorize_net"
card.number String No

The credit card number without any format. If you are using Braintree.js, you can specify the Braintree encrypted card number here.

card.ip_address String No

The IP address of the customer. Used primarily for referral integration and EU VAT validation.

card.first_name String No

Cardholder's first name

card.tmp_token String No

The single-use card token returned by vaults like Stripe/Braintree which act as a substitute for your card details. Before calling this API, you should have submitted your card details to the gateway and gotten this token in return.
Note: Supported only for Stripe, Braintree and Authorize.Net. If this value is specified, there is no need to specify other card details (like number, cvv, etc).

card.expiry_month Integer No

Card expiry month.

card.last_name String No

Cardholder's last name

card.billing_state_code String No

The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).

card.billing_zip String No

Postal or Zip code, as available in card billing address.

card.expiry_year Integer No

Card expiry year.

card.cvv String No

The card verification value (CVV). If you are using Braintree.js, you can specify the Braintree encrypted CVV here.

card.billing_city String No

City, as available in card billing address.

card.billing_state String No

The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.

card.billing_country String No

The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note : If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom -- Northern Ireland) is available as an option.

payment_method Object No

Parameters for payment_method

payment_method.gateway String No

Name of the gateway the payment method is associated with. * chargebee - Chargebee test gateway. * stripe - Stripe is a payment gateway. * eway - eWAY Account is a payment gateway. * authorize_net - Authorize.net is a payment gateway * paypal_payflow_pro - PayPal Payflow Pro is a payment gateway. * sage_pay - Sage Pay is a payment gateway. * wirecard - WireCard Account is a payment service provider. * worldpay - WorldPay is a payment gateway * pin - Pin is a payment gateway * migs - MasterCard Internet Gateway Service payment gateway. * beanstream - Bambora(formerly known as Beanstream) is a payment gateway. * elavon - Elavon Virtual Merchant is a payment solution. * braintree - Braintree is a payment gateway. * nmi - NMI is a payment gateway. * first_data_global - First Data Global Gateway Virtual Terminal Account * bluepay - BluePay is a payment gateway. * paymill - PAYMILL is a payment gateway. * paypal_pro - PayPal Pro Account is a payment gateway. * eway_rapid - eWAY Rapid is a payment gateway. * ogone - Ingenico ePayments (formerly known as Ogone) is a payment gateway. * not_applicable - Indicates that payment gateway is not applicable for this resource. * tco - 2Checkout is a payment gateway. * hdfc - HDFC Account is a payment gateway. * balanced_payments - Balanced is a payment gateway

Possible values:

  • "balanced_payments"
  • "first_data_global"
  • "paymill"
  • "bluepay"
  • "paypal_payflow_pro"
  • "wirecard"
  • "nmi"
  • "hdfc"
  • "ogone"
  • "stripe"
  • "migs"
  • "eway_rapid"
  • "worldpay"
  • "sage_pay"
  • "beanstream"
  • "tco"
  • "paypal_pro"
  • "braintree"
  • "elavon"
  • "pin"
  • "eway"
  • "authorize_net"
payment_method.type String No

The type of payment method. For more details refer Update payment method for a customer API under Customer resource. * paypal_express_checkout - Payments made via PayPal Express Checkout. * direct_debit - Represents bank account for which the direct debit or ACH agreement/mandate is created. * automated_bank_transfer - Represents virtual bank account using which the payment will be done. * amazon_payments - Payments made via Amazon Payments. * card - Card based payment including credit cards and debit cards. Details about the card can be obtained from the card resource.

Possible values:

  • "amazon_payments"
  • "card"
  • "direct_debit"
  • "automated_bank_transfer"
  • "paypal_express_checkout"
payment_method.reference_id String No

The reference id. In the case of Amazon and Paypal this will be the billing agreement id . In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one time temporary token provided by gateways like Stripe.
For more details refer Update payment method for a customer API under Customer resource.

billing_cycles Integer No

Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.

id String No

A unique and immutable identifier for the subscription. If not provided, it is autogenerated.

affiliate_token String No

A unique tracking token.

customer Object No

Parameters for customer

customer.id String No

The unique ID of the customer for which this hosted_page should be created. When not provided, a new customer is created with the ID set to the value provided for subscription[id]. If subscription[id] is unavailable, then the customer ID is autogenerated.

customer.taxability String No

Specifies if the customer is liable for tax * 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.

* 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.

Possible values:

  • "exempt"
  • "taxable"

Default value: "taxable"

customer.email String No

Email of the customer. Configured email notifications will be sent to this email.

customer.last_name String No

Last name of the customer

customer.company String No

Company name of the customer.

customer.first_name String No

First name of the customer

customer.phone String No

Phone number of the customer

customer.auto_collection String No

Whether payments needs to be collected automatically for this customer * 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.

Possible values:

  • "on"
  • "off"

Default value: "on"

customer.vat_number String No

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.

customer.allow_direct_debit Boolean No

Whether the customer can pay via Direct Debit

Default value: false

start_date Integer No

The date/time at which the subscription is to start. If not provided, the subscription starts immediately. You can provide a value in the past as well. This is called backdating the subscription creation and is done when the subscription has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:

  • Backdating is enabled for subscription creation operations.
  • The current day of the month does not exceed the limit set in Chargebee for backdating such operations. This day is typically the day of the month by which the accounting for the previous month must be closed.
  • The date is not more than duration X into the past, where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April, start_date cannot be earlier than 14th February. .
coupon String No

The id of the coupon. For validating the coupon code provided by the user , use the following codes in combination with the param attribute in the error response.

  • resource_not_found : Returned if the coupon is not present.
  • resource_limit_exhausted : Returned if the coupon has expired or the maximum redemption for the coupon has already been reached.
  • invalid_request : Returned if the coupon is not applicable for the particular plan/addon.
trial_end Integer No

The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.

plan_quantity Integer No

Plan quantity for this subscription.

Default value: 1

addons Object No

Parameters for addons

addons.id[] Array No

Identifier of the addon. Multiple addons can be passed.

addons.quantity[] Array No

Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.

billing_address Object No

Parameters for billing_address

billing_address.first_name String No

The first name of the billing contact.

billing_address.state String No

The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.

billing_address.city String No

The name of the city.

billing_address.line2 String No

Address line 2

billing_address.line1 String No

Address line 1

billing_address.email String No

The email address.

billing_address.last_name String No

The last name of the billing contact.

billing_address.company String No

The company name.

billing_address.line3 String No

Address line 3

billing_address.state_code String No

The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).

billing_address.zip String No

Zip or postal code. The number of characters is validated according to the rules specified here.

billing_address.phone String No

The phone number.

billing_address.country String No

The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.
Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom -- Northern Ireland) is available as an option.

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.