Imports a subscription for an existing customer.
Use this operation when migrating subscriptions from another billing system.
Prerequisites & Constraints
- Pause Subscription must be enabled for your site to import subscriptions with
statusset topaused. - At least one
subscription_items[item_price_id]must reference an item price of typeplan.
If you are calling this operation on your live site, ensure you have requested Support to enable it; otherwise the API may return an "API not enabled" error.
Impacts
Subscription
A subscription is created for the customer with the details provided in the request.
Invoice and payment
When create_current_term_invoice is true, an invoice is created for the current term.
Sample Request
Sample Result[JSON]
URL Format
Input Parameters
Specifies the IDs of coupons
to be marked as exhausted. This parameter accepts a list of IDs, which must correspond to coupons with a duration_type
of one_time.
Ensure that the IDs included in this parameter do not match any IDs provided in the coupon_ids
parameter.
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.
trial_endis required whenstatusisin_trial.
trial_endmust not be provided whenstatusisfuture.trial_endmust be a future timestamp whenstatusisin_trial.
The number of billing cycles the subscription runs before canceling. If not provided, then the billing cycles set for the plan-item price is used.
billing_cyclesis required whencontract_term[action_at_term_end]is provided.
billing_cyclesmust not be provided whenstatusiscancelled.billing_cyclesmust be at least 1, unlessstatusisin_trial.
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_daysdefined at the customer level is considered. .
- Payment Terms for Subscriptions must be enabled for your site to provide
net_term_days.
net_term_daysis not allowed whenauto_collectionison, unless Net Term Days for online payment methods is enabled for your site.net_term_daysis not allowed whenauto_collectionisoff, unless Net Term Days for offline payment methods is enabled for your site.
The date/time at which the subscription is to start or has started. If not provided, the subscription starts immediately.
start_dateis required whenstatusisfuture.
start_datemust be a future timestamp whenstatusisfuture.start_datemust not be provided whenstatusisin_trial.
Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
Whenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.
Automatic collection of charges will not be made for this subscription. Use this for offline payments.
List of coupons to be applied to this subscription. You can provide coupon ids or coupon codes .
Current state of the subscription.
statuscannot be set totransferredwhen importing a subscription.
The subscription is scheduled to start at a future date.
The subscription is in trial.
The subscription is active and will be charged for automatically based on the items in it.
The subscription will be canceled at the end of the current term.
The subscription is paused. The subscription will not renew while in this state.
The subscription has been canceled and is no longer in service.
The subscription has been transferred to another business entity within the organization.
End of the current billing term. Subscription is renewed immediately after this. If not given, this will be calculated based on plan billing cycle.
current_term_endis required whenstatusisactiveornon_renewing.current_term_endis required whenstatusispaused.
current_term_endmust not be provided whenstatusisfuture.current_term_endmust not be provided whenstatusisin_trial.
Start of the current billing period of the subscription. This is required when the subscription status
is paused.
When the status
is active
or non_renewing
, it defaults to the current time.
current_term_startis required whenstatusispaused.
current_term_startmust not be provided whenstatusisfuture.current_term_startmust not be provided whenstatusisin_trial.
Start of the trial period for the subscription. When not passed, it is assumed to be current time. When passed for a future
subscription, it implies that the subscription goes into in_trial
when it starts.
trial_startmust not be provided whenstatusisfuture.trial_startmust be in the past whenstatusisin_trial.
Time at which subscription was cancelled or is set to be cancelled.
cancelled_atis required whenstatusiscancelled.
cancelled_atmust not be provided whenstatusisfuture.cancelled_atmust not be provided whenstatusisin_trial.
The time at which the subscription was activated. A subscription is "activated" when its status changes from any other, to either active or non_renewing.
activated_atmust not be provided whenstatusisfuture.activated_atmust be earlier thantrial_startwhenstatusisin_trial.
When a pause has been scheduled, it is the date/time of scheduled pause. When the subscription is in the paused
state, it is the date/time when the subscription was paused.
pause_dateis required whenstatusispaused.
pause_datemust not be provided whenstatusisfuture.pause_datemust not be provided whenstatusisin_trial.
For a paused subscription, it is the date/time when the subscription is scheduled to resume. If the pause is for an indefinite period, this value is not returned.
resume_datemust not be provided whenstatusisfuture.resume_datemust not be provided whenstatusisin_trial.
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
.
contract_term_billing_cycle_on_renewalis required whencontract_term[action_at_term_end]isreneworrenew_once.
- Contract Terms must be enabled for your site to provide
contract_term_billing_cycle_on_renewal.
contract_term_billing_cycle_on_renewalmust not be provided whencontract_term[action_at_term_end]iscancelorevergreen.contract_term_billing_cycle_on_renewalrequirescontract_term[action_at_term_end]to be provided.
Set as true
if you want an invoice to be created for the subscription.
- The invoice will be created for the subscription only if it has an
activeornon_renewingstatus. - The period of the invoice is from
current_term_starttocurrent_term_end. - The invoice will not be generated if the subscription amount is zero dollars (for that period) and 'Hide Zero Value Line Items' option is enabled in site settings.
- You may pass
transactiondetails to record an offline payment against that invoice.
create_current_term_invoicecan betrueonly whenstatusisactiveornon_renewing.
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.
A set of key-value pairs stored as additional information for the subscription. Learn more .
Reason code for canceling the subscription. Must be one from a list of reason codes set in the Chargebee app in Settings > Configure Chargebee > Reason Codes > Subscriptions > Subscription Cancellation. Must be passed if set as mandatory in the app. The codes are case-sensitive.
cancel_reason_codemust not be provided whenstatusisfuture,in_trial,active,non_renewing, orpaused.
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 .
- Metered Billing must be enabled for your site to provide
create_pending_invoices.
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
.
- Metered Billing must be enabled for your site to provide
auto_close_invoices.