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

**Note:** This operation optionally supports 3DS verification flow. To achieve the same, create the [Payment Intent](/docs/api/getting-started) and pass it as input parameter to this API.

Creates a new subscription for an existing customer. You can attach a plan, plan quantity, one or more addons and coupon while creating this subscription.

If the plan does not have a trial period and if any of the recurring-item has charges, then the customer is charged immediately if auto\_collection is turned 'on'. In that case, subscription is created only if the customer has a payment method on file and attempted payment is successful.

If an invoice gets generated during this operation, available Credits and Excess Payments will be automatically applied.

## Sample Request

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWkmi22UR/subscriptions \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d "shipping_address[first_name]"="Mark" \
     -d "shipping_address[last_name]"="Henry" \
     -d "shipping_address[company]"="chargebee" \
     -d start_date=1600968050
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.CreateForCustomer("__test__KyVnHhSBWkmi22UR")
		.PlanId("no_trial")
		.ShippingAddressFirstName("Mark")
		.ShippingAddressLastName("Henry")
		.ShippingAddressCompany("chargebee")
		.StartDate(1600968050)
		.Request();

Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Card card = result.Card;
Invoice invoice = result.Invoice;
List<UnbilledCharge> unbilledCharges = result.UnbilledCharges;
```

#### 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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.CreateForCustomer("__test__KyVnHhSBWkmi22UR", &subscription.CreateForCustomerRequestParams{
        PlanId : "no_trial",
        ShippingAddress : &subscription.CreateForCustomerShippingAddressParams{
            FirstName : "Mark",
            LastName : "Henry",
            Company : "chargebee",
        },
        StartDate : chargebee.Int64(1600968050),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
    }
}
```

#### 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.SubscriptionCreateForCustomerRequest{
    PlanId : "no_trial",
    ShippingAddress : &chargebee.SubscriptionCreateForCustomerShippingAddress{
        FirstName : "Mark",
        LastName : "Henry",
        Company : "chargebee",
    },
    StartDate : chargebee.Int64(1600968050),
}
  res, err := client.Subscription.CreateForCustomer("__test__KyVnHhSBWkmi22UR", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.util.List;
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.createForCustomer("__test__KyVnHhSBWkmi22UR")
            .planId("no_trial")
            .shippingAddressFirstName("Mark")
            .shippingAddressLastName("Henry")
            .shippingAddressCompany("chargebee")
            .startDate(new Timestamp(1600968050L * 1000))
            .request();

        Subscription subscription = result.subscription();
        Customer customer = result.customer();
        Card card = result.card();
        Invoice invoice = result.invoice();
        List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    }
}
```

#### 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.SubscriptionCreateForCustomerParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionCreateForCustomerResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.sql.Timestamp;
import java.util.List;

public class SubscriptionCreateForCustomer {

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

        SubscriptionCreateForCustomerParams.ShippingAddressParams shippingAddressParams =
            SubscriptionCreateForCustomerParams.ShippingAddressParams.builder()
                .firstName("Mark")
                .lastName("Henry")
                .company("chargebee")
                .build();

        SubscriptionCreateForCustomerParams params = SubscriptionCreateForCustomerParams.builder()
            .planId("no_trial")
            .shippingAddress(shippingAddressParams)
            .startDate(new Timestamp(1600968050L * 1000))
            .build();

        SubscriptionCreateForCustomerResponse response = client
            .subscriptions()
            .createForCustomer("__test__KyVnHhSBWkmi22UR", params);

        Subscription subscription = response.getSubscription();
        Customer customer = response.getCustomer();
        Card card = response.getCard();
        Invoice invoice = response.getInvoice();
        List<UnbilledCharge> unbilledCharges = response.getUnbilledCharges();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.subscription.createForCustomer("__test__KyVnHhSBWkmi22UR", {
        plan_id: "no_trial",
        shipping_address: {
            first_name: "Mark",
            last_name: "Henry",
            company: "chargebee"
        },
        start_date: 1600968050
    });

    console.log(result);
    const subscription = result.subscription;
    const customer = result.customer;
    const card = result.card;
    const invoice = result.invoice;
    const unbilledCharges = result.unbilled_charges;
} 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()->createForCustomer("__test__KyVnHhSBWkmi22UR", [
    "plan_id" => "no_trial",
    "shipping_address" => [
        "first_name" => "Mark",
        "last_name" => "Henry",
        "company" => "chargebee"
    ],
    "start_date" => 1600968050
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.create_for_customer("__test__KyVnHhSBWkmi22UR",
    cb_client.Subscription.CreateForCustomerParams(
        plan_id="no_trial",
        shipping_address=cb_client.Subscription.CreateForCustomerShippingAddressParams(
            first_name="Mark",
            last_name="Henry",
            company="chargebee"
        ),
        start_date=1600968050
    )
)
subscription = response.subscription
customer = response.customer
card = response.card
invoice = response.invoice
unbilled_charges = response.unbilled_charges
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Subscription.create_for_customer("__test__KyVnHhSBWkmi22UR",{
  :plan_id => "no_trial",
  :shipping_address => {
    :first_name => "Mark",
    :last_name => "Henry",
    :company => "chargebee"
  },
  :start_date => 1600968050
})

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

### creates a subscription for customer with addons and coupons.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWkn672UW/subscriptions \
     -X POST  \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d "addons[id][0]"="day-pass" \
     -d "addons[quantity][0]"=2 \
     -d "addons[id][1]"="ssl" \
     -d "coupon_ids[0]"="plan_only_coupon" \
     -d "coupon_ids[1]"="plan_quantity_coupon"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.CreateForCustomer("__test__KyVnHhSBWkn672UW")
		.PlanId("no_trial")
		.AddonId(0, "day-pass")
		.AddonQuantity(0, 2)
		.AddonId(1, "ssl")
		.CouponIds(new List<string>{"plan_only_coupon", "plan_quantity_coupon"})
		.Request();

Subscription subscription = result.Subscription;
Customer customer = result.Customer;
Card card = result.Card;
Invoice invoice = result.Invoice;
List<UnbilledCharge> unbilledCharges = result.UnbilledCharges;
```

#### 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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.CreateForCustomer("__test__KyVnHhSBWkn672UW", &subscription.CreateForCustomerRequestParams{
        Addons : []*subscription.CreateForCustomerAddonParams{
            {
                Id : "day-pass",
                Quantity : chargebee.Int32(2),
            },
            {
                Id : "ssl",
            },
        },
        PlanId : "no_trial",
        CouponIds : []string{"plan_only_coupon", "plan_quantity_coupon"},
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
    }
}
```

#### 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.SubscriptionCreateForCustomerRequest{
    Addons : []*chargebee.SubscriptionCreateForCustomerAddon{
        {
            Id : "day-pass",
            Quantity : chargebee.Int32(2),
        },
        {
            Id : "ssl",
        },
    },
    PlanId : "no_trial",
    CouponIds : []string{"plan_only_coupon", "plan_quantity_coupon"},
}
  res, err := client.Subscription.CreateForCustomer("__test__KyVnHhSBWkn672UW", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
        Customer := res.Customer
        Card := res.Card
        Invoice := res.Invoice
        UnbilledCharges := res.UnbilledCharges
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.util.List;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.createForCustomer("__test__KyVnHhSBWkn672UW")
            .planId("no_trial")
            .addonId(0, "day-pass")
            .addonQuantity(0, 2)
            .addonId(1, "ssl")
            .couponIds("plan_quantity_coupon")
            .request();

        Subscription subscription = result.subscription();
        Customer customer = result.customer();
        Card card = result.card();
        Invoice invoice = result.invoice();
        List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    }
}
```

#### 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.SubscriptionCreateForCustomerParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionCreateForCustomerResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;

public class SubscriptionCreateForCustomer {

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

        SubscriptionCreateForCustomerParams.AddonsParams addon0 =
            SubscriptionCreateForCustomerParams.AddonsParams.builder()
                .id("day-pass")
                .quantity(2)
                .build();

        SubscriptionCreateForCustomerParams.AddonsParams addon1 =
            SubscriptionCreateForCustomerParams.AddonsParams.builder()
                .id("ssl")
                .build();

        List<SubscriptionCreateForCustomerParams.AddonsParams> addonsList =
            List.of(addon0, addon1);

        SubscriptionCreateForCustomerParams params = SubscriptionCreateForCustomerParams.builder()
            .planId("no_trial")
            .addons(addonsList)
            .couponIds(List.of("plan_quantity_coupon"))
            .build();

        SubscriptionCreateForCustomerResponse response = client
            .subscriptions()
            .createForCustomer("__test__KyVnHhSBWkn672UW", params);

        Subscription subscription = response.getSubscription();
        Customer customer = response.getCustomer();
        Card card = response.getCard();
        Invoice invoice = response.getInvoice();
        List<UnbilledCharge> unbilledCharges = response.getUnbilledCharges();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.subscription.createForCustomer("__test__KyVnHhSBWkn672UW", {
        addons: [
            {
                id: "day-pass",
                quantity: 2
            },
            {
                id: "ssl"
            }
        ],
        plan_id: "no_trial",
        coupon_ids: ["plan_only_coupon", "plan_quantity_coupon"]
    });

    console.log(result);
    const subscription = result.subscription;
    const customer = result.customer;
    const card = result.card;
    const invoice = result.invoice;
    const unbilledCharges = result.unbilled_charges;
} 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()->createForCustomer("__test__KyVnHhSBWkn672UW", [
    "addons" => [
        [
            "id" => "day-pass",
            "quantity" => 2
        ],
        [
            "id" => "ssl"
        ]
    ],
    "plan_id" => "no_trial",
    "coupon_ids" => ["plan_only_coupon", "plan_quantity_coupon"]
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.create_for_customer("__test__KyVnHhSBWkn672UW",
    cb_client.Subscription.CreateForCustomerParams(
        addons=[
            cb_client.Subscription.CreateForCustomerAddonParams(
              id="day-pass",
              quantity=2
            ),
            cb_client.Subscription.CreateForCustomerAddonParams(
              id="ssl"
            )
        ],
        plan_id="no_trial",
        coupon_ids=["plan_only_coupon", "plan_quantity_coupon"]
    )
)
subscription = response.subscription
customer = response.customer
card = response.card
invoice = response.invoice
unbilled_charges = response.unbilled_charges
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Subscription.create_for_customer("__test__KyVnHhSBWkn672UW",{
  :plan_id => "no_trial",
  :addons => [
    {
      :id => "day-pass",
      :quantity => 2
    },
    {
      :id => "ssl"
    }
  ],
  :coupon_ids => ["plan_only_coupon", "plan_quantity_coupon"]
})

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

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "off",
    "card_status": "no_card",
    "created_at": 1517505650,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "Mark",
    "id": "__test__KyVnHhSBWkmi22UR",
    "last_name": "Henry",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505650000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505650
  },
  "subscription": {
    "billing_period": 1,
    "billing_period_unit": "month",
    "created_at": 1517505650,
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWkmi22UR",
    "deleted": false,
    "due_invoices_count": 0,
    "has_scheduled_changes": false,
    "id": "__test__KyVnHhSBWkmjz2UT",
    "next_billing_at": 1600968050,
    "object": "subscription",
    "plan_amount": 895,
    "plan_free_quantity": 0,
    "plan_id": "no_trial",
    "plan_quantity": 1,
    "plan_unit_price": 895,
    "resource_version": 1517505650000,
    "shipping_address": {
      "company": "chargebee",
      "first_name": "Mark",
      "last_name": "Henry",
      "object": "shipping_address",
      "validation_status": "not_validated"
    },
    "start_date": 1600968050,
    "status": "future",
    "updated_at": 1517505650
  }
}
```

## URL Format

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

## 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)
  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](/docs/api/v2/pcv-1/contract_terms) 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](/docs/api/v2/pcv-1/plans/plan-object#billing_cycles) 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_addons_to_remove` (optional, string, max chars=100)
  List of addons IDs that are mandatory to the plan and has to be removed from the subscription.

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

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

- `terms_to_charge` (optional, integer, min=1)
  The number of subscription billing cycles (including the first one) to [invoice in advance](https://www.chargebee.com/docs/advance-invoices.html) .

- `billing_alignment_mode` (optional, enumerated string)
  Override the [billing alignment mode](https://www.chargebee.com/docs/calendar-billing.html#alignment-of-billing-date) 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
    - `sepa_credit`
      SEPA Credit
    - `boleto`
      Boleto
    - `us_automated_bank_transfer`
      US Automated Bank Transfer
    - `eu_automated_bank_transfer`
      EU Automated Bank Transfer
    - `uk_automated_bank_transfer`
      UK Automated Bank Transfer
    - `jp_automated_bank_transfer`
      JP Automated Bank Transfer
    - `mx_automated_bank_transfer`
      MX Automated Bank Transfer
    - `custom`
      Custom

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

- `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](/docs/api/customers/customer-object#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](/docs/api/invoices/invoice-object#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](/docs/api/v2/pcv-1/advanced-features) .

- `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](https://www.chargebee.com/docs/unbilled-charges.html). The default value is as per the [site settings](https://www.chargebee.com/docs/unbilled-charges.html#configuration) .
  
  **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](/docs/api/v2/pcv-1/plans/create-a-plan#period_unit) attribute of the [plan](/docs/api/v2/pcv-1/subscriptions/create-a-subscription#plan_id) 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](https://www.chargebee.com/docs/contract-terms.html#configuring-contract-terms) .

- `trial_end_action` (optional, enumerated string)
  Applicable only when [End-of-trial Action](https://www.chargebee.com/docs/1.0/trial_periods_hidden.html#how-to-define-the-end-of-trial-actions-for-subscriptions) 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. This is the default value. The action [configured for the site](https://www.chargebee.com/docs/1.0/trial_periods_hidden.html#how-to-define-the-end-of-trial-actions-for-subscriptions) at the time when the trial ends, takes effect.
    - `plan_default`
      The action [configured for the site](https://www.chargebee.com/docs/1.0/trial_periods_hidden.html#how-to-define-the-end-of-trial-actions-for-subscriptions) 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
  - `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.

- `statement_descriptor` (optional, string)
  Parameters for statement\_descriptor
  - `descriptor` (optional, string, max chars=65k)
    Payment transaction descriptor text to help your customer easily recognize the transaction. When this value is passed this will override the [transaction descriptor](https://www.chargebee.com/docs/1.0/transaction_descriptors.html) text configured in the Chargebee site for all the subscription renewal transactions.

- `payment_intent` (optional, string)
  Parameters for payment\_intent
  - `id` (optional, string, max chars=150)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
  - `gateway_account_id` (required if payment intent token provided, string, max chars=50)
    The gateway account used for performing the 3DS flow.
  - `gw_token` (optional, string, max chars=65k)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer [3DS implementation in Chargebee](/docs/api/3ds_card_payments) to find out the gateway-specific gw\_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
  - `payment_method_type` (optional, enumerated string)
    The list of payment method types (For example, card, ideal, sofort, bancontact, etc.) this Payment Intent is allowed to use. If payment method type is empty, Card is taken as the default type for all gateways except Razorpay.
    Possible enum values:
      - `card`
        card
      - `ideal`
        ideal
      - `sofort`
        sofort
      - `bancontact`
        bancontact
      - `google_pay`
        google\_pay
      - `dotpay`
        dotpay
      - `giropay`
        giropay
      - `apple_pay`
        apple\_pay
      - `upi`
        upi
      - `netbanking_emandates`
        netbanking\_emandates
      - `paypal_express_checkout`
        paypal\_express\_checkout
      - `direct_debit`
        direct\_debit
      - `boleto`
        boleto
      - `venmo`
        Venmo
      - `amazon_payments`
        Amazon Payments
      - `pay_to`
        PayTo
      - `faster_payments`
        Faster Payments
      - `sepa_instant_transfer`
        Sepa Instant Transfer
      - `klarna_pay_now`
        Klarna Pay Now
      - `online_banking_poland`
        Online Banking Poland
      - `payconiq_by_bancontact`
        Payments made via Payconiq by Bancontact.
      - `electronic_payment_standard`
        Electronic Payment Standard
      - `kbc_payment_button`
        KBC Payment Button
      - `pay_by_bank`
        Pay By Bank
      - `trustly`
        Trustly
      - `stablecoin`
        Payments made via Stablecoin.
      - `kakao_pay`
        Payments made via Kakao Pay.
      - `naver_pay`
        Payments made via Naver Pay.
      - `revolut_pay`
        Payments made via Revolut Pay.
      - `cash_app_pay`
        Payments made via Cash App Pay.
      - `wechat_pay`
        Payments made via WeChat Pay.
      - `alipay`
        Payments made via Alipay.
      - `twint`
        Payments made via Twint
      - `go_pay`
        Payments made via GoPay
      - `grab_pay`
        Payments made via GrabPay
      - `pay_co`
        Payments made via PayCo
      - `after_pay`
        Payments made via Afterpay
      - `swish`
        Payments made via Swish
      - `payme`
        Payments made via PayMe
      - `pix`
        Pix
      - `klarna`
        Payments made via Klarna.
      - `alipay_hk`
        Payments made via Alipay HK.
      - `paypay`
        PayPay
      - `gcash`
        Payments made via GCash.
      - `south_korean_cards`
        Payments made via South Korean Cards
      - `paynow`
      - `bizum`
      - `promptpay`
      - `dana`
        Payments made via Dana.
      - `touch_n_go`
        Payments made via Touch 'n Go.
      - `tamara`
        Payments made via Tamara.
      - `qpay`
        Payments made via Qpay.
      - `ovo`
      - `momo`
      - `mercado_pago`
      - `nequi`
      - `nupay`
      - `picpay`
      - `thai_qr`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
      - `rakuten_pay`
  - `reference_id` (optional, string, max chars=65k)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
  - `additional_information` (optional, jsonobject)
    -   `checkout_com`: While adding a new payment method using [permanent token](/docs/api/payment_sources/create-using-permanent-token) or passing raw card details to Checkout.com, `document` ID and `country_of_residence` are required to support payments through [dLocal](https://www.checkout.com/docs/previous/payments/payment-methods/cards/dlocal).
        
        -   `payer`: User related information.
            -   `country_of_residence`: This is required since the billing country associated with the user's payment method may not be the same as their country of residence. Hence the user's country of residence needs to be specified. The country code should be a [two-character ISO code](https://docs.checkout.com/resources/codes/country-codes).
            -   `document`: Document ID is the user's [identification number](https://docs.dlocal.com/api-documentation/payins-api-reference/country-reference#documents) based on their country.
    -   `bluesnap`: While passing raw card details to BlueSnap, if `fraud_session_id` is added, [additional validation](https://developers.bluesnap.com/docs/fraud-prevention) is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your [BlueSnap fraud session ID](https://developers.bluesnap.com/docs/fraud-prevention#section-implementing-device-data-collector) required to perform anti-fraud validation.
    -   `braintree`: While passing raw card details to Braintree, your `fraud_merchant_id` and the user's `device_session_id` can be added to perform [additional validation](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
            -   `fraud_merchant_id`: Your [merchant ID](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) for fraud detection.
    -   `chargebee_payments`: While passing raw card details to Chargebee Payments, if `fraud_session_id` is added, additional validation is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your Chargebee Payments fraud session ID required to perform anti-fraud validation.
    -   `bank_of_america`: While passing raw card details to Bank of America, your user's `device_session_id` can be added to perform additional validation and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
    -   `ecentric`: This parameter is used to verify and process payment method details in Ecentric. If the `merchant_id` parameter is included, Chargebee will vault it / perform a lookup and verification against this `merchant_id`, overriding the one configured in Chargebee. If tokens and processing occur in the same Merchant GUID, you can just skip this part.
        
        -   `merchant_id`: Merchant GUID where the card is vaulted or need to be vaulted.
    -   `ebanx`: While passing raw card details to EBANX, the user's `document` is required for some countries and `device_session_id` can be added to perform [additional validation](https://developer.ebanx.com/docs/payments/guides/features/device-fingerprint#device-fingerprint) and avoid fraudulent transactions.
        
        -   `payer`: User related information.
            -   `document`: Document is the user's identification number based on their country.
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device

- `contract_term` (optional, enumerated string)
  Parameters for contract\_term
  - `action_at_term_end` (optional, enumerated string)
    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.
  - `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.

- `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)
    Sub Item Plan Unit Amount for create subscription
  - `unit_price_in_decimal` (optional, string, max chars=39)
    Sub Item Plan Unit Amount in Decimal for create subscription
  - `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.
  - `trial_end` (optional, timestamp(UTC) in seconds)
    The time at which the trial ends for the addon. This value can only be set for subscriptions that start with an `active` or `non-renewing` status. Once set, the value can't be changed. (Addon trial periods must be enabled by [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) )

- `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.
  - `charge_on` (optional, enumerated string)
    Indicates when the non-recurring addon will be charged.
    Possible enum values:
      - `immediately`
        Charges for the addon will be applied immediately.
      - `on_event`
        Charge for the addon will be applied on the occurrence of a specified event.

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

- `unbilled_charges` (optional)
  Resource object representing unbilled\_charge
