POST /customers/{customer-id}/subscription_for_items

Note: This endpoint optionally supports 3DS. To use it create a payment_intent and provide it via this endpoint.

Creates a new subscription for an existing customer in Chargebee. Any available credits and excess payments for the customer are automatically applied on the invoice.

Servers

Path parameters

Name Type Required Description
customer-id String Yes

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-business-entity-id String No

If the site has multiple business entities, you can use this custom HTTP header to specify the business entity for which Chargebee should perform the operation.

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
discounts Object No

Parameters for discounts

discounts.apply_on[] Array No
discounts.included_in_mrr[] Array No

The discount is included in MRR calculations for your site. This attribute is only applicable when duration_type is one_time and when the feature is enabled in Chargebee. Also, If the site-level setting is to exclude one-time discounts from MRR calculations, this value is always returned false.

discounts.period_unit[] Array No
discounts.percentage[] Array No

The percentage of the original amount that should be deducted from it.

discounts.period[] Array No

The duration of time for which the discount is attached to the subscription, in period_units. Applicable only when duration_type is limited_period.

discounts.amount[] Array No

The value of the discount. The format of this value depends on the kind of currency.

discounts.duration_type[] Array Yes
discounts.item_price_id[] Array No

The id of the item price in the subscription to which the discount is to be applied. Relevant only when apply_on = specific_item_price.

business_entity_id String No

The unique ID of the business entity this subscription should be linked to. Applicable only when multiple business entities have been created for the site. This must be the same as the business entity of the {customer_id} for the operation to be successful.
Note

An alternative way of passing this parameter is by means of a custom HTTP header. .

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.

override_relationship Boolean No

If true, ignores the hierarchy relationship and uses customer as payment and invoice owner.

subscription_items Object No

Parameters for subscription_items

subscription_items.charge_on_event[] Array No
subscription_items.unit_price[] Array No

Sub Item Plan Unit Amount for create subscription

subscription_items.charge_once[] Array No

Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This parameter only applies to charge-items.

subscription_items.charge_on_option[] Array No
subscription_items.unit_price_in_decimal[] Array No

Sub Item Plan Unit Amount in Decimal for create subscription

subscription_items.item_price_id[] Array Yes

The unique identifier of the item price.

subscription_items.quantity[] Array No

The quantity of the item purchased

subscription_items.quantity_in_decimal[] Array No

The decimal representation of the quantity of the item purchased. Can be provided for quantity-based item prices and only when multi-decimal pricing is enabled.

subscription_items.service_period_days[] Array No

The service period of the item in days from the day of charge.

subscription_items.trial_end[] Array No

The date/time when the trial period of the item ends. Applies to plan-items and----when enabled----addon-items as well.

subscription_items.usage_accumulation_reset_frequency[] Array No
subscription_items.billing_cycles[] Array No

For the plan-item price:
the value determines the number of billing cycles the subscription runs before canceling automatically. If not provided, then the value set for the plan-item price is used.

For addon-item prices:
If addon billing cycles are enabled then this is the number of subscription billing cycles for which the addon is included. If not provided, then the value set under attached addons is used. Further, if that value is not provided, then the value set for the addon-item price is used.

coupon_ids[] Array No

List of coupons to be applied to this subscription. You can provide coupon ids or coupon codes.

id String No

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

invoice_immediately Boolean No

If there are charges raised immediately for the subscription, this parameter specifies whether those charges are to be invoiced immediately or added to unbilled charges. The default value is as per the site settings.
Note: invoice_immediately only affects charges that are raised at the time of execution of this API call. Any charges scheduled to be raised in the future are not affected by this parameter. .

billing_override Object No

Specify limits on how credits and payments are applied to individual invoices for the subscription. Contact [Support](https://support.chargebee.com/) to enable this feature. Note: These limits do not apply to [consolidated invoices](https://www.chargebee.com/docs/2.0/consolidated-invoicing.html).

billing_override.max_excess_payment_usage Integer No

Maximum amount of excess payments that can be applied to any single invoice associated with this subscription. Set to -1 to remove this limit.

billing_override.max_refundable_credits_usage Integer No

Maximum amount of refundable credits that can be applied to any single invoice associated with this subscription. Set to -1 to remove this limit.

net_term_days Integer No

Defines Net D for the subscription. Net D is the number of days within which any invoice raised for the subscription must be paid.

  • If a value is provided: Net D is set explicitly for the subscription to the value provided. The value must be one among those defined in the site configuration.
  • If not provided: The attribute is not set and therefore not returned by the API. In this case, when an invoice is raised -- whether now or later -- the net_term_days defined at the customer level is considered. .
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. .
free_period Integer No

The period of time by which the first term of the subscription is to be extended free-of-charge. The value must be in multiples of free_period_unit.

auto_collection String No

Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property. * on - Whenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available. * off - Automatic collection of charges will not be made for this subscription. Use this for offline payments.

Possible values:

  • "on"
  • "off"
statement_descriptor Object No

Parameters for statement_descriptor

statement_descriptor.descriptor String No

Payment transaction descriptor text to help your customer easily recognize the transaction. When this value is passed this will override the transaction descriptor text configured in the Chargebee site for all the subscription renewal transactions.

contract_term Object No

Parameters for contract_term

contract_term.action_at_term_end String No

Action to be taken when the contract term completes. * evergreen - Contract term completes and the subscription renews. * renew -

  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew. * cancel - Contract term completes and subscription is canceled.

Possible values:

  • "evergreen"
  • "cancel"
  • "renew"
contract_term.cancellation_cutoff_period Integer No

The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure

Default value: 0

payment_source_id String No

Id of the payment source to be attached to this subscription.

free_period_unit String No

The unit of time in multiples of which the free_period parameter is expressed. The value must be equal to or lower than the period_unit attribute of the plan chosen. * week - Charge based on week(s) * month - Charge based on month(s) * day - Charge based on day(s) * year - Charge based on year(s)

Possible values:

  • "month"
  • "day"
  • "week"
  • "year"
payment_initiator String No

The type of initiator to be used for the payment request triggered by this operation. * customer - Pass this value to indicate that the request is initiated by the customer * merchant - Pass this value to indicate that the request is initiated by the merchant

Possible values:

  • "merchant"
  • "customer"
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.validation_status String No

The address verification status. * partially_valid - The address is valid for taxability but has not been validated for shipping. * invalid - Address is invalid. * not_validated - Address is not yet validated. * valid - Address was validated successfully.

Possible values:

  • "partially_valid"
  • "valid"
  • "not_validated"
  • "invalid"

Default value: "not_validated"

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.

po_number String No

Purchase order number for this subscription.

meta_data Object No

A collection of key-value pairs that provides extra information about the subscription. **Note:** There's a character limit of 65,535. [Learn more](advanced-features?prod_cat_ver=2#metadata).

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.payment_method_type String No

The list of payment method types (For example, card, ideal, sofort, bancontact, etc.) this Payment Intent is allowed to use. If payment method type is empty, Card is taken as the default type for all gateways except Razorpay. * card - card * dotpay - dotpay * faster_payments - Faster Payments * upi - upi * google_pay - google_pay * paypal_express_checkout - paypal_express_checkout * venmo - Venmo * klarna_pay_now - Klarna Pay Now * ideal - ideal * pay_to - PayTo * boleto - boleto * netbanking_emandates - netbanking_emandates * direct_debit - direct_debit * sepa_instant_transfer - Sepa Instant Transfer * bancontact - bancontact * apple_pay - apple_pay * online_banking_poland - Online Banking Poland * giropay - giropay * sofort - sofort * amazon_payments - Amazon Payments

Possible values:

  • "bancontact"
  • "upi"
  • "amazon_payments"
  • "online_banking_poland"
  • "direct_debit"
  • "sofort"
  • "boleto"
  • "netbanking_emandates"
  • "giropay"
  • "paypal_express_checkout"
  • "apple_pay"
  • "pay_to"
  • "venmo"
  • "payconiq_by_bancontact"
  • "card"
  • "klarna_pay_now"
  • "dotpay"
  • "faster_payments"
  • "sepa_instant_transfer"
  • "google_pay"
  • "ideal"
payment_intent.additional_information Object No

* `checkout_com`: While adding a new payment method using [permanent token](./payment_sources?#create_using_permanent_token) or passing raw card details to Checkout.com, `document` ID and `country_of_residence` are required to support payments through [dLocal](https://www.checkout.com/docs/previous/payments/payment-methods/cards/dlocal). * `payer`: User related information. * `country_of_residence`: This is required since the billing country associated with the user's payment method may not be the same as their country of residence. Hence the user's country of residence needs to be specified. The country code should be a [two-character ISO code](https://docs.checkout.com/resources/codes/country-codes). * `document`: Document ID is the user's [identification number](https://docs.dlocal.com/api-documentation/payins-api-reference/country-reference#documents) based on their country. * `bluesnap`: While passing raw card details to BlueSnap, if `fraud_session_id` is added, [additional validation](https://developers.bluesnap.com/docs/fraud-prevention) is performed to avoid fraudulent transactions. * `fraud`: Fraud identification related information. * `fraud_session_id`: Your [BlueSnap fraud session ID](https://developers.bluesnap.com/docs/fraud-prevention#section-implementing-device-data-collector) required to perform anti-fraud validation. * `braintree`: While passing raw card details to Braintree, your `fraud_merchant_id` and the user's `device_session_id` can be added to perform [additional validation](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) and avoid fraudulent transactions. * `fraud`: Fraud identification related information. * `device_session_id`: Session ID associated with the user's device. * `fraud_merchant_id`: Your [merchant ID](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) for fraud detection. * `chargebee_payments`: While passing raw card details to Chargebee Payments, if `fraud_session_id` is added, additional validation is performed to avoid fraudulent transactions. * `fraud`: Fraud identification related information. * `fraud_session_id`: Your Chargebee Payments fraud session ID required to perform anti-fraud validation. * `bank_of_america`: While passing raw card details to Bank of America, your user's `device_session_id` can be added to perform additional validation and avoid fraudulent transactions. * `fraud`: Fraud identification related information. * `device_session_id`: Session ID associated with the user's device. * `ecentric`: This parameter is used to verify and process payment method details in Ecentric. If the `merchant_id` parameter is included, Chargebee will vault it / perform a lookup and verification against this `merchant_id`, overriding the one configured in Chargebee. If tokens and processing occur in the same Merchant GUID, you can just skip this part. * `merchant_id`: Merchant GUID where the card is vaulted or need to be vaulted. * `ebanx`: While passing raw card details to EBANX, the user's `document` is required for some countries and `device_session_id` can be added to perform [additional validation](https://developer.ebanx.com/docs/payments/guides/features/device-fingerprint#device-fingerprint) and avoid fraudulent transactions. * `payer`: User related information. * `document`: Document is the user's identification number based on their country. * `fraud`: Fraud identification related information. * `device_session_id`: Session ID associated with the user's device

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.

terms_to_charge Integer No

The number of subscription billing cycles (including the first one) to invoice in advance.

mandatory_items_to_remove[] Array No

Item ids of mandatorily attached addons that are to be removed from the subscription.

trial_end_action String No

Applicable only when End-of-trial Action has been enabled for the site. Whenever the subscription has a trial period, this attribute (parameter) is returned (required) and specifies the operation to be carried out for the subscription once the trial ends. * cancel_subscription - The subscription cancels. * activate_subscription - The subscription activates and charges are raised for non-metered items. * plan_default - The action configured for the site at the time when the trial ends, takes effect. * site_default - This is the default value. The action configured for the site at the time when the trial ends, takes effect.

Possible values:

  • "site_default"
  • "cancel_subscription"
  • "activate_subscription"
  • "plan_default"
auto_close_invoices Boolean No

Set to false to override for this subscription, the site-level setting for auto-closing invoices. Only applicable when auto-closing invoices has been enabled for the site. This attribute has a higher precedence than the same attribute at the customer level.

replace_primary_payment_source Boolean No

Indicates whether the primary payment source should be replaced with this payment source. In case of Create Subscription for Customer endpoint, the default value is True. Otherwise, the default value is False.

Default value: true

billing_cycles Integer No

Specifies the number of billing cycles for the subscription. The behavior of the subscription after the billing cycles have completed depends on whether the subscription is on a contract term or not.

  • When the subscription is not on a contract term: if billing_cycles is not provided, then the billing cycles set for the plan-item price is used. Moreover, once the billing_cycles have completed, the subscription cancels.
  • When the subscription is on a contract term: Providing billing_cycles is mandatory. Moreover, once the billing_cycles have completed, the behavior of the subscription is determined by the contract_term[action_at_term_end] parameter.
create_pending_invoices Boolean No

Indicates whether the invoices for this subscription are generated with a pending status. This attribute is set to true automatically when the subscription has item prices that belong to metered items.

You can also set this to true explicitly using the create/update subscription operations. This is useful in the following scenarios:

  • When tracking usages and calculating usage-based charges on your end. You can then add them to the subscription as a one-time charge at the end of the billing term.
  • When you need to inspect all charges before closing invoices for this subscription.

Applicable only when Metered Billing is enabled for the site .

billing_alignment_mode String No

Override the billing alignment mode for Calendar Billing. Only applicable when using Calendar Billing. The default value is that which has been configured for the site. * immediate - Subscription period will be aligned with the configured billing date immediately, with credits or charges raised accordingly.. * delayed - Subscription period will be aligned with the configured billing date at the next renewal.

Possible values:

  • "immediate"
  • "delayed"
first_invoice_pending Boolean No

If you want to bill the usages from the previous billing cycle, set this parameter to true. This is useful if the subscription has moved from another system into Chargebee and you haven't closed the previous cycle's invoice yet. This creates a pending invoice immediately on subscription creation, to which you can add usages for the previous cycle.

If any non-metered items are present for the current term, they're also added to this pending invoice. As with all pending invoices, this invoice is also closed automatically or via an API call. This parameter can be passed only when the create_pending_invoices is true .

Default value: false

item_tiers Object No

Parameters for item_tiers

item_tiers.starting_unit_in_decimal[] Array No

The decimal representation of the lowest value of quantity in this tier. This is zero for the lowest tier. For all other tiers, it is the same as ending_unit_in_decimal of the next lower tier. Returned only when the pricing_model is tiered, volume or stairstep and multi-decimal pricing is enabled.

item_tiers.price_in_decimal[] Array No

The decimal representation of the per-unit price for the tier when the pricing_model is tiered or volume. When the pricing_model is stairstep, it is the decimal representation of the total price for the item. The value is in major units of the currency. Returned when the plan is quantity-based and multi-decimal pricing is enabled.

item_tiers.package_size[] Array No

Package size for the tier when pricing type is package. Specify the number of units that make up one package. For example, if 1000 API hits are grouped into a single package, set the package size to 1000.

item_tiers.price[] Array No

The overridden price of the tier. The value depends on the type of currency.

item_tiers.ending_unit[] Array No

The highest value in the quantity tier.

item_tiers.item_price_id[] Array No

The id of the item price for which the tier price is being overridden.

item_tiers.pricing_type[] Array No
item_tiers.starting_unit[] Array No

The lowest value in the quantity tier.

item_tiers.ending_unit_in_decimal[] Array No

The decimal representation of the highest value of quantity in this tier. This attribute is not applicable for the highest tier. For all other tiers, it must be equal to the starting_unit_in_decimal of the next higher tier. Returned only when the pricing_model is tiered, volume or stairstep and multi-decimal pricing is enabled.

invoice_date Integer No

The document date displayed on the invoice PDF. The default value is the current date. Provide this value to backdate the invoice. Backdating an invoice is done for reasons such as booking revenue for a previous date or when the subscription is effective as of a past date. Moreover, if create_pending_invoices is set to true, and if the site is configured to set invoice dates to the date of closing, then upon invoice closure, this date is changed to the invoice closing date. taxes and line_item_taxes are computed based on the tax configuration as of invoice_date. When passing this parameter, the following prerequisites must be met:

  • invoice_date must be in the past.
  • It is not earlier than start_date.
  • It is not more than one calendar month into the past. Eg. If today is 13th January, then you cannot pass a value that is earlier than 13th December.
  • invoice_immediately is true. .
trial_end Integer No

End of the trial period for the subscription. This overrides the trial period set for the plan-item. The value must be later than start_date. Set it to 0 to have no trial period.

contract_term_billing_cycle_on_renewal Integer No

Number of billing cycles the new contract term should run for, on contract renewal. The default value is the same as billing_cycles or a custom value depending on the site configuration.

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.