# Create unbilled charges for item subscription

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


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

This endpoint creates unbilled charges for a subscription.

## Sample Request

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/unbilled_charges \
     -u {site_api_key}:\
     -d subscription_id="__test__5SK2lmRmS627AvF5Z" \
     -d "item_prices[item_price_id][0]"="ssl-charge-USD"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = UnbilledCharge.Create()
		.SubscriptionId("__test__5SK2lmRmS627AvF5Z")
		.ItemPriceItemPriceId(0, "ssl-charge-USD")
		.Request();

List<UnbilledCharge> unbilledCharges = result.UnbilledCharges;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    unbilledchargeAction "github.com/chargebee/chargebee-go/v3/actions/unbilledcharge"
    "github.com/chargebee/chargebee-go/v3/models/unbilledcharge"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := unbilledchargeAction.Create(&unbilledcharge.CreateRequestParams{
        ItemPrices : []*unbilledcharge.CreateItemPriceParams{
            {
                ItemPriceId : "ssl-charge-USD",
            },
        },
        SubscriptionId : "__test__5SK2lmRmS627AvF5Z",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        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.UnbilledChargeCreateRequest{
    ItemPrices : []*chargebee.UnbilledChargeCreateItemPrice{
        {
            ItemPriceId : "ssl-charge-USD",
        },
    },
    SubscriptionId : "__test__5SK2lmRmS627AvF5Z",
}
  res, err := client.UnbilledCharge.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        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 = UnbilledCharge.create()
            .subscriptionId("__test__5SK2lmRmS627AvF5Z")
            .itemPriceItemPriceId(0, "ssl-charge-USD")
            .request();

        List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import com.chargebee.v4.models.unbilledCharge.params.UnbilledChargeCreateParams;
import com.chargebee.v4.models.unbilledCharge.responses.UnbilledChargeCreateResponse;
import java.util.List;

public class UnbilledChargeCreate {

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

        UnbilledChargeCreateParams.ItemPricesParams itemPrice0 =
            UnbilledChargeCreateParams.ItemPricesParams.builder()
                .itemPriceId("ssl-charge-USD")
                .build();

        List<UnbilledChargeCreateParams.ItemPricesParams> itemPricesList =
            List.of(itemPrice0);

        UnbilledChargeCreateParams params = UnbilledChargeCreateParams.builder()
            .subscriptionId("__test__5SK2lmRmS627AvF5Z")
            .itemPrices(itemPricesList)
            .build();

        UnbilledChargeCreateResponse response = client.unbilledCharges().create(params);

        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.unbilledCharge.create({
        item_prices: [
            {
                item_price_id: "ssl-charge-USD"
            }
        ],
        subscription_id: "__test__5SK2lmRmS627AvF5Z"
    });

    console.log(result);
    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->unbilledCharge()->create([
    "item_prices" => [
        [
            "item_price_id" => "ssl-charge-USD"
        ]
    ],
    "subscription_id" => "__test__5SK2lmRmS627AvF5Z"
]);
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.UnbilledCharge.create(
    cb_client.UnbilledCharge.CreateParams(
        item_prices=[
            cb_client.UnbilledCharge.CreateItemPriceParams(
              item_price_id="ssl-charge-USD"
            )
        ],
        subscription_id="__test__5SK2lmRmS627AvF5Z"
    )
)
unbilled_charges = response.unbilled_charges
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::UnbilledCharge.create({
  :subscription_id => "__test__5SK2lmRmS627AvF5Z",
  :item_prices => [
    {
      :item_price_id => "ssl-charge-USD"
    }
  ]
})

unbilled_charges = result.unbilled_charges
```

### Null

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/unbilled_charges \
     -u {site_api_key}:\
     -d subscription_id="__test__5SK2lmRmS627BA25k" \
     -d currency_code="usd" \
     -d "charges[amount][0]"=100 \
     -d "charges[description][0]"="Implementation charge"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = UnbilledCharge.Create()
		.SubscriptionId("__test__5SK2lmRmS627BA25k")
		.CurrencyCode("usd")
		.ChargeAmount(0, 100)
		.ChargeDescription(0, "Implementation charge")
		.Request();

List<UnbilledCharge> unbilledCharges = result.UnbilledCharges;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    unbilledchargeAction "github.com/chargebee/chargebee-go/v3/actions/unbilledcharge"
    "github.com/chargebee/chargebee-go/v3/models/unbilledcharge"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := unbilledchargeAction.Create(&unbilledcharge.CreateRequestParams{
        Charges : []*unbilledcharge.CreateChargeParams{
            {
                Amount : chargebee.Int64(100),
                Description : "Implementation charge",
            },
        },
        SubscriptionId : "__test__5SK2lmRmS627BA25k",
        CurrencyCode : "usd",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        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.UnbilledChargeCreateRequest{
    Charges : []*chargebee.UnbilledChargeCreateCharge{
        {
            Amount : chargebee.Int64(100),
            Description : "Implementation charge",
        },
    },
    SubscriptionId : "__test__5SK2lmRmS627BA25k",
    CurrencyCode : "usd",
}
  res, err := client.UnbilledCharge.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        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 = UnbilledCharge.create()
            .subscriptionId("__test__5SK2lmRmS627BA25k")
            .currencyCode("usd")
            .chargeAmount(0, 100L)
            .chargeDescription(0, "Implementation charge")
            .request();

        List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.unbilledCharge.UnbilledCharge;
import com.chargebee.v4.models.unbilledCharge.params.UnbilledChargeCreateParams;
import com.chargebee.v4.models.unbilledCharge.responses.UnbilledChargeCreateResponse;
import java.util.List;

public class UnbilledChargeCreate {

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

        UnbilledChargeCreateParams.ChargesParams charge0 =
            UnbilledChargeCreateParams.ChargesParams.builder()
                .amount(100L)
                .description("Implementation charge")
                .build();

        List<UnbilledChargeCreateParams.ChargesParams> chargesList =
            List.of(charge0);

        UnbilledChargeCreateParams params = UnbilledChargeCreateParams.builder()
            .subscriptionId("__test__5SK2lmRmS627BA25k")
            .currencyCode("usd")
            .charges(chargesList)
            .build();

        UnbilledChargeCreateResponse response = client.unbilledCharges().create(params);

        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.unbilledCharge.create({
        charges: [
            {
                amount: 100,
                description: "Implementation charge"
            }
        ],
        subscription_id: "__test__5SK2lmRmS627BA25k",
        currency_code: "usd"
    });

    console.log(result);
    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->unbilledCharge()->create([
    "charges" => [
        [
            "amount" => 100,
            "description" => "Implementation charge"
        ]
    ],
    "subscription_id" => "__test__5SK2lmRmS627BA25k",
    "currency_code" => "usd"
]);
$unbilledCharges = $result->unbilled_charges;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.UnbilledCharge.create(
    cb_client.UnbilledCharge.CreateParams(
        charges=[
            cb_client.UnbilledCharge.CreateChargeParams(
              amount=100,
              description="Implementation charge"
            )
        ],
        subscription_id="__test__5SK2lmRmS627BA25k",
        currency_code="usd"
    )
)
unbilled_charges = response.unbilled_charges
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::UnbilledCharge.create({
  :subscription_id => "__test__5SK2lmRmS627BA25k",
  :currency_code => "usd",
  :charges => [
    {
      :amount => 100,
      :description => "Implementation charge"
    }
  ]
})

unbilled_charges = result.unbilled_charges
```

## Sample Response

```json
{
  "unbilled_charges": [
    {
      "id": "li___dev__XpbJ77CVDP7eWz3a",
      "customer_id": "_cb_test_demo_",
      "subscription_id": "__dev__XpbJ77CVDP3zQI38",
      "date_from": 1773088261,
      "date_to": 1773088261,
      "unit_amount": 50000,
      "pricing_model": "flat_fee",
      "quantity": 1,
      "amount": 50000,
      "discount_amount": 0,
      "description": "One-Time Setup Fee",
      "entity_id": "cbdemo_one-time-setup-fee",
      "is_voided": false,
      "created_at": 1773088262,
      "updated_at": 1773088262,
      "deleted": false,
      "object": "unbilled_charge",
      "entity_type": "charge_item_price",
      "currency_code": "USD"
    },
    {..}
  ]
}
```

## URL Format

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

## Input Parameters

- `subscription_id` (required, string, max chars=50)
  Identifier of the subscription for which this unbilled charges needs to be created.

- `currency_code` (required if Multicurrency is enabled, string, max chars=3)
  The currency code (ISO 4217 format) of the unbilled\_charge.

- `item_prices` (optional, array)
  Parameters for item\_prices
  - `item_price_id` (optional, string, max chars=100)
    A unique ID for your system to identify the item price.
  - `quantity` (optional, integer)
    Item price quantity
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the item purchased. Can be provided for quantity-based item prices and only when [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `unit_price` (optional, in cents)
    The price or per-unit-price of the item price. By default, it is the [value set](/docs/api/item_prices/item_price-object#price) for the `item_price`. This is only applicable when the `pricing_model` of the `item_price` is `flat_fee` or `per_unit`. The value depends on the [type of currency](/docs/api/currencies) .
  - `unit_price_in_decimal` (optional, string, max chars=39)
    The decimal representation of the price or per-unit price of the plan. The value is in major units of the currency. Always returned when [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `date_from` (optional, timestamp(UTC) in seconds)
    The time when the service period for the item starts.
  - `date_to` (optional, timestamp(UTC) in seconds)
    The time when the service period for the item ends.

- `item_tiers` (optional, array)
  Parameters for item\_tiers
  - `item_price_id` (optional, string, max chars=100)
    The id of the item price to which this tier belongs.
  - `starting_unit` (optional, integer)
    The lowest value in the quantity tier.
  - `ending_unit` (optional, integer)
    The highest value in the quantity tier.
  - `price` (optional, in cents)
    The per-unit price for the tier when the `pricing_model` is `tiered` or `volume`. The total cost for the item price when the `pricing_model` is `stairstep`. The value is in the minor unit of the currency.
  - `starting_unit_in_decimal` (optional, string, max chars=33)
    The decimal representation of the lowest value of quantity in this tier. This is zero for the lowest tier. For all other tiers, it is the same as `ending_unit_in_decimal` of the next lower tier. Returned only when the pricing\_model is `tiered` , `volume` or `stairstep` and [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `ending_unit_in_decimal` (optional, string, max chars=33)
    The decimal representation of the highest value of quantity in this tier. This attribute is not applicable for the highest tier. For all other tiers, it must be equal to the `starting_unit_in_decimal` of the next higher tier. Returned only when the pricing\_model is `tiered` , `volume` or `stairstep` and [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `price_in_decimal` (optional, string, max chars=39)
    The decimal representation of the per-unit price for the tier when the `pricing_model` is `tiered` or `volume`. When the `pricing_model` is `stairstep` , it is the decimal representation of the total price for the item. The value is in major units of the currency. Returned when the plan is quantity-based and [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `pricing_type` (optional, enumerated string)
    Pricing type for the tier.
    Possible enum values:
      - `per_unit`
        Indicates that the tier pricing is based on individual units. Customers are charged a fixed price per unit. For example, if the price per unit is $2 and the customer consumes 150 units, they will be charged $300 (150 × $2).
      - `flat_fee`
        Indicates that the tier pricing is a flat fee, applied to the entire tier regardless of the number of units consumed. For the **stairstep** pricing model, `pricing_type` will be set to `flat_fee` by default. For example, if the flat fee for a tier is $100, the customer pays $100 whether they consume 1 unit or the maximum number of units within that tier.
      - `package`
        Indicates that the tier pricing is based on a package of units. Customers are charged for each block or package of units. For example, if the package size is 100 units and the cost per block is $20 consuming 400 units will result in a charge of $80 (4 × $20).
  - `package_size` (optional, integer)
    Package size for the tier when pricing type is `package`. Specify the number of units that make up one package. For example, if 1000 API hits are grouped into a single package, set the package size to 1000.

- `charges` (optional, array)
  Parameters for charges
  - `amount` (optional, in cents)
    The amount to be charged. The unit depends on the [type of currency](/docs/api/getting-started) .
  - `amount_in_decimal` (optional, string, max chars=39)
    The decimal representation of the amount for the [one-time charge](https://www.chargebee.com/docs/charges.html#one-time-charges ). Provide the value in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `description` (optional, string, max chars=250)
    Description for this charge
  - `taxable` (optional, boolean)
    The amount to be charged is taxable or not.
  - `tax_profile_id` (optional, string, max chars=50)
    Tax profile of the charge.
  - `avalara_tax_code` (optional, string, max chars=50)
    The Avalara tax codes to which items are mapped to should be provided here. Applicable only if you use Chargebee's [AvaTax for Sales integration](https://www.chargebee.com/docs/avalara.html) .
  - `hsn_code` (optional, string, max chars=50)
    The [HSN code](https://cbic-gst.gov.in/gst-goods-services-rates.html) to which the item is mapped for calculating the customer's tax in India. Applicable only when both of the following conditions are true:
    
    -   [**India**](https://www.chargebee.com/docs/indian-gst.html#configuring-indian-gst) has been enabled as a **Tax Region**. (An error is returned when this condition is not true.)
    -   The [**AvaTax for Sales** integration](https://www.chargebee.com/docs/avalara.html) has been enabled in Chargebee.
  - `taxjar_product_code` (optional, string, max chars=50)
    The TaxJar product codes to which items are mapped to should be provided here. Applicable only if you use Chargebee's [TaxJar integration](https://www.chargebee.com/docs/taxjar.html) .
  - `avalara_sale_type` (optional, enumerated string)
    Indicates the type of sale carried out. 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:
      - `wholesale`
        Transaction is a sale to another company that will resell your product or service to another consumer
      - `retail`
        Transaction is a sale to an end user
      - `consumed`
        Transaction is for an item that is consumed directly
      - `vendor_use`
        Transaction is for an item that is subject to vendor use tax
  - `avalara_transaction_type` (optional, integer)
    Indicates the type of product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
  - `avalara_service_type` (optional, integer)
    Indicates the type of service for the product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
  - `date_from` (optional, timestamp(UTC) in seconds)
    The time when the service period for the charge starts.
  - `date_to` (optional, timestamp(UTC) in seconds)
    The time when the service period for the charge ends.

- `tax_providers_fields` (optional, array)
  Parameters for tax\_providers\_fields
  - `provider_name` (optional, string, max chars=50)
    Name of the tax provider currently supported.
  - `field_id` (optional, string, max chars=50)
    Field id of the attribute which tax vendor has provided while getting onboarded with us.
  - `field_value` (optional, string, max chars=50)
    The value of the corresponding tax field.

## Returns

- `unbilled_charges` (always returned)
  Resource object representing unbilled\_charge
