# Create a subscription

> 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 along with the customer. You can attach a plan, plan quantity, one or more addons and coupon while creating this subscription.

#### Future Subscriptions[](#future-subscriptions)

If the **start\_date** is specified, the subscription will be created in 'future' state (.ie, instead of starting immediately it will be scheduled to start at the specified 'start\_date'). Besides if 'trial' is specified (plan configuration or specified explicitly using trial\_end), the subscription will go into 'trial' state when it starts. Otherwise it will directly become 'active' when it starts.

#### Trial Period[](#trial-period)

If the plan has trial period or if the trial\_end is specified explicitly, the subscription will be created in 'in\_trial' state.

If the card details are passed, it is not charged until the end of the trial period. Incase you need to verify the card you could enable the ['card verification option'](https://www.chargebee.com/docs/cards.html#card-verification) in the gateway settings.

#### Invoice[](#invoice)

If the plan does not have a trial period and if any of the recurring items has charges, then a invoice would be raised immediately. If 'auto\_collection' is turned 'on', then card attributes are mandatory and subscription will be created only if the payment was successful.

#### Card details[](#card-details)

Passing card details to this API involves PCI liability at your end as sensitive card information passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable

-   If you are using Stripe gateway, you can use [Stripe.js](https://stripe.com/docs/stripe.js) with your checkout form. Take a look at this [Stripe tutorial](https://stripe.com/docs/payments/accept-a-payment-charges) for more details.
-   If you are using Braintree gateway, you can use [Braintree.js](https://www.braintreepayments.com/docs/javascript) with your checkout form. Please refer this [tutorial](https://www.chargebee.com/tutorials/braintree-js-example.html) for more details.
-   If you are using Authorize.Net gateway, you use [Accept.js](https://developer.authorize.net/api/reference/features/acceptjs.html) with your checkout form.
-   In case you are using the Adyen gateway, you will have to use the Adyen's [Client Side Encryption](https://docs.adyen.com/online-payments/classic-integrations/api-integration-ecommerce/cse-integration-ecommerce) to encrypt sensitive cardholder data. Once the cardholder data is encrypted, pass the value in adyen.encrypted.data as temp token in this API. You can also use our [Hosted Pages](https://www.chargebee.com/docs/billing/2.0/hosted-capabilities/hosted-capabilities) based integration.

**Legacy behavior:**

-   **For [sites](https://www.chargebee.com/docs/sites-intro.html) created before March 1st, 2014:** On making this request, the `billing_address` and `vat_number` of the customer are **deleted** and replaced by the values passed with this request. Ensure that you pass the [billing address parameters](/docs/api/v2/pcv-1/subscriptions/create-a-subscription#card_billing_addr1) and the `vat_number` parameters each time you make this request, to avoid losing the same information at the customer-level.
-   **For [sites](https://www.chargebee.com/docs/sites-intro.html) created on or after March 1st, 2014:** This request does not alter the `billing_address` and `vat_number` of the customer.

#### Related Tutorials[](#related-tutorials)

-   [Check out this tutorial to create trial signup with custom fields.](https://www.chargebee.com/tutorials/custom-fields-recurring-billing-example.html)
-   [Learn how to implement a in-app checkout flow that allows your customers to select addons and apply coupons. Estimate API is used to dynamically calculate the order summary shown to the customer.](https://www.chargebee.com/tutorials/in-app-checkout-page-using-estimate-api-example.html)

## Sample Request

### creates a subscription with customer information and billing details.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d auto_collection="OFF" \
     -d "customer[first_name]"="John" \
     -d "customer[last_name]"="Doe" \
     -d "customer[email]"="john@user.com" \
     -d "billing_address[first_name]"="John" \
     -d "billing_address[last_name]"="Doe" \
     -d "billing_address[line1]"="PO Box 9999" \
     -d "billing_address[city]"="Walnut" \
     -d "billing_address[state]"="California" \
     -d "billing_address[zip]"="91789" \
     -d "billing_address[country]"="US"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.Create()
		.PlanId("no_trial")
		.AutoCollection(AutoCollectionEnum.Off)
		.CustomerFirstName("John")
		.CustomerLastName("Doe")
		.CustomerEmail("john@user.com")
		.BillingAddressFirstName("John")
		.BillingAddressLastName("Doe")
		.BillingAddressLine1("PO Box 9999")
		.BillingAddressCity("Walnut")
		.BillingAddressState("California")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.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"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Create(&subscription.CreateRequestParams{
        PlanId : "no_trial",
        AutoCollection : enum.AutoCollectionOff,
        Customer : &subscription.CreateCustomerParams{
            FirstName : "John",
            LastName : "Doe",
            Email : "john@user.com",
        },
        BillingAddress : &subscription.CreateBillingAddressParams{
            FirstName : "John",
            LastName : "Doe",
            Line1 : "PO Box 9999",
            City : "Walnut",
            State : "California",
            Zip : "91789",
            Country : "US",
        },
    }).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.SubscriptionCreateRequest{
    PlanId : "no_trial",
    AutoCollection : chargebee.AutoCollectionOff,
    Customer : &chargebee.SubscriptionCreateCustomer{
        FirstName : "John",
        LastName : "Doe",
        Email : "john@user.com",
    },
    BillingAddress : &chargebee.SubscriptionCreateBillingAddress{
        FirstName : "John",
        LastName : "Doe",
        Line1 : "PO Box 9999",
        City : "Walnut",
        State : "California",
        Zip : "91789",
        Country : "US",
    },
}
  res, err := client.Subscription.Create(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.create()
            .planId("no_trial")
            .autoCollection(AutoCollection.OFF)
            .customerFirstName("John")
            .customerLastName("Doe")
            .customerEmail("john@user.com")
            .billingAddressFirstName("John")
            .billingAddressLastName("Doe")
            .billingAddressLine1("PO Box 9999")
            .billingAddressCity("Walnut")
            .billingAddressState("California")
            .billingAddressZip("91789")
            .billingAddressCountry("US")
            .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.SubscriptionCreateParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionCreateResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;

public class SubscriptionCreate {

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

        SubscriptionCreateParams.CustomerParams customerParams =
            SubscriptionCreateParams.CustomerParams.builder()
                .firstName("John")
                .lastName("Doe")
                .email("john@user.com")
                .build();

        SubscriptionCreateParams.BillingAddressParams billingAddressParams =
            SubscriptionCreateParams.BillingAddressParams.builder()
                .firstName("John")
                .lastName("Doe")
                .line1("PO Box 9999")
                .city("Walnut")
                .state("California")
                .zip("91789")
                .country("US")
                .build();

        SubscriptionCreateParams params = SubscriptionCreateParams.builder()
            .planId("no_trial")
            .autoCollection(SubscriptionCreateParams.AutoCollection.OFF)
            .customer(customerParams)
            .billingAddress(billingAddressParams)
            .build();

        SubscriptionCreateResponse response = client.subscriptions().create(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.create({
        plan_id: "no_trial",
        auto_collection: "off",
        customer: {
            first_name: "John",
            last_name: "Doe",
            email: "john@user.com"
        },
        billing_address: {
            first_name: "John",
            last_name: "Doe",
            line1: "PO Box 9999",
            city: "Walnut",
            state: "California",
            zip: 91789,
            country: "US"
        }
    });

    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()->create([
    "plan_id" => "no_trial",
    "auto_collection" => "off",
    "customer" => [
        "first_name" => "John",
        "last_name" => "Doe",
        "email" => "john@user.com"
    ],
    "billing_address" => [
        "first_name" => "John",
        "last_name" => "Doe",
        "line1" => "PO Box 9999",
        "city" => "Walnut",
        "state" => "California",
        "zip" => "91789",
        "country" => "US"
    ]
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.create(
    cb_client.Subscription.CreateParams(
        plan_id="no_trial",
        auto_collection=chargebee.AutoCollection.OFF,
        customer=cb_client.Subscription.CreateCustomerParams(
            first_name="John",
            last_name="Doe",
            email="john@user.com"
        ),
        billing_address=cb_client.Subscription.CreateBillingAddressParams(
            first_name="John",
            last_name="Doe",
            line1="PO Box 9999",
            city="Walnut",
            state="California",
            zip="91789",
            country="US"
        )
    )
)
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({
  :plan_id => "no_trial",
  :auto_collection => "OFF",
  :customer => {
    :first_name => "John",
    :last_name => "Doe",
    :email => "john@user.com"
  },
  :billing_address => {
    :first_name => "John",
    :last_name => "Doe",
    :line1 => "PO Box 9999",
    :city => "Walnut",
    :state => "California",
    :zip => "91789",
    :country => "US"
  }
})

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

### creates a subscription with addons and coupons.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d "addons[id][0]"="ssl" \
     -d "coupon_ids[0]"="plan_only_coupon" \
     -d auto_collection="OFF"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.Create()
		.PlanId("no_trial")
		.AddonId(0, "ssl")
		.CouponIds(new List<string>{"plan_only_coupon"})
		.AutoCollection(AutoCollectionEnum.Off)
		.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"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Create(&subscription.CreateRequestParams{
        Addons : []*subscription.CreateAddonParams{
            {
                Id : "ssl",
            },
        },
        PlanId : "no_trial",
        CouponIds : []string{"plan_only_coupon"},
        AutoCollection : enum.AutoCollectionOff,
    }).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.SubscriptionCreateRequest{
    Addons : []*chargebee.SubscriptionCreateAddon{
        {
            Id : "ssl",
        },
    },
    PlanId : "no_trial",
    CouponIds : []string{"plan_only_coupon"},
    AutoCollection : chargebee.AutoCollectionOff,
}
  res, err := client.Subscription.Create(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.create()
            .planId("no_trial")
            .addonId(0, "ssl")
            .couponIds("plan_only_coupon")
            .autoCollection(AutoCollection.OFF)
            .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.SubscriptionCreateParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionCreateResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;

public class SubscriptionCreate {

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

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

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

        SubscriptionCreateParams params = SubscriptionCreateParams.builder()
            .planId("no_trial")
            .addons(addonsList)
            .couponIds(List.of("plan_only_coupon"))
            .autoCollection(SubscriptionCreateParams.AutoCollection.OFF)
            .build();

        SubscriptionCreateResponse response = client.subscriptions().create(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.create({
        addons: [
            {
                id: "ssl"
            }
        ],
        plan_id: "no_trial",
        coupon_ids: ["plan_only_coupon"],
        auto_collection: "off"
    });

    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()->create([
    "addons" => [
        [
            "id" => "ssl"
        ]
    ],
    "plan_id" => "no_trial",
    "coupon_ids" => ["plan_only_coupon"],
    "auto_collection" => "off"
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.create(
    cb_client.Subscription.CreateParams(
        addons=[
            cb_client.Subscription.CreateAddonParams(
              id="ssl"
            )
        ],
        plan_id="no_trial",
        coupon_ids=["plan_only_coupon"],
        auto_collection=chargebee.AutoCollection.OFF
    )
)
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({
  :plan_id => "no_trial",
  :addons => [
    {
      :id => "ssl"
    }
  ],
  :coupon_ids => ["plan_only_coupon"],
  :auto_collection => "OFF"
})

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

### creates a subscription with meta data and custom fields.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d auto_collection="OFF" \
     -d cf_gender="Male" \
     -d meta_data='{"features":{"usage-limit":"5GB","speed-within-quota":"2MBbps","post-usage-quota":"512kbps"}}'
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;
using ChargeBee.Models.Enums;
using Newtonsoft.Json.Linq;

ApiConfig.Configure("{site}","{site_api_key}");
var metaData = new JObject { ["features"] = "{\"usage-limit\":\"5GB\",\"speed-within-quota\":\"2MBbps\",\"post-usage-quota\":\"512kbps\"}" };
EntityResult result = Subscription.Create()
		.PlanId("no_trial")
		.AutoCollection(AutoCollectionEnum.Off)
		.MetaData(metaData)
		.Param("cf_gender", "Male")
		.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"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Create(&subscription.CreateRequestParams{
        PlanId : "no_trial",
        AutoCollection : enum.AutoCollectionOff,
        MetaData : &subscription.CreateMetaDataParams{
            Features : map[string]interface{}{
    "usage-limit" : "5GB",
    "speed-within-quota" : "2MBbps",
    "post-usage-quota" : "512kbps",
},
        },
    }).AddParams("cf_gender", "Male").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.SubscriptionCreateRequest{
    PlanId : "no_trial",
    AutoCollection : chargebee.AutoCollectionOff,
    MetaData : &chargebee.SubscriptionCreateMetaData{
        Features : map[string]interface{}{
"usage-limit" : "5GB",
"speed-within-quota" : "2MBbps",
"post-usage-quota" : "512kbps",
},
    },
}
  req.AddCustomField("cf_gender", "Male")
  res, err := client.Subscription.Create(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 com.chargebee.org.json.JSONArray;
import com.chargebee.org.json.JSONObject;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.create()
            .planId("no_trial")
            .autoCollection(AutoCollection.OFF)
            .metaData(new JSONObject("{\"features\":{\"usage-limit\":\"5GB\",\"speed-within-quota\":\"2MBbps\",\"post-usage-quota\":\"512kbps\"}}"))
            .param("cf_gender", "Male")
            .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.SubscriptionCreateParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionCreateResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;
import java.util.Map;

public class SubscriptionCreate {

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

        SubscriptionCreateParams params = SubscriptionCreateParams.builder()
            .planId("no_trial")
            .autoCollection(SubscriptionCreateParams.AutoCollection.OFF)
            .metaData(Map.of("features", Map.of("usage-limit", "5GB", "speed-within-quota", "2MBbps", "post-usage-quota", "512kbps")))
            .customField("cf_gender", "Male")
            .build();

        SubscriptionCreateResponse response = client.subscriptions().create(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.create({
        plan_id: "no_trial",
        auto_collection: "off",
        meta_data: {
            features: {
                usage_limit: "5GB",
                speed_within_quota: "2MBbps",
                post_usage_quota: "512kbps"
            }
        },
        cf_gender: "Male"
    });

    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()->create([
    "plan_id" => "no_trial",
    "auto_collection" => "off",
    "meta_data" => '{"features":{"usage-limit":"5GB","speed-within-quota":"2MBbps","post-usage-quota":"512kbps"}}',
    "cf_gender" => "Male"
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.create(
    cb_client.Subscription.CreateParams(
        plan_id="no_trial",
        auto_collection=chargebee.AutoCollection.OFF,
        meta_data={
            "features": {
    "usage_limit": "5GB",
    "speed_within_quota": "2MBbps",
    "post_usage_quota": "512kbps"
}
        },
        cf_gender="Male"
    )
)
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({
  :plan_id => "no_trial",
  :auto_collection => "OFF",
  :meta_data => {:features => {:usage_limit => "5GB",:speed_within_quota => "2MBbps",:post_usage_quota => "512kbps"}},
  "cf_gender" => "Male"
})

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

### creates a subscription with unbilled charges.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions \
     -u {site_api_key}:\
     -d plan_id="no_trial" \
     -d invoice_immediately="false" \
     -d terms_to_charge=2 \
     -d "addons[id][0]"="ssl" \
     -d auto_collection="OFF"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.Create()
		.PlanId("no_trial")
		.InvoiceImmediately(false)
		.TermsToCharge(2)
		.AddonId(0, "ssl")
		.AutoCollection(AutoCollectionEnum.Off)
		.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"
    enum "github.com/chargebee/chargebee-go/v3/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Create(&subscription.CreateRequestParams{
        Addons : []*subscription.CreateAddonParams{
            {
                Id : "ssl",
            },
        },
        PlanId : "no_trial",
        InvoiceImmediately : chargebee.Bool(false),
        TermsToCharge : chargebee.Int32(2),
        AutoCollection : enum.AutoCollectionOff,
    }).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.SubscriptionCreateRequest{
    Addons : []*chargebee.SubscriptionCreateAddon{
        {
            Id : "ssl",
        },
    },
    PlanId : "no_trial",
    InvoiceImmediately : chargebee.Bool(false),
    TermsToCharge : chargebee.Int32(2),
    AutoCollection : chargebee.AutoCollectionOff,
}
  res, err := client.Subscription.Create(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.create()
            .planId("no_trial")
            .invoiceImmediately(false)
            .termsToCharge(2)
            .addonId(0, "ssl")
            .autoCollection(AutoCollection.OFF)
            .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.SubscriptionCreateParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionCreateResponse;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import java.util.List;

public class SubscriptionCreate {

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

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

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

        SubscriptionCreateParams params = SubscriptionCreateParams.builder()
            .planId("no_trial")
            .invoiceImmediately(false)
            .termsToCharge(2)
            .addons(addonsList)
            .autoCollection(SubscriptionCreateParams.AutoCollection.OFF)
            .build();

        SubscriptionCreateResponse response = client.subscriptions().create(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.create({
        addons: [
            {
                id: "ssl"
            }
        ],
        plan_id: "no_trial",
        invoice_immediately: false,
        terms_to_charge: 2,
        auto_collection: "off"
    });

    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()->create([
    "addons" => [
        [
            "id" => "ssl"
        ]
    ],
    "plan_id" => "no_trial",
    "invoice_immediately" => false,
    "terms_to_charge" => 2,
    "auto_collection" => "off"
]);
$subscription = $result->subscription;
$customer = $result->customer;
$card = $result->card;
$invoice = $result->invoice;
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.create(
    cb_client.Subscription.CreateParams(
        addons=[
            cb_client.Subscription.CreateAddonParams(
              id="ssl"
            )
        ],
        plan_id="no_trial",
        invoice_immediately=False,
        terms_to_charge=2,
        auto_collection=chargebee.AutoCollection.OFF
    )
)
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({
  :plan_id => "no_trial",
  :invoice_immediately => "false",
  :terms_to_charge => 2,
  :addons => [
    {
      :id => "ssl"
    }
  ],
  :auto_collection => "OFF"
})

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": "on",
    "billing_address": {
      "city": "Walnut",
      "country": "US",
      "first_name": "John",
      "last_name": "Doe",
      "line1": "PO Box 9999",
      "object": "billing_address",
      "state": "California",
      "state_code": "CA",
      "validation_status": "not_validated",
      "zip": "91789"
    },
    "card_status": "no_card",
    "created_at": 1517505643,
    "deleted": false,
    "email": "john@user.com",
    "excess_payments": 0,
    "first_name": "John",
    "id": "__test__KyVnHhSBWkkwI2Tn",
    "last_name": "Doe",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505643000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505643
  },
  "invoice": {
    "adjustment_credit_notes": {},
    "amount_adjusted": 0,
    "amount_due": 895,
    "amount_paid": 0,
    "amount_to_collect": 895,
    "applied_credits": {},
    "base_currency_code": "USD",
    "billing_address": {
      "city": "Walnut",
      "country": "US",
      "first_name": "John",
      "last_name": "Doe",
      "line1": "PO Box 9999",
      "object": "billing_address",
      "state": "California",
      "state_code": "CA",
      "validation_status": "not_validated",
      "zip": "91789"
    },
    "credits_applied": 0,
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWkkwI2Tn",
    "date": 1517505643,
    "deleted": false,
    "due_date": 1517505643,
    "dunning_attempts": {},
    "exchange_rate": 1,
    "first_invoice": true,
    "has_advance_charges": false,
    "id": "__demo_inv__11",
    "is_gifted": false,
    "issued_credit_notes": {},
    "line_items": [
      {
        "amount": 895,
        "customer_id": "__test__KyVnHhSBWkkwI2Tn",
        "date_from": 1517505643,
        "date_to": 1519924843,
        "description": "No Trial",
        "discount_amount": 0,
        "entity_id": "no_trial",
        "entity_type": "plan",
        "id": "li___test__KyVnHhSBWkkxu2Tp",
        "is_taxed": false,
        "item_level_discount_amount": 0,
        "object": "line_item",
        "pricing_model": "per_unit",
        "quantity": 1,
        "subscription_id": "__test__KyVnHhSBWkkwI2Tn",
        "tax_amount": 0,
        "tax_exempt_reason": "tax_not_configured",
        "unit_amount": 895
      },
      {..}
    ],
    "linked_orders": {},
    "linked_payments": {},
    "net_term_days": 0,
    "new_sales_amount": 895,
    "object": "invoice",
    "price_type": "tax_exclusive",
    "recurring": true,
    "resource_version": 1517505643000,
    "round_off_amount": 0,
    "status": "payment_due",
    "sub_total": 895,
    "subscription_id": "__test__KyVnHhSBWkkwI2Tn",
    "tax": 0,
    "term_finalized": true,
    "total": 895,
    "updated_at": 1517505643,
    "write_off_amount": 0
  },
  "subscription": {
    "activated_at": 1517505643,
    "auto_collection": "off",
    "billing_period": 1,
    "billing_period_unit": "month",
    "created_at": 1517505643,
    "currency_code": "USD",
    "current_term_end": 1519924843,
    "current_term_start": 1517505643,
    "customer_id": "__test__KyVnHhSBWkkwI2Tn",
    "deleted": false,
    "due_invoices_count": 1,
    "due_since": 1517505643,
    "has_scheduled_changes": false,
    "id": "__test__KyVnHhSBWkkwI2Tn",
    "mrr": 0,
    "next_billing_at": 1519924843,
    "object": "subscription",
    "plan_amount": 895,
    "plan_free_quantity": 0,
    "plan_id": "no_trial",
    "plan_quantity": 1,
    "plan_unit_price": 895,
    "resource_version": 1517505643000,
    "started_at": 1517505643,
    "status": "active",
    "total_dues": 895,
    "updated_at": 1517505643
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/subscriptions

## Input Parameters

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

- `brand_id` (optional, string, max chars=50)

- `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)
  Plan Unit Amount for create subscription.

- `plan_unit_price_in_decimal` (optional, string, max chars=39)
  Plan Unit Amount in Decimal for create subscription.

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

- `token_id` (optional, string, max chars=40)
  The Chargebee payment token generated by [Chargebee.js](https://www.chargebee.com/docs/payments/2.0/card-components-and-helpers/3ds-helper#using-the-gateways-hosted-fields).
  
  **Note**: The payment token created via Chargebee.js uses the gateway selected through [Smart Routing](https://www.chargebee.com/docs/payments/1.0/payment-gateways-and-configuration/gateway_settings#smart-routing). Explicitly passing a `gateway_id` in this API call will not override the gateway associated with the token.

- `affiliate_token` (optional, string, max chars=250)
  A unique tracking token.

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

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

- `client_profile_id` (optional, string, max chars=50)
  Indicates the Client profile id for the customer. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.

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

- `customer` (optional, string)
  Parameters for customer
  - `id` (optional, string, max chars=50)
    The unique ID of the customer for which this `subscription` resource should be created.
  - `email` (optional, string, max chars=70)
    Email of the customer. Configured email notifications will be sent to this email.
  - `first_name` (optional, string, max chars=150)
    First name of the customer
  - `last_name` (optional, string, max chars=150)
    Last name of the customer
  - `company` (optional, string, max chars=250)
    Company name of the customer.
  - `phone` (optional, string, max chars=50)
    Phone number of the customer
  - `locale` (optional, string, max chars=50)
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
  - `taxability` (optional, enumerated string, default=taxable)
    Specifies if the customer is liable for tax
    Possible enum values:
      - `taxable`
        Computes tax for the customer based on the [site configuration](https://www.chargebee.com/docs/tax.html). In some cases, depending on the region, shipping\_address is needed. If not provided, then billing\_address is used to compute tax. If that's not available either, the tax is taken as zero.
      - `exempt`
        -   Customer is exempted from tax. When using Chargebee's native [Taxes](https://www.chargebee.com/docs/tax.html) feature or when using the [TaxJar integration](https://www.chargebee.com/docs/taxjar.html), no other action is needed.
        -   However, when using our [Avalara integration](https://www.chargebee.com/docs/avalara.html), optionally, specify `entity_code` or `exempt_number` attributes if you use Chargebee's [AvaTax for Sales](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption) or specify `exemption_details` attribute if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration. Tax may still be applied by Avalara for certain values of `entity_code`/`exempt_number`/`exemption_details` based on the state/region/province of the taxable address.
  - `entity_code` (optional, enumerated string)
    The exemption category of the customer, for USA and Canada. Applicable if you use Chargebee's [AvaTax for Sales integration](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption) .
    Possible enum values:
      - `a`
        Federal government
      - `b`
        State government
      - `c`
        Tribe/Status Indian/Indian Band
      - `d`
        Foreign diplomat
      - `e`
        Charitable or benevolent organization
      - `f`
        Religious organization
      - `g`
        Resale
      - `h`
        Commercial agricultural production
      - `i`
        Industrial production/manufacturer
      - `j`
        Direct pay permit
      - `k`
        Direct mail
      - `l`
        Other or custom
      - `m`
        Educational organization
      - `n`
        Local government
      - `p`
        Commercial aquaculture
      - `q`
        Commercial Fishery
      - `r`
        Non-resident
      - `med1`
        US Medical Device Excise Tax with exempt sales tax
      - `med2`
        US Medical Device Excise Tax with taxable sales tax
  - `exempt_number` (optional, string, max chars=100)
    Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable if you use Chargebee's [AvaTax for Sales integration](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption) .
  - `net_term_days` (optional, integer, default=0)
    The number of days within which the customer has to make payment for the invoice.
  - `taxjar_exemption_category` (optional, enumerated string)
    Indicates the exemption type of the customer. This is applicable only if you use Chargebee's TaxJar integration.
    Possible enum values:
      - `wholesale`
        Whole-sale
      - `government`
        Government
      - `other`
        Other
  - `auto_collection` (optional, enumerated string, default=on)
    Whether payments needs to be collected automatically for this customer
    Possible enum values:
      - `on`
        Whenever an invoice is created, an automatic attempt to charge the customer's payment method is made.
      - `off`
        Automatic collection of charges will not be made. All payments must be recorded offline.
  - `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
  - `allow_direct_debit` (optional, boolean, default=false)
    Whether the customer can pay via Direct Debit
  - `consolidated_invoicing` (optional, boolean)
    Indicates whether invoices raised on the same day for the `customer` are consolidated. When provided, this overrides the default configuration at the [site-level](https://www.chargebee.com/docs/consolidated-invoicing.html#configuring-consolidated-invoicing). This parameter can be provided only when [Consolidated Invoicing](https://www.chargebee.com/docs/consolidated-invoicing.html) is enabled.
    
    **Note:**
    
    Any invoices raised when a subscription activates from `in_trial` or `future` `status`, are not consolidated by default. [Contact 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 consolidation for such invoices.
  - `vat_number` (optional, string, max chars=20)
    The VAT/tax registration number for the customer. For customers with `[billing_address](/docs/api/customers/customer-object#billing_address)`
    
    `country` as `XI` (which is **United Kingdom - Northern Ireland** ), the first two characters of the [full VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) can be overridden by setting `[vat_number_prefix](/docs/api/customers/customer-object#vat_number_prefix)` .
  - `vat_number_prefix` (optional, string, max chars=10)
    An overridden value for the first two characters of the [full VAT number](https://en.wikipedia.org/wiki/VAT_identification_number). Only applicable specifically for customers with `[billing_address](/docs/api/customers/customer-object#billing_address)`
    
    `country` as `XI` (which is **United Kingdom - Northern Ireland** ).
    
    When you have enabled [EU VAT](https://www.chargebee.com/docs/eu-vat.html) in 2021 or have [manually enabled](https://www.chargebee.com/docs/brexit.html#what-needs-to-be-done-in-chargebee) the Brexit configuration, you have the option of setting `[billing_address](/docs/api/customers/customer-object#billing_address)`
    
    `country` as `XI`. That's the code for **United Kingdom - Northern Ireland**. The first two characters of the VAT number in such a case is `XI` by default. However, if the VAT number was registered in UK, the value should be `GB`. Set `vat_number_prefix` to `GB` for such cases.
  - `entity_identifier_scheme` (optional, string, max chars=50)
    The Peppol BIS scheme associated with the `[vat_number](/docs/api/customers/customer-object#vat_number)` of the customer. This helps identify the specific type of customer entity. For example, `DE:VAT` is used for a German business entity while `DE:LWID45` is used for a German government entity. The value must be from the list of possible values and must correspond to the country provided under `billing_address.country`. See [list of possible values](https://www.chargebee.com/docs/e-invoicing.html#supported-countries) .
    
    **Tip:**
    
    If there are additional entity identifiers for the customer not associated with the `vat_number`, they can be provided as the `entity_identifiers[]` array.
  - `entity_identifier_standard` (optional, string, default=iso6523-actorid-upis, max chars=50)
    The standard used for specifying the `entity_identifier_scheme`. Currently only `iso6523-actorid-upis` is supported and is used by default when not provided.
    
    **Tip:**
    
    If there are additional entity identifiers for the customer not associated with the `vat_number`, they can be provided as the `entity_identifiers[]` array.
  - `is_einvoice_enabled` (optional, boolean)
    Determines whether the customer is e-invoiced. When set to `true` or not set to any value, the customer is e-invoiced so long as e-invoicing is enabled for their country (`billing_address.country` ). When set to `false` , the customer is not e-invoiced even if e-invoicing is enabled for their country.
    
    **Tip:**
    
    It is possible to set a value for this flag even when E-Invoicing is disabled. However, it comes into effect only when E-Invoicing is enabled.
  - `einvoicing_method` (optional, enumerated string)
    Determines whether to send einvoice manually or automatic.
    Possible enum values:
      - `automatic`
        Use this value to send e-invoice every time an invoice or credit note is created.
      - `manual`
        When manual is selected the automatic e-invoice sending is disabled. Use this value to send e-invoice manually through UI or API.
      - `site_default`
        The default value of the site which can be overridden at the customer level.
  - `registered_for_gst` (optional, boolean)
    Confirms that a customer is registered under GST. If set to `true` then the [Reverse Charge Mechanism](https://www.chargebee.com/docs/australian-gst.html#reverse-charge-mechanism) is applicable. This field is applicable only when Australian GST is configured for your site.
  - `business_customer_without_vat_number` (optional, boolean)
    Confirms that a customer is a valid business without an EU/UK VAT number.
  - `exemption_details` (optional)
    Indicates the exemption information. You can customize customer exemption based on specific Location, Tax level (Federal, State, County and Local), Category of Tax or specific Tax Name. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration. To know more about what values you need to provide, refer to this [Avalara's API document](https://developer.avalara.com/communications/dev-guide_rest_v2/customizing-transactions/sample-transactions/exemption/) .
  - `customer_type` (optional, enumerated string)
    Indicates the type of the customer. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
    Possible enum values:
      - `residential`
        When the purchase is made by a customer for home use
      - `business`
        When the purchase is made at a place of business
      - `senior_citizen`
        When the purchase is made by a customer who meets the jurisdiction requirements to be considered a senior citizen and qualifies for senior citizen tax breaks
      - `industrial`
        When the purchase is made by an industrial business

- `card` (optional, string)
  Parameters for card
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `first_name` (optional, string, max chars=50)
    Cardholder's first name
  - `last_name` (optional, string, max chars=50)
    Cardholder's last name
  - `number` (required if card provided, string, max chars=1500)
    The credit card number without any format. If you are using [Braintree.js](https://developer.paypal.com/braintree/docs/guides/client-sdk/setup/javascript/v2#getting-braintree.js) , you can specify the Braintree encrypted card number here.
  - `expiry_month` (required if card provided, integer, min=1, max=12)
    Card expiry month.
  - `expiry_year` (required if card provided, integer)
    Card expiry year.
  - `cvv` (optional, string, max chars=520)
    The card verification value (CVV). If you are using [Braintree.js](https://developer.paypal.com/braintree/docs/guides/client-sdk/setup/javascript/v2#getting-braintree.js) , you can specify the Braintree encrypted CVV here.
  - `preferred_scheme` (optional, enumerated string)
    The customer's preferred card scheme for co-branded cards.
    
    **Note**: Currently, this parameter is only supported for Stripe.
    Possible enum values:
      - `cartes_bancaires`
        A Cartes Bancaires card scheme.
      - `mastercard`
        A MasterCard scheme.
      - `visa`
        A Visa card scheme.
  - `billing_addr1` (optional, string, max chars=150)
    Address line 1, as available in card billing address.
  - `billing_addr2` (optional, string, max chars=150)
    Address line 2, as available in card billing address.
  - `billing_city` (optional, string, max chars=50)
    City, as available in card billing address.
  - `billing_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 `billing_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` ).
  - `billing_state` (optional, string, max chars=50)
    The state/province name. Is set by Chargebee automatically for US, Canada, India and UAE, if `billing_state_code` is provided.
  - `billing_zip` (optional, string, max chars=20)
    Postal or Zip code, as available in card billing address.
  - `billing_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.
  - `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

- `bank_account` (optional, string)
  Parameters for bank\_account
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `iban` (optional, string, min chars=10, max chars=50)
    Account holder's International Bank Account Number. For the [GoCardless](https://www.chargebee.com/docs/gocardless.html) platform, this can be the [local bank details](https://developer.gocardless.com/api-reference/#appendix-local-bank-details)
  - `first_name` (optional, string, max chars=150)
    Account holder's first name as per bank account. If not passed, details from customer details will be considered.
  - `last_name` (optional, string, max chars=150)
    Account holder's last name as per bank account. If not passed, details from customer details will be considered.
  - `company` (optional, string, max chars=250)
    Account holder's company name as per bank account. If not passed, details from customer details will be considered.
  - `email` (optional, string, max chars=70)
    Account holder's email address. If not passed, details from customer details will be considered. All Direct Debit compliant emails will be sent to this email address.
  - `phone` (optional, string, max chars=50)
    Phone number of the account holder that is linked to the bank account.
  - `bank_name` (optional, string, max chars=100)
    Name of account holder's bank.
  - `account_number` (optional, string, min chars=4, max chars=17)
    Account holder's bank account number.
  - `routing_number` (optional, string, min chars=3, max chars=9)
    Bank account routing number.
  - `bank_code` (optional, string, max chars=20)
    Indicates the bank code.
  - `account_type` (optional, enumerated string)
    Represents the account type used to create a payment source. Available for [Authorize.net](https://www.authorize.net/) ACH and Razorpay NetBanking users only. If not passed, account type is taken as null.
    Possible enum values:
      - `checking`
        Checking Account
      - `savings`
        Savings Account
      - `business_checking`
        Business Checking Account
      - `current`
        Current Account
  - `account_holder_type` (optional, enumerated string)
    For Stripe ACH users only. Indicates the account holder type.
    Possible enum values:
      - `individual`
        Individual Account.
      - `company`
        Company Account.
  - `echeck_type` (optional, enumerated string)
    For Authorize.net ACH users only. Indicates the type of eCheck.
    Possible enum values:
      - `web`
        Payment Authorization obtained from the customer via the internet.
      - `ppd`
        Payment Authorization is prearranged between the customer and the merchant.
      - `ccd`
        Payment Authorization agreement from the corporate customer is required. Applicable for business\_checking account\_type.
  - `issuing_country` (optional, string, max chars=50)
    [two-letter(alpha2)](https://www.iso.org/iso-3166-country-codes.html) ISO country code. Required when local bank details are provided, and not IBAN.
  - `swedish_identity_number` (optional, string, min chars=10, max chars=12)
    For GoCardless Autogiro users only. The civic/company number (personnummer, samordningsnummer, or organisationsnummer) of the customer. Must be supplied if the customer's bank account is denominated in Swedish krona (SEK). This field cannot be changed once it has been set.
  - `billing_address` (optional, jsonobject)
    The billing address associated with the bank account. The value is a JSON object with the following keys and their values:- `first_name`:(string, max chars=150) The first name of the contact.
    
    -   `last_name`:(string, max chars=150) The last name of the contact.
    -   `company_name`:(string, max chars=250) The company name for the address.
    -   `line1`:(string, max chars=180) The first line of the address.
    -   `line2`:(string, max chars=180) The second line of the address.
    -   `country`:(string) The name of the country for the address.
    -   `country_code`:(string, max chars=50) The two-letter, [ISO 3166 alpha-2](https://www.iso.org/iso-3166-country-codes.html) country code for the address.
    -   `state`:(string, max chars=50) The name of the state or province for the address. When not provided, this is set automatically for US, Canada, India, and UAE.
    -   `state_code`:(string, max chars=50) The [ISO 3166-2 state/province code](https://www.iso.org/obp/ui/#search/code/) without the country prefix. This is 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`).
    -   `city`:(string, max chars=50) The city name for the address.
    -   `postal_code`:(string, max chars=20) The postal or ZIP code for the address.
    -   `phone`:(string, max chars=50) The contact phone number for the address.
    -   `email`:(string, max chars=70) The contact email address for the address.

- `payment_method` (optional, enumerated string)
  Parameters for payment\_method
  - `type` (optional, enumerated string)
    The type of payment method. For more details refer [Update payment method for a customer](/docs/api/customers/update-payment-method-for-a-customer) API under Customer resource.
    Possible enum values:
      - `card`
        Card based payment including credit cards and debit cards. Details about the card can be obtained from the card resource.
      - `paypal_express_checkout`
        Payments made via PayPal Express Checkout.
      - `amazon_payments`
        Payments made via Amazon Payments.
      - `direct_debit`
        Represents bank account for which the direct debit or ACH agreement/mandate is created.
      - `generic`
        Payments made via Generic Payment Method.
      - `alipay`
        Payments made via Alipay.
        
        This payment source is deprecated.
      - `unionpay`
        Payments made via UnionPay.
      - `apple_pay`
        Payments made via Apple Pay.
      - `wechat_pay`
        Payments made via WeChat Pay.
        
        This payment source is deprecated.
      - `ideal`
        Payments made via iDEAL.
      - `google_pay`
        Payments made via Google Pay.
      - `sofort`
        Payments made via Sofort.
      - `bancontact`
        Payments made via Bancontact Card.
      - `giropay`
        Payments made via giropay.
      - `dotpay`
        Payments made via Dotpay.
      - `upi`
        UPI Payments.
      - `netbanking_emandates`
        Netbanking (eMandates) Payments.
      - `venmo`
        Payments made via Venmo
      - `pay_to`
        Payments made via PayTo
      - `faster_payments`
        Payments made via Faster Payments
      - `sepa_instant_transfer`
        Payments made via Sepa Instant Transfer
      - `automated_bank_transfer`
        Represents virtual bank account using which the payment will be done.
      - `klarna_pay_now`
        Payments made via Klarna Pay Now
      - `online_banking_poland`
        Payments made via 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.
      - `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`
        Payments made via Pix
      - `klarna`
        Payments made via Klarna.
      - `alipay_hk`
        Payments made via Alipay HK.
      - `paypay`
        Payments made via 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`
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `reference_id` (optional, string, max chars=200)
    The reference id. In the case of Amazon and PayPal this will be the _billing agreement id_. For GoCardless direct debit this will be 'mandate id'. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. **Note:** This is not the one-time temporary token provided by gateways like Stripe.
    
    For more details refer [Update payment method for a customer](/docs/api/customers/update-payment-method-for-a-customer) API under Customer resource.
  - `tmp_token` (required if reference_id not provided, string, max chars=65k)
    Single-use token created by payment gateways. In Stripe, a single-use token is created for Apple Pay Wallet or card details. In Braintree, a nonce is created for Apple Pay Wallet, PayPal, or card details. In Authorize.Net, a nonce is created for card details. In Adyen, an encrypted data is created from the card details.
  - `issuing_country` (optional, string, max chars=50)
    [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.
    
    If you have enabled [EU VAT](https://www.chargebee.com/docs/eu-vat.html) in 2021 or have [manually enabled](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.
  - `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

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

- `billing_address` (optional, string)
  Parameters for billing\_address
  - `first_name` (optional, string, max chars=150)
    The first name of the billing contact.
  - `last_name` (optional, string, max chars=150)
    The last name of the billing 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://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) .
    
    **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.

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

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

- `entity_identifiers` (optional, array)
  Parameters for entity\_identifiers
  - `id` (optional, string, max chars=40)
    The unique id for the `entity_identifier` in Chargebee. When not provided, it is autogenerated.
  - `scheme` (optional, string, max chars=50)
    The Peppol BIS scheme associated with the `[vat_number](/docs/api/customers/customer-object#vat_number)` of the customer. This helps identify the specific type of customer entity. For example, `DE:VAT` is used for a German business entity while `DE:LWID45` is used for a German government entity. The value must be from the list of possible values and must correspond to the country provided under `billing_address.country`. See [list of possible values](https://www.chargebee.com/docs/e-invoicing.html#supported-countries) .
    
    **Tip:**
    
    If there is only one entity identifier for the customer and the value is the same as `vat_number`, then there is no need to provide the `entity_identifiers[]` array. See [description for `entity_identifiers[]`](/docs/api/customers/customer-object#entity_identifiers).
  - `value` (optional, string, max chars=50)
    The value of the `entity_identifier`. This identifies the customer entity on the Peppol network. For example: `10101010-STO-10` .
    
    **Tip:**
    
    If there is only one entity identifier for the customer and the value is the same as `vat_number`, then there is no need to provide the `entity_identifiers[]` array. See [description for `entity_identifiers[]`](/docs/api/customers/customer-object#entity_identifiers).
  - `standard` (optional, string, max chars=50)
    The standard used for specifying the `entity_identifier` `scheme`. Currently, only `iso6523-actorid-upis` is supported and is used by default when not provided.
    
    **Tip:**
    
    If there is only one entity identifier for the customer and the value is the same as `vat_number`, then there is no need to provide the `entity_identifiers[]` array. See [description for `entity_identifiers[]`](/docs/api/customers/customer-object#entity_identifiers).

- `tax_providers_fields` (optional, array)
  Parameters for tax\_providers\_fields
  - `provider_name` (optional, string, max chars=50)
    Name of the tax provider.
  - `field_id` (optional, string, max chars=50)
    The unique identifier belonging to a tax vendor when they are onboarded with Chargebee.
  - `field_value` (optional, string, max chars=50)
    The value of the corresponding tax field.

- `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)
    Addon Unit Amount for create subscription
  - `unit_price_in_decimal` (optional, string, max chars=39)
    Addon 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
