# Import a subscription

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


[Idempotency Supported](/docs/api/idempotency)

Imports a [subscription](/docs/api/subscriptions) for an existing [customer](/docs/api/customers).

Use this operation when migrating subscriptions from another billing system.

### Prerequisites & Constraints

If you are calling this operation on your live site, ensure you have [requested Support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=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

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__8at19S2Bx82rKy/import_for_items \
     -X POST  \
     -u {site_api_key}:\
     -d "subscription_items[item_price_id][0]"="basic-USD" \
     -d "subscription_items[quantity][0]"=1 \
     -d status="ACTIVE" \
     -d "charged_items[item_price_id][0]"="ssl-charge-USD" \
     -d "charged_items[last_charged_at][0]"=1516297094 \
     -d current_term_end=1593541800
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.ImportForItems("__test__8at19S2Bx82rKy")
		.SubscriptionItemItemPriceId(0, "basic-USD")
		.SubscriptionItemQuantity(0, 1)
		.Status(Subscription.StatusEnum.Active)
		.ChargedItemItemPriceId(0, "ssl-charge-USD")
		.ChargedItemLastChargedAt(0, 1516297094)
		.CurrentTermEnd(1593541800)
		.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.ImportForItems("__test__8at19S2Bx82rKy", &subscription.ImportForItemsRequestParams{
        SubscriptionItems : []*subscription.ImportForItemsSubscriptionItemParams{
            {
                ItemPriceId : "basic-USD",
                Quantity : chargebee.Int32(1),
            },
        },
        ChargedItems : []*subscription.ImportForItemsChargedItemParams{
            {
                ItemPriceId : "ssl-charge-USD",
                LastChargedAt : chargebee.Int64(1516297094),
            },
        },
        Status : subscriptionEnum.StatusActive,
        CurrentTermEnd : chargebee.Int64(1593541800),
    }).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.SubscriptionImportForItemsRequest{
    SubscriptionItems : []*chargebee.SubscriptionImportForItemsSubscriptionItem{
        {
            ItemPriceId : "basic-USD",
            Quantity : chargebee.Int32(1),
        },
    },
    ChargedItems : []*chargebee.SubscriptionImportForItemsChargedItem{
        {
            ItemPriceId : "ssl-charge-USD",
            LastChargedAt : chargebee.Int64(1516297094),
        },
    },
    Status : chargebee.SubscriptionStatusActive,
    CurrentTermEnd : chargebee.Int64(1593541800),
}
  res, err := client.Subscription.ImportForItems("__test__8at19S2Bx82rKy", 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.importForItems("__test__8at19S2Bx82rKy")
            .subscriptionItemItemPriceId(0, "basic-USD")
            .subscriptionItemQuantity(0, 1)
            .status(Subscription.Status.ACTIVE)
            .chargedItemItemPriceId(0, "ssl-charge-USD")
            .chargedItemLastChargedAt(0, new Timestamp(1516297094L * 1000))
            .currentTermEnd(new Timestamp(1593541800L * 1000))
            .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.SubscriptionImportForItemsParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionImportForItemsResponse;
import java.sql.Timestamp;
import java.util.List;

public class SubscriptionImportForItems {

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

        SubscriptionImportForItemsParams.SubscriptionItemsParams subscriptionItem0 =
            SubscriptionImportForItemsParams.SubscriptionItemsParams.builder()
                .itemPriceId("basic-USD")
                .quantity(1)
                .build();

        List<SubscriptionImportForItemsParams.SubscriptionItemsParams> subscriptionItemsList =
            List.of(subscriptionItem0);

        SubscriptionImportForItemsParams.ChargedItemsParams chargedItem0 =
            SubscriptionImportForItemsParams.ChargedItemsParams.builder()
                .itemPriceId("ssl-charge-USD")
                .lastChargedAt(new Timestamp(1516297094L * 1000))
                .build();

        List<SubscriptionImportForItemsParams.ChargedItemsParams> chargedItemsList =
            List.of(chargedItem0);

        SubscriptionImportForItemsParams params = SubscriptionImportForItemsParams.builder()
            .subscriptionItems(subscriptionItemsList)
            .status(SubscriptionImportForItemsParams.Status.ACTIVE)
            .chargedItems(chargedItemsList)
            .currentTermEnd(new Timestamp(1593541800L * 1000))
            .build();

        SubscriptionImportForItemsResponse response = client
            .subscriptions()
            .importForItems("__test__8at19S2Bx82rKy", 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.importForItems("__test__8at19S2Bx82rKy", {
        subscription_items: [
            {
                item_price_id: "basic-USD",
                quantity: 1
            }
        ],
        charged_items: [
            {
                item_price_id: "ssl-charge-USD",
                last_charged_at: 1516297094
            }
        ],
        status: "active",
        current_term_end: 1593541800
    });

    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()->importForItems("__test__8at19S2Bx82rKy", [
    "subscription_items" => [
        [
            "item_price_id" => "basic-USD",
            "quantity" => 1
        ]
    ],
    "charged_items" => [
        [
            "item_price_id" => "ssl-charge-USD",
            "last_charged_at" => 1516297094
        ]
    ],
    "status" => "active",
    "current_term_end" => 1593541800
]);
$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_items("__test__8at19S2Bx82rKy",
    cb_client.Subscription.ImportForItemsParams(
        subscription_items=[
            cb_client.Subscription.ImportForItemsSubscriptionItemParams(
              item_price_id="basic-USD",
              quantity=1
            )
        ],
        charged_items=[
            cb_client.Subscription.ImportForItemsChargedItemParams(
              item_price_id="ssl-charge-USD",
              last_charged_at=1516297094
            )
        ],
        status=chargebee.Subscription.Status.ACTIVE,
        current_term_end=1593541800
    )
)
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_items("__test__8at19S2Bx82rKy",{
  :subscription_items => [
    {
      :item_price_id => "basic-USD",
      :quantity => 1
    }
  ],
  :status => "ACTIVE",
  :charged_items => [
    {
      :item_price_id => "ssl-charge-USD",
      :last_charged_at => 1516297094
    }
  ],
  :current_term_end => 1593541800
})

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

### sample subscription for import for items

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__8at19S2Bx82rKy/import_for_items \
     -X POST  \
     -u {site_api_key}:\
     -d status="ACTIVE" \
     -d current_term_end=1593541800 \
     -d "subscription_items[item_price_id][0]"="basic-USD" \
     -d "subscription_items[quantity][0]"=1 \
     -d "charged_items[item_price_id][0]"="ssl-charge-USD" \
     -d "charged_items[last_charged_at][0]"=1516297094 \
     -d "exhausted_coupon_ids[0]"="FESTIVE100"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.ImportForItems("__test__8at19S2Bx82rKy")
		.Status(Subscription.StatusEnum.Active)
		.CurrentTermEnd(1593541800)
		.SubscriptionItemItemPriceId(0, "basic-USD")
		.SubscriptionItemQuantity(0, 1)
		.ChargedItemItemPriceId(0, "ssl-charge-USD")
		.ChargedItemLastChargedAt(0, 1516297094)
		.ExhaustedCouponIds(new List<string>{"FESTIVE100"})
		.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.ImportForItems("__test__8at19S2Bx82rKy", &subscription.ImportForItemsRequestParams{
        SubscriptionItems : []*subscription.ImportForItemsSubscriptionItemParams{
            {
                ItemPriceId : "basic-USD",
                Quantity : chargebee.Int32(1),
            },
        },
        ChargedItems : []*subscription.ImportForItemsChargedItemParams{
            {
                ItemPriceId : "ssl-charge-USD",
                LastChargedAt : chargebee.Int64(1516297094),
            },
        },
        Status : subscriptionEnum.StatusActive,
        CurrentTermEnd : chargebee.Int64(1593541800),
        ExhaustedCouponIds : []string{"FESTIVE100"},
    }).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.SubscriptionImportForItemsRequest{
    SubscriptionItems : []*chargebee.SubscriptionImportForItemsSubscriptionItem{
        {
            ItemPriceId : "basic-USD",
            Quantity : chargebee.Int32(1),
        },
    },
    ChargedItems : []*chargebee.SubscriptionImportForItemsChargedItem{
        {
            ItemPriceId : "ssl-charge-USD",
            LastChargedAt : chargebee.Int64(1516297094),
        },
    },
    Status : chargebee.SubscriptionStatusActive,
    CurrentTermEnd : chargebee.Int64(1593541800),
    ExhaustedCouponIds : []string{"FESTIVE100"},
}
  res, err := client.Subscription.ImportForItems("__test__8at19S2Bx82rKy", 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.importForItems("__test__8at19S2Bx82rKy")
            .status(Subscription.Status.ACTIVE)
            .currentTermEnd(new Timestamp(1593541800L * 1000))
            .subscriptionItemItemPriceId(0, "basic-USD")
            .subscriptionItemQuantity(0, 1)
            .chargedItemItemPriceId(0, "ssl-charge-USD")
            .chargedItemLastChargedAt(0, new Timestamp(1516297094L * 1000))
            .exhaustedCouponIds("FESTIVE100")
            .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.SubscriptionImportForItemsParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionImportForItemsResponse;
import java.sql.Timestamp;
import java.util.List;

public class SubscriptionImportForItems {

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

        SubscriptionImportForItemsParams.SubscriptionItemsParams subscriptionItem0 =
            SubscriptionImportForItemsParams.SubscriptionItemsParams.builder()
                .itemPriceId("basic-USD")
                .quantity(1)
                .build();

        List<SubscriptionImportForItemsParams.SubscriptionItemsParams> subscriptionItemsList =
            List.of(subscriptionItem0);

        SubscriptionImportForItemsParams.ChargedItemsParams chargedItem0 =
            SubscriptionImportForItemsParams.ChargedItemsParams.builder()
                .itemPriceId("ssl-charge-USD")
                .lastChargedAt(new Timestamp(1516297094L * 1000))
                .build();

        List<SubscriptionImportForItemsParams.ChargedItemsParams> chargedItemsList =
            List.of(chargedItem0);

        SubscriptionImportForItemsParams params = SubscriptionImportForItemsParams.builder()
            .status(SubscriptionImportForItemsParams.Status.ACTIVE)
            .currentTermEnd(new Timestamp(1593541800L * 1000))
            .subscriptionItems(subscriptionItemsList)
            .chargedItems(chargedItemsList)
            .exhaustedCouponIds(List.of("FESTIVE100"))
            .build();

        SubscriptionImportForItemsResponse response = client
            .subscriptions()
            .importForItems("__test__8at19S2Bx82rKy", 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.importForItems("__test__8at19S2Bx82rKy", {
        subscription_items: [
            {
                item_price_id: "basic-USD",
                quantity: 1
            }
        ],
        charged_items: [
            {
                item_price_id: "ssl-charge-USD",
                last_charged_at: 1516297094
            }
        ],
        status: "active",
        current_term_end: 1593541800,
        exhausted_coupon_ids: ["FESTIVE100"]
    });

    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()->importForItems("__test__8at19S2Bx82rKy", [
    "subscription_items" => [
        [
            "item_price_id" => "basic-USD",
            "quantity" => 1
        ]
    ],
    "charged_items" => [
        [
            "item_price_id" => "ssl-charge-USD",
            "last_charged_at" => 1516297094
        ]
    ],
    "status" => "active",
    "current_term_end" => 1593541800,
    "exhausted_coupon_ids" => ["FESTIVE100"]
]);
$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_items("__test__8at19S2Bx82rKy",
    cb_client.Subscription.ImportForItemsParams(
        subscription_items=[
            cb_client.Subscription.ImportForItemsSubscriptionItemParams(
              item_price_id="basic-USD",
              quantity=1
            )
        ],
        charged_items=[
            cb_client.Subscription.ImportForItemsChargedItemParams(
              item_price_id="ssl-charge-USD",
              last_charged_at=1516297094
            )
        ],
        status=chargebee.Subscription.Status.ACTIVE,
        current_term_end=1593541800,
        exhausted_coupon_ids=["FESTIVE100"]
    )
)
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_items("__test__8at19S2Bx82rKy",{
  :status => "ACTIVE",
  :current_term_end => 1593541800,
  :subscription_items => [
    {
      :item_price_id => "basic-USD",
      :quantity => 1
    }
  ],
  :charged_items => [
    {
      :item_price_id => "ssl-charge-USD",
      :last_charged_at => 1516297094
    }
  ],
  :exhausted_coupon_ids => ["FESTIVE100"]
})

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": 1517505319,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "John",
    "id": "__test__8asukSOXdvWPP6",
    "last_name": "Doe",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505319325,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505319
  },
  "subscription": {
    "activated_at": 1517505319,
    "billing_period": 1,
    "billing_period_unit": "month",
    "charged_items": [
      {
        "item_price_id": "ssl-charge-USD",
        "last_charged_at": 1516295719,
        "object": "charged_item"
      },
      {..}
    ],
    "created_at": 1517505319,
    "currency_code": "USD",
    "current_term_end": 1614018600,
    "current_term_start": 1517505319,
    "customer_id": "__test__8asukSOXdvWPP6",
    "deleted": false,
    "due_invoices_count": 0,
    "has_scheduled_changes": false,
    "id": "__test__8asukSOXdvbfP9",
    "mrr": 0,
    "next_billing_at": 1614018600,
    "object": "subscription",
    "resource_version": 1517505319739,
    "started_at": 1517505319,
    "status": "active",
    "subscription_items": [
      {
        "amount": 1000,
        "free_quantity": 0,
        "item_price_id": "basic-USD",
        "item_type": "plan",
        "object": "subscription_item",
        "quantity": 1,
        "unit_price": 1000
      },
      {..}
    ],
    "updated_at": 1517505319
  }
}
```

## URL Format

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

## Input Parameters

- `exhausted_coupon_ids` (optional, string, max chars=100)
  Specifies the IDs of [coupons](/docs/api/coupons) to be marked as exhausted. This parameter accepts a list of IDs, which must correspond to coupons with a `[duration_type](/docs/api/coupons/coupon-object#duration_type)` of `one_time`. Ensure that the IDs included in this parameter do not match any IDs provided in the `[coupon_ids](/docs/api/subscriptions/import-subscription-for-items#coupon_ids)` parameter.

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

- `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)
  The number of billing cycles the subscription runs before canceling. If not provided, then the billing cycles [set for the plan-item price](/docs/api/item_prices/item_price-object#billing_cycles) is used.

- `net_term_days` (optional, integer)
  Defines [Net D](https://www.chargebee.com/docs/net_d.html) 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](https://www.chargebee.com/docs/net_d.html#enable-net-d-for-chargebee-invoices).
  -   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](/docs/api/customers/customer-object#net_term_days) is considered. .

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

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

- `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.
  -   You may pass `transaction` details to record an offline payment against that invoice.

- `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 set of key-value pairs stored as additional information for the subscription. [Learn more](/docs/api/subscriptions) .

- `cancel_reason_code` (optional, string, max chars=100)
  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.

- `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](/docs/api/subscriptions/create-subscription-for-items#create_pending_invoices)/[update](/docs/api/subscriptions/update-subscription-for-items#create_pending_invoices) 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](https://www.chargebee.com/docs/charges.html) 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](https://www.chargebee.com/docs/metered_billing.html) is enabled for the site .

- `auto_close_invoices` (optional, boolean)
  Set to `false` to override for this subscription, the [site-level setting](https://www.chargebee.com/docs/billing/2.0/usage-based-billing/metered_billing#configuring-metered-billing) 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](/docs/api/customers/customer-object#auto_close_invoices) .

- `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.
  - `payment_method` (optional, enumerated string)
    The payment method of this transaction. This parameter should be passed only if the invoice is created for the current term.
    Possible enum values:
      - `cash`
        Cash
      - `check`
        Check
      - `bank_transfer`
        Bank Transfer
      - `other`
        Payment methods other than the named types above.
      - `custom`
        Custom
      - `dana`
      - `touch_n_go`
      - `tamara`
      - `qpay`
      - `ovo`
      - `momo`
      - `mercado_pago`
      - `nequi`
      - `nupay`
      - `picpay`
      - `thai_qr`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
      - `rakuten_pay`
  - `reference_number` (optional, string, max chars=100)
    The reference number for this transaction. For example, check number when `payment_method` is `check`.
  - `date` (optional, timestamp(UTC) in seconds)
    The date of occurrence of the transaction.

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

- `subscription_items` (optional, array)
  Parameters for subscription\_items
  - `item_price_id` (required, string, max chars=100)
    The unique identifier of the [item price](/docs/api/item_prices) in Chargebee. At least one entry is required to import the subscription.
  - `quantity` (optional, integer)
    The quantity of the item purchased
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the item purchased. Can be provided for quantity-based item prices and only when [multi-decimal pricing](/docs/api/getting-started) is enabled.
  - `unit_price` (optional, in cents)
    The price or per-unit price of the item. When not provided, [the value set](/docs/api/item_prices/item-price-object) for the item price is used.
  - `unit_price_in_decimal` (optional, string, max chars=39)
    When [price overriding](https://www.chargebee.com/docs/2.0/price-override.html) is enabled for the site, the price or per-unit price of the item can be set here. The [value set for the item price](/docs/api/item_prices/item_price-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/getting-started) is enabled.
  - `billing_cycles` (optional, integer)
    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](/docs/api/item_prices/item-price-object) for the plan-item price is used.
    
    For addon-item prices: If [addon billing cycles](https://www.chargebee.com/docs/2.0/addons-billingcycle.html) 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](/docs/api/attached_items/attached-item-object) is used. Further, if that value is not provided, then [the value set for the addon-item price](/docs/api/item_prices/item-price-object) is used.
  - `trial_end` (optional, timestamp(UTC) in seconds)
    The date/time when the trial period of the item ends. Applies to plan-items and--when [enabled](https://www.chargebee.com/docs/2.0/addons-trial.html) --addon-items as well.
  - `service_period_days` (optional, integer)
    The service period of the item in days from the day of charge.
  - `charge_on_event` (optional, enumerated string)
    When `charge_on_option` option is set to `on_event` , this parameter specifies the event at which the charge-item is applied to the subscription. This parameter only applies to charge-items.
    Possible enum values:
      - `subscription_creation`
        the time of creation of the subscription.
      - `subscription_trial_start`
        the time when the trial period of the subscription begins.
      - `plan_activation`
        same as subscription activation, but also includes the case when the plan-item of the subscription is changed.
      - `subscription_activation`
        the moment a subscription enters an `active` or `non-renewing` state. Also includes reactivations of canceled subscriptions.
      - `contract_termination`
        when a contract term is [terminated](/docs/api/subscriptions/cancel-subscription-for-items#contract_term_cancel_option) .
  - `charge_once` (optional, boolean)
    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.
  - `description` (optional, string, max chars=500)
    **Limited availability**
    
    Subscription-level item descriptions are available only on sites where this feature is enabled. Please reach out to the Chargebee [support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=support) to enable this feature.
    
    A description for this item that applies only to this subscription. When set, it is used on the customer-facing invoice instead of the description configured for the item price, and is returned as `entity_description` on the invoice [line item](/docs/api/invoices/invoice-object#invoice_line_items). When not set, the description configured for the item price is used.
    
    **Constraints**
    
    -   Maximum 500 characters.
    -   Whether a description is shown on the invoice at all continues to be controlled by the item price's [show\_description\_in\_invoices](/docs/api/item_prices#show_description_in_invoices) setting. This parameter determines which description is shown, not whether one is shown.

- `discounts` (optional, array)
  Parameters for discounts
  - `apply_on` (optional, enumerated string)
    The amount on the invoice to which the discount is applied.
    Possible enum values:
      - `invoice_amount`
        The discount is applied to the invoice `sub_total` .
      - `specific_item_price`
        The discount is applied to the `invoice.line_item.amount` that corresponds to the item price specified by `item_price_id` .
  - `duration_type` (required, enumerated string)
    Specifies the time duration for which this discount is attached to the subscription.
    Possible enum values:
      - `one_time`
        The discount stays attached to the subscription till it is applied on an invoice **once**. It is removed after that from the subscription.
      - `forever`
        The discount is attached to the subscription and applied on the invoices till it is [explicitly removed](/docs/api/subscriptions/update-subscription-for-items#discounts_operation_type) .
      - `limited_period`
        The discount is attached to the subscription and applied on the invoices for a limited duration. This duration starts from the point it is applied to an invoice for the first time and expires after a period specified by `period` and `period_unit` .
  - `percentage` (optional, double)
    The percentage of the original amount that should be deducted from it.
  - `amount` (optional, in cents)
    The value of the discount. [The format of this value](/docs/api/currencies) depends on the kind of currency.
  - `period` (optional, integer)
    The duration of time for which the discount is attached to the subscription, in `period_units`. Applicable only when `duration_type` is `limited_period`.
  - `period_unit` (optional, enumerated string)
    The unit of time for `period`. Applicable only when `duration_type` is `limited_period`.
    Possible enum values:
      - `day`
        A period of 24 hours.
      - `week`
        A period of 7 days.
      - `month`
        A period of 1 calendar month.
      - `year`
        A period of 1 calendar year.
  - `included_in_mrr` (optional, boolean)
    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](https://www.chargebee.com/docs/reporting.html#dashboards_flexible-mrr-calculation) in Chargebee. Also, If the [site-level setting](https://www.chargebee.com/docs/reporting.html#chart_flexible-mrr-calculation) is to exclude one-time discounts from MRR calculations, this value is always returned `false`.
  - `item_price_id` (optional, string, max chars=100)
    The [id of the item price](/docs/api/subscriptions/subscription-object#subscription_items_item_price_id) in the subscription to which the discount is to be applied.
  - `quantity` (optional, integer)
    Specifies the number of free units provided for the item, without affecting the total quantity sold

- `charged_items` (optional, array)
  Parameters for charged\_items
  - `item_price_id` (optional, string, max chars=100)
    Identifier of the [`charge` item price](/docs/api/item_prices) that was already charged for this subscription.
  - `last_charged_at` (optional, timestamp(UTC) in seconds)
    Timestamp when this charge item price was last charged for this subscription in the source system.

- `item_tiers` (optional, array)
  Parameters for item\_tiers
  - `item_price_id` (optional, string, max chars=100)
    The id of the item price for which the tier price is being overridden.
  - `starting_unit` (optional, integer)
    The lowest value in the quantity tier.
  - `ending_unit` (optional, integer)
    The highest value in the quantity tier.
  - `price` (optional, in cents)
    The overridden price of the tier. The value depends on the [type of currency](/docs/api/subscriptions) .
  - `starting_unit_in_decimal` (optional, string, max chars=33)
    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](/docs/api/getting-started) is enabled.
  - `ending_unit_in_decimal` (optional, string, max chars=33)
    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](/docs/api/getting-started) is enabled.
  - `price_in_decimal` (optional, string, max chars=39)
    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](/docs/api/getting-started) is enabled.
  - `pricing_type` (optional, enumerated string)
    Pricing type for the tier.
    Possible enum values:
      - `per_unit`
        Indicates that the tier pricing is based on individual units. Customers are charged a fixed price per unit. For example, if the price per unit is $2 and the customer consumes 150 units, they will be charged $300 (150 × $2).
      - `flat_fee`
        Indicates that the tier pricing is a flat fee, applied to the entire tier regardless of the number of units consumed. For the **stairstep** pricing model, `pricing_type` will be set to `flat_fee` by default. For example, if the flat fee for a tier is $100, the customer pays $100 whether they consume 1 unit or the maximum number of units within that tier.
      - `package`
        Indicates that the tier pricing is based on a package of units. Customers are charged for each block or package of units. For example, if the package size is 100 units and the cost per block is $20 consuming 400 units will result in a charge of $80 (4 × $20).
  - `package_size` (optional, integer)
    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.

## 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
