# Import subscription for customer

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/v2/pcv-1/idempotency)

Import the subscription details of a customer.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWkp5t2VV/import_subscription \
     -X POST  \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d status="IN_TRIAL" \
     -d trial_end=1602095400 \
     -d billing_cycles=5 \
     -d "addons[id][0]"="ssl" \
     -d "contract_term[action_at_term_end]"="RENEW" \
     -d contract_term_billing_cycle_on_renewal=3 \
     -d "contract_term[contract_start]"=1509511210 \
     -d "contract_term[cancellation_cutoff_period]"=3 \
     -d "contract_term[created_at]"=1509511210 \
     -d "contract_term[total_amount_raised]"=900 \
     -d "contract_term[billing_cycle]"=5
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.ImportForCustomer("__test__KyVnHhSBWkp5t2VV")
		.PlanId("no_trial")
		.Status(Subscription.StatusEnum.InTrial)
		.TrialEnd(1602095400)
		.BillingCycles(5)
		.AddonId(0, "ssl")
		.ContractTermActionAtTermEnd(Subscription.SubscriptionContractTerm.ActionAtTermEndEnum.Renew)
		.ContractTermContractStart(1509511210)
		.ContractTermCancellationCutoffPeriod(3)
		.ContractTermCreatedAt(1509511210)
		.ContractTermTotalAmountRaised(900)
		.ContractTermBillingCycle(5)
		.ContractTermBillingCycleOnRenewal(3)
		.Request();

Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Card card = result.Card;
Invoice invoice = result.Invoice;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    subscriptionAction "github.com/chargebee/chargebee-go/v3/actions/subscription"
    "github.com/chargebee/chargebee-go/v3/models/subscription"
    subscriptionEnum "github.com/chargebee/chargebee-go/v3/models/subscription/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.ImportForCustomer("__test__KyVnHhSBWkp5t2VV", &subscription.ImportForCustomerRequestParams{
        Addons : []*subscription.ImportForCustomerAddonParams{
            {
                Id : "ssl",
            },
        },
        PlanId : "no_trial",
        Status : subscriptionEnum.StatusInTrial,
        TrialEnd : chargebee.Int64(1602095400),
        BillingCycles : chargebee.Int32(5),
        ContractTerm : &subscription.ImportForCustomerContractTermParams{
            ActionAtTermEnd : subscriptionEnum.ContractTermActionAtTermEndRenew,
            ContractStart : chargebee.Int64(1509511210),
            CancellationCutoffPeriod : chargebee.Int32(3),
            CreatedAt : chargebee.Int64(1509511210),
            TotalAmountRaised : chargebee.Int64(900),
            BillingCycle : chargebee.Int32(5),
        },
        ContractTermBillingCycleOnRenewal : chargebee.Int32(3),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.SubscriptionImportForCustomerRequest{
    Addons : []*chargebee.SubscriptionImportForCustomerAddon{
        {
            Id : "ssl",
        },
    },
    PlanId : "no_trial",
    Status : chargebee.SubscriptionStatusInTrial,
    TrialEnd : chargebee.Int64(1602095400),
    BillingCycles : chargebee.Int32(5),
    ContractTerm : &chargebee.SubscriptionImportForCustomerContractTerm{
        ActionAtTermEnd : chargebee.ContractTermActionAtTermEndRenew,
        ContractStart : chargebee.Int64(1509511210),
        CancellationCutoffPeriod : chargebee.Int32(3),
        CreatedAt : chargebee.Int64(1509511210),
        TotalAmountRaised : chargebee.Int64(900),
        BillingCycle : chargebee.Int32(5),
    },
    ContractTermBillingCycleOnRenewal : chargebee.Int32(3),
}
  res, err := client.Subscription.ImportForCustomer("__test__KyVnHhSBWkp5t2VV", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.sql.Timestamp;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.importForCustomer("__test__KyVnHhSBWkp5t2VV")
            .planId("no_trial")
            .status(Subscription.Status.IN_TRIAL)
            .trialEnd(new Timestamp(1602095400L * 1000))
            .billingCycles(5)
            .addonId(0, "ssl")
            .contractTermActionAtTermEnd(Subscription.ContractTerm.ActionAtTermEnd.RENEW)
            .contractTermContractStart(new Timestamp(1509511210L * 1000))
            .contractTermCancellationCutoffPeriod(3)
            .contractTermCreatedAt(new Timestamp(1509511210L * 1000))
            .contractTermTotalAmountRaised(900L)
            .contractTermBillingCycle(5)
            .contractTermBillingCycleOnRenewal(3)
            .request();

        Subscription subscription = result.subscription();
        Customer customer = result.customer();
        Card card = result.card();
        Invoice invoice = result.invoice();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.card.Card;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.subscription.Subscription;
import com.chargebee.v4.models.subscription.params.SubscriptionImportForCustomerParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionImportForCustomerResponse;
import java.sql.Timestamp;
import java.util.List;

public class SubscriptionImportForCustomer {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        SubscriptionImportForCustomerParams.ContractTermParams contractTermParams =
            SubscriptionImportForCustomerParams.ContractTermParams.builder()
                .actionAtTermEnd(SubscriptionImportForCustomerParams.ContractTermParams.ActionAtTermEnd.RENEW)
                .contractStart(new Timestamp(1509511210L * 1000))
                .cancellationCutoffPeriod(3)
                .createdAt(new Timestamp(1509511210L * 1000))
                .totalAmountRaised(900L)
                .billingCycle(5)
                .build();

        SubscriptionImportForCustomerParams.AddonsParams addon0 =
            SubscriptionImportForCustomerParams.AddonsParams.builder()
                .id("ssl")
                .build();

        List<SubscriptionImportForCustomerParams.AddonsParams> addonsList =
            List.of(addon0);

        SubscriptionImportForCustomerParams params = SubscriptionImportForCustomerParams.builder()
            .planId("no_trial")
            .status(SubscriptionImportForCustomerParams.Status.IN_TRIAL)
            .trialEnd(new Timestamp(1602095400L * 1000))
            .billingCycles(5)
            .addons(addonsList)
            .contractTerm(contractTermParams)
            .contractTermBillingCycleOnRenewal(3)
            .build();

        SubscriptionImportForCustomerResponse response = client
            .subscriptions()
            .importForCustomer("__test__KyVnHhSBWkp5t2VV", params);

        Subscription subscription = response.getSubscription();
        Customer customer = response.getCustomer();
        Card card = response.getCard();
        Invoice invoice = response.getInvoice();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.subscription.importForCustomer("__test__KyVnHhSBWkp5t2VV", {
        addons: [
            {
                id: "ssl"
            }
        ],
        plan_id: "no_trial",
        status: "in_trial",
        trial_end: 1602095400,
        billing_cycles: 5,
        contract_term: {
            action_at_term_end: "renew",
            contract_start: 1509511210,
            cancellation_cutoff_period: 3,
            created_at: 1509511210,
            total_amount_raised: 900,
            billing_cycle: 5
        },
        contract_term_billing_cycle_on_renewal: 3
    });

    console.log(result);
    const subscription = result.subscription;
    const customer = result.customer;
    const card = result.card;
    const invoice = result.invoice;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->subscription()->importForCustomer("__test__KyVnHhSBWkp5t2VV", [
    "addons" => [
        [
            "id" => "ssl"
        ]
    ],
    "plan_id" => "no_trial",
    "status" => "in_trial",
    "trial_end" => 1602095400,
    "billing_cycles" => 5,
    "contract_term" => [
        "action_at_term_end" => "renew",
        "contract_start" => 1509511210,
        "cancellation_cutoff_period" => 3,
        "created_at" => 1509511210,
        "total_amount_raised" => 900,
        "billing_cycle" => 5
    ],
    "contract_term_billing_cycle_on_renewal" => 3
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.import_for_customer("__test__KyVnHhSBWkp5t2VV",
    cb_client.Subscription.ImportForCustomerParams(
        addons=[
            cb_client.Subscription.ImportForCustomerAddonParams(
              id="ssl"
            )
        ],
        plan_id="no_trial",
        status=chargebee.Subscription.Status.IN_TRIAL,
        trial_end=1602095400,
        billing_cycles=5,
        contract_term=cb_client.Subscription.ImportForCustomerContractTermParams(
            action_at_term_end=chargebee.Subscription.ContractTermActionAtTermEnd.RENEW,
            contract_start=1509511210,
            cancellation_cutoff_period=3,
            created_at=1509511210,
            total_amount_raised=900,
            billing_cycle=5
        ),
        contract_term_billing_cycle_on_renewal=3
    )
)
subscription = response.subscription
customer = response.customer
card = response.card
invoice = response.invoice
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Subscription.import_for_customer("__test__KyVnHhSBWkp5t2VV",{
  :plan_id => "no_trial",
  :status => "IN_TRIAL",
  :trial_end => 1602095400,
  :billing_cycles => 5,
  :addons => [
    {
      :id => "ssl"
    }
  ],
  :contract_term => {
    :action_at_term_end => "RENEW",
    :contract_start => 1509511210,
    :cancellation_cutoff_period => 3,
    :created_at => 1509511210,
    :total_amount_raised => 900,
    :billing_cycle => 5
  },
  :contract_term_billing_cycle_on_renewal => 3
})

subscription = result.subscription
customer = result.customer
card = result.card
invoice = result.invoice
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "off",
    "card_status": "no_card",
    "created_at": 1517505659,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "Mark",
    "id": "__test__KyVnHhSBWkp5t2VV",
    "last_name": "Henry",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505659000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505659
  },
  "subscription": {
    "addons": [
      {
        "amount": 495,
        "id": "ssl",
        "object": "addon",
        "quantity": 1,
        "unit_price": 495
      },
      {..}
    ],
    "billing_period": 1,
    "billing_period_unit": "month",
    "contract_term": {
      "action_at_term_end": "renew",
      "billing_cycle": 5,
      "cancellation_cutoff_period": 3,
      "contract_end": 1615141800,
      "contract_start": 1509511210,
      "created_at": 1509511210,
      "id": "__test__KyVnHhSBWkp8U2VZ",
      "object": "contract_term",
      "remaining_billing_cycles": 5,
      "status": "active",
      "total_contract_value": 7850
    },
    "contract_term_billing_cycle_on_renewal": 3,
    "created_at": 1517505659,
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWkp5t2VV",
    "deleted": false,
    "due_invoices_count": 0,
    "has_scheduled_changes": false,
    "id": "__test__KyVnHhSBWkp852VX",
    "next_billing_at": 1602095400,
    "object": "subscription",
    "plan_amount": 895,
    "plan_free_quantity": 0,
    "plan_id": "no_trial",
    "plan_quantity": 1,
    "plan_unit_price": 895,
    "remaining_billing_cycles": 5,
    "resource_version": 1517505659000,
    "started_at": 1517505659,
    "status": "in_trial",
    "trial_end": 1602095400,
    "trial_start": 1517505659,
    "updated_at": 1517505659
  }
}
```

## URL Format

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

## Input Parameters

- `id` (optional, string, max chars=50)
  A unique and immutable identifier for the subscription. If not provided, it is autogenerated.

- `plan_id` (required, string, max chars=100)
  Identifier of the plan for this subscription.

- `plan_quantity` (optional, integer, default=1, min=1)
  Plan quantity for this subscription.

- `plan_quantity_in_decimal` (optional, string, max chars=33)
  The decimal representation of the quantity of the plan purchased. Can be provided for quantity-based plans and only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.

- `plan_unit_price` (optional, in cents, min=0)
  Amount that will override the Plan's default price. The unit depends on the [type of currency](/docs/api/getting-started) .

- `plan_unit_price_in_decimal` (optional, string, max chars=39)
  When [price overriding](http://chargebee.com/docs/price-override.html ) is enabled for the site, the price or per-unit price of the plan can be set here. The value [set for the plan](/docs/api/v2/pcv-1/plans/plan-object#price) is used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.

- `setup_fee` (optional, in cents, min=0)
  Amount that will override the default setup fee. The unit depends on the [type of currency](/docs/api/getting-started) .

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

- `billing_cycles` (optional, integer, min=0)
  Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.

- `start_date` (optional, timestamp(UTC) in seconds)
  The date/time at which the subscription is to start or has started. If not provided, the subscription starts immediately.

- `auto_collection` (optional, enumerated string)
  Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
  Possible enum values:
    - `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.

- `po_number` (optional, string, max chars=100)
  Purchase order number for this subscription.

- `coupon_ids` (optional, string, max chars=100)
  List of coupons to be applied to this subscription. You can provide coupon ids or [coupon codes](/docs/api/coupon_codes) .

- `payment_source_id` (optional, string, max chars=40)
  Id of the payment source to be attached to this subscription.

- `status` (required, enumerated string)
  Current state of the subscription.
  Possible enum values:
    - `future`
      The subscription is scheduled to start at a future date.
    - `in_trial`
      The subscription is in trial.
    - `active`
      The subscription is active and will be charged for automatically based on the items in it.
    - `non_renewing`
      The subscription will be canceled at the end of the current term.
    - `paused`
      The subscription is [paused](https://www.chargebee.com/docs/2.0/pause-subscription.html). The subscription will not renew while in this state.
    - `cancelled`
      The subscription has been canceled and is no longer in service.
    - `transferred`
      The subscription has been transferred to another business entity within the organization.

- `current_term_end` (optional, timestamp(UTC) in seconds)
  End of the current billing term. Subscription is renewed immediately after this. If not given, this will be calculated based on plan billing cycle.
  
  **Note:**
  
  For subscription status: `non_renewing`, `active`, and `paused`, `current_term_end` is required.
  
  .

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

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

- `cancelled_at` (optional, timestamp(UTC) in seconds)
  Time at which subscription was cancelled or is set to be cancelled.

- `started_at` (optional, timestamp(UTC) in seconds)
  Time at which the subscription was started. Is `null` for `future` subscriptions as it is yet to be started.

- `activated_at` (optional, timestamp(UTC) in seconds)
  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`.
  
  The following conditions must be satisfied when passing this parameter:
  
  -   When `status` is `active`, `non_renewing`, or `paused`, `activated_at` must be on or after `trial_end` or `started_at`. Additionally, `activated_at` must be on or before `current_term_start`.
  -   When `status` is `in_trial`, `activated_at` must precede `trial_start`
  
  #### Note:[](#note)
  
  This parameter should not be provided when passing `status` as `future` or `cancelled`.

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

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

- `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](https://www.chargebee.com/docs/contract-terms.html#configuring-contract-terms) .

- `create_current_term_invoice` (optional, boolean, default=false)
  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 `active` or `non_renewing` status.
  -   The period of the invoice is from `current_term_start` to `current_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.

- `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](/docs/api/invoices/invoice-object#notes) displayed on the invoice PDF.

- `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](/docs/api/v2/pcv-1/advanced-features) .

- `contract_term` (optional, string)
  Parameters for contract\_term
  - `id` (optional, string, max chars=50)
    Id that uniquely identifies the contract term in the site.
  - `created_at` (optional, timestamp(UTC) in seconds)
    The date when the contract term was created.
  - `contract_start` (optional, timestamp(UTC) in seconds)
    The start date of the contract term
  - `billing_cycle` (optional, integer, min=0)
    The number of billing cycles of the subscription that the contract term is for.
  - `total_amount_raised` (optional, in cents, default=0, min=0)
    The amount raised for the contract term till the time of importing the subscription. This amount is added to the `[total_contract_value](/docs/api/contract_terms/contract_term-object#total_contract_value)`
  - `total_amount_raised_before_tax` (optional, in cents, default=0, min=0)
    The amount raised for the contract term till the time of importing the subscription excluding tax. This amount is added to the `[total_contract_value_before_tax](/docs/api/contract_terms/contract_term-object#total_contract_value)`
  - `action_at_term_end` (optional, enumerated string, default=renew)
    Action to be taken when the contract term completes.
    Possible enum values:
      - `renew`
        -   Contract term completes and a new contract term is started for the number of billing cycles specified in [`contract_billing_cycle_on_renewal`](/docs/api/v2/pcv-1/subscriptions/create-subscription-for-customer#contract_term_billing_cycle_on_renewal).
        -   The `action_at_term_end` for the new contract term is set to `renew`.
      - `evergreen`
        Contract term completes and the subscription renews.
      - `cancel`
        Contract term completes and subscription is canceled.
      - `renew_once`
        Used when you want to renew the contract term just once. Does the following: - Contract term completes and a new contract term is started for the number of billing cycles specified in [`contract_billing_cycle_on_renewal`](/docs/api/v2/pcv-1/subscriptions/create-subscription-for-customer#contract_term_billing_cycle_on_renewal).
        
        -   The `action_at_term_end` for the new contract term is set to `cancel`.
  - `cancellation_cutoff_period` (optional, integer, default=0)
    The number of days before [`contract_end`](/docs/api/contract_terms/contract_term-object#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.

- `transaction` (optional, in cents)
  Parameters for transaction
  - `amount` (optional, in cents, min=0)
    The payment transaction amount. This parameter should be passed only if the invoice is created for current term.
  - `payment_method` (optional, enumerated string)
    The payment method of this transaction. This parameter should be passed only if the invoice is created for current term.
    Possible enum values:
      - `cash`
        Cash
      - `check`
        Check
      - `bank_transfer`
        Bank Transfer
      - `other`
        Payment Methods other than the above types
      - `custom`
        Custom
      - `tamara`
      - `qpay`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
  - `reference_number` (optional, string, max chars=100)
    The reference number for this transaction. For example, check number in case of `check` `payment_method`. This parameter should be passed only if the invoice is created for current term.
  - `date` (optional, timestamp(UTC) in seconds)
    The date of occurence of the transaction. This parameter should be passed only if the invoice is created for current term.

- `shipping_address` (optional, string)
  Parameters for shipping\_address
  - `first_name` (optional, string, max chars=150)
    The first name of the contact.
  - `last_name` (optional, string, max chars=150)
    The last name of the contact.
  - `email` (optional, string, max chars=70)
    The email address.
  - `company` (optional, string, max chars=250)
    The company name.
  - `phone` (optional, string, max chars=50)
    The phone number.
  - `line1` (optional, string, max chars=150)
    Address line 1
  - `line2` (optional, string, max chars=150)
    Address line 2
  - `line3` (optional, string, max chars=150)
    Address line 3
  - `city` (optional, string, max chars=50)
    The name of the city.
  - `state_code` (optional, string, max chars=50)
    The [ISO 3166-2 state/province code](https://www.iso.org/obp/ui/#search/code) without the country prefix. Currently supported for USA, Canada, India and UAE. 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` ). For Dubai (UAE), set as `DU` (not `AE-DU` ).
  - `state` (optional, string, max chars=50)
    The state/province name. Is set by Chargebee automatically for US, Canada, India and UAE, if `state_code` is provided.
  - `zip` (optional, string, max chars=20)
    Zip or postal code. The number of characters is validated according to the rules [specified here](https://chromium-i18n.appspot.com/ssl-address) .
  - `country` (optional, string, max chars=50)
    The billing address country of the customer. Must be one of [ISO 3166 alpha-2 country code](https://www.iso.org/iso-3166-country-codes.html) .
    
    **Note**: If you enter an invalid country code, the system will return an error.
    
    **Brexit**
    
    If you have enabled [EU VAT](https://www.chargebee.com/docs/eu-vat.html) in 2021 or later, or have [manually enable](https://www.chargebee.com/docs/brexit.html#what-needs-to-be-done-in-chargebee) the Brexit configuration, then `XI` (the code for **United Kingdom - Northern Ireland**) is available as an option.
  - `validation_status` (optional, enumerated string, default=not_validated)
    The address verification status.
    Possible enum values:
      - `not_validated`
        Address is not yet validated.
      - `valid`
        Address was validated successfully.
      - `partially_valid`
        The address is valid for taxability but has not been validated for shipping.
      - `invalid`
        Address is invalid.

- `addons` (optional, array)
  Parameters for addons
  - `id` (optional, string, max chars=100)
    Identifier of the addon. Multiple addons can be passed.
  - `quantity` (optional, integer)
    Quantity of the addon. Applicable for addons with `pricing_model` other than `flat_fee` .
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `unit_price` (optional, in cents)
    The price or per-unit-price of the addon. The value depends on the [type of currency](/docs/api/getting-started).
    
    **Note:**
    
    For recurring addons, this is the final price or per-unit price for each billing period of the subscription, regardless of the [addon period](/docs/api/v2/pcv-1/addons/addon-object#period). For example, consider the following details:
    
    -   The `unit_price` provided is $10
    -   The addon billing period is 1 month.
    -   The plan billing period is 3 months.
    -   The addon is only billed for $10 on each subscription renewal.
  - `unit_price_in_decimal` (optional, string, max chars=39)
    When [price overriding](http://chargebee.com/docs/price-override.html ) is enabled for the site, the price or per-unit price of the addon can be set here. The value [set for the addon](/docs/api/v2/pcv-1/addons/addon-object#price) is used by default. However, the price provided here is considered as the price of the addon for an entire billing cycle of the subscription regardless of the value of the addon `period`. Provide the value as a decimal string in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `billing_cycles` (optional, integer)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.

- `event_based_addons` (optional, array)
  Parameters for event\_based\_addons
  - `id` (optional, string, max chars=100)
    A unique 'id' used to identify the addon.
  - `quantity` (optional, integer)
    Quantity of the addon. Applicable for addons with `pricing_model` other than `flat_fee` .
  - `unit_price` (optional, in cents)
    Amount that will override the Addon's default price. The unit depends on the [type of currency](/docs/api/getting-started) .
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `unit_price_in_decimal` (optional, string, max chars=39)
    When [price overriding](http://chargebee.com/docs/price-override.html ) is enabled for the site, the price or per-unit price of the addon can be set here. The value [set for the addon](/docs/api/v2/pcv-1/addons/addon-object#price) is used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `service_period_in_days` (optional, integer)
    Defines service period of the addon in days from the day of charge.
  - `on_event` (optional, enumerated string)
    Event on which this addon will be charged.
    Possible enum values:
      - `subscription_creation`
        Addon will be charged on subscription creation.
      - `subscription_trial_start`
        Addon will be charged when the trial period starts.
      - `plan_activation`
        Addon will be charged on plan activation.
      - `subscription_activation`
        Addon will be charged on subscription activation.
      - `contract_termination`
        Addon will be charged on contract termination.
  - `charge_once` (optional, boolean)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.

- `charged_event_based_addons` (optional, array)
  Parameters for charged\_event\_based\_addons
  - `id` (optional, string, max chars=100)
    Addon id.
  - `last_charged_at` (optional, timestamp(UTC) in seconds)
    Timestamp indicating when this add-on was last charged for this subscription.

## Returns

- `subscription` (Subscription object)
  Resource object representing subscription

- `customer` (Customer object)
  Resource object representing customer

- `card` (Card object)
  Resource object representing card

- `invoice` (Invoice object)
  Resource object representing invoice
