ChargebeeAPI

Create subscription for Items

Idempotency Supported
Try in API Explorer

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.

Sample Request

URL Format

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

Input Parameters

id
optional, string, max chars=50

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

business_entity_id
optional, string, max chars=50

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.

trial_end
optional, timestamp(UTC) in seconds

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.

billing_cycles
optional, integer, min=0

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.
mandatory_items_to_remove
optional, string

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

net_term_days
optional, integer

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
optional, timestamp(UTC) in seconds

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. .
terms_to_charge
optional, integer, min=1

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

billing_alignment_mode
optional, enumerated string

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.

Possible Enum Values
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.

offline_payment_method
optional, enumerated string

The preferred offline payment method for the subscription.

Possible Enum Values
no_preference

No Preference

cash

Cash

check

Check

bank_transfer

Bank Transfer

ach_credit

ACH Credit

po_number
optional, string, max chars=100

Purchase order number for this subscription.

coupon_ids
optional, string

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

payment_source_id
optional, string, max chars=40

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

override_relationship
optional, boolean

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

invoice_notes
optional, string, max chars=2000

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.

invoice_date
optional, timestamp(UTC) in seconds

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. .
meta_data
optional, jsonobject

A collection of key-value pairs that provides extra information about the subscription.

Note: There's a character limit of 65,535.

Learn more .

invoice_immediately
optional, boolean

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.

.

replace_primary_payment_source
optional, boolean, default=true

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.

free_period
optional, integer, min=1

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.

free_period_unit
optional, enumerated string

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.

Possible Enum Values
day

Charge based on day(s)

week

Charge based on week(s)

month

Charge based on month(s)

year

Charge based on year(s)

contract_term_billing_cycle_on_renewal
optional, integer, min=1, max=100

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 .

create_pending_invoices
optional, boolean

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 .
auto_close_invoices
optional, boolean

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 .

first_invoice_pending
optional, boolean, default=false

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 .

trial_end_action
optional, enumerated string

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.

Possible Enum Values
site_default

This is the default value. The action configured for the site at the time when the trial ends, takes effect.

plan_default

The action configured for the site at the time when the trial ends, takes effect.

activate_subscription

The subscription activates and charges are raised for non-metered items.

cancel_subscription

The subscription cancels.

payment_initiator
optional, enumerated string

The type of initiator to be used for the payment request triggered by this operation.

Possible Enum Values
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

shipping_address
optional, string

Parameters for shipping_address

statement_descriptor
optional, string

Parameters for statement_descriptor

payment_intent
optional, string

Parameters for payment_intent

contract_term
optional, enumerated string

Parameters for contract_term

billing_override
optional, long

Specify limits on how credits and payments are applied to individual invoices for the subscription. Contact Support to enable this feature. Note: These limits do not apply to consolidated invoices .

subscription_items
optional, string

Parameters for subscription_items

discounts
optional, enumerated string

Parameters for discounts

item_tiers
optional, string

Parameters for item_tiers

Returns

subscriptionSubscription object

Resource object representing subscription

customerCustomer object

Resource object representing customer

cardCard object

Resource object representing card

invoiceInvoice object

Resource object representing invoice

Resource object representing unbilled_charge