# Create a quote for charges and charge items

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


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

Creates a quote using charge-items and one-time charges.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/quotes/create_for_charge_items_and_charges \
     -u {site_api_key}:\
     -d customer_id="__test__KyVlFpS4cWCm4J" \
     -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 = Quote.CreateForChargeItemsAndCharges()
		.CustomerId("__test__KyVlFpS4cWCm4J")
		.ItemPriceItemPriceId(0, "ssl-charge-USD")
		.Request();

Quote quote = result.Quote;
QuotedCharge quotedCharge = result.QuotedCharge;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    quoteAction "github.com/chargebee/chargebee-go/v3/actions/quote"
    "github.com/chargebee/chargebee-go/v3/models/quote"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := quoteAction.CreateForChargeItemsAndCharges(&quote.CreateForChargeItemsAndChargesRequestParams{
        ItemPrices : []*quote.CreateForChargeItemsAndChargesItemPriceParams{
            {
                ItemPriceId : "ssl-charge-USD",
            },
        },
        CustomerId : "__test__KyVlFpS4cWCm4J",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Quote := res.Quote
        QuotedCharge := res.QuotedCharge
    }
}
```

#### 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.QuoteCreateForChargeItemsAndChargesRequest{
    ItemPrices : []*chargebee.QuoteCreateForChargeItemsAndChargesItemPrice{
        {
            ItemPriceId : "ssl-charge-USD",
        },
    },
    CustomerId : "__test__KyVlFpS4cWCm4J",
}
  res, err := client.Quote.CreateForChargeItemsAndCharges(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Quote := res.Quote
        QuotedCharge := res.QuotedCharge
    }
}
```

#### Java

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

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Quote.createForChargeItemsAndCharges()
            .customerId("__test__KyVlFpS4cWCm4J")
            .itemPriceItemPriceId(0, "ssl-charge-USD")
            .request();

        Quote quote = result.quote();
        QuotedCharge quotedCharge = result.quotedCharge();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.quote.Quote;
import com.chargebee.v4.models.quote.params.QuoteCreateForChargeItemsAndChargesParams;
import com.chargebee.v4.models.quote.responses.QuoteCreateForChargeItemsAndChargesResponse;
import com.chargebee.v4.models.quotedCharge.QuotedCharge;
import java.util.List;

public class QuoteCreateForChargeItemsAndCharges {

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

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

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

        QuoteCreateForChargeItemsAndChargesParams params = QuoteCreateForChargeItemsAndChargesParams.builder()
            .customerId("__test__KyVlFpS4cWCm4J")
            .itemPrices(itemPricesList)
            .build();

        QuoteCreateForChargeItemsAndChargesResponse response = client.quotes().createForChargeItemsAndCharges(params);

        Quote quote = response.getQuote();
        QuotedCharge quotedCharge = response.getQuotedCharge();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.quote.createForChargeItemsAndCharges({
        item_prices: [
            {
                item_price_id: "ssl-charge-USD"
            }
        ],
        customer_id: "__test__KyVlFpS4cWCm4J"
    });

    console.log(result);
    const quote = result.quote;
    const quotedCharge = result.quoted_charge;
} 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->quote()->createForChargeItemsAndCharges([
    "item_prices" => [
        [
            "item_price_id" => "ssl-charge-USD"
        ]
    ],
    "customer_id" => "__test__KyVlFpS4cWCm4J"
]);
$quote = $result->quote;
$quotedCharge = $result->quoted_charge;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Quote.create_for_charge_items_and_charges(
    cb_client.Quote.CreateForChargeItemsAndChargesParams(
        item_prices=[
            cb_client.Quote.CreateForChargeItemsAndChargesItemPriceParams(
              item_price_id="ssl-charge-USD"
            )
        ],
        customer_id="__test__KyVlFpS4cWCm4J"
    )
)
quote = response.quote
quoted_charge = response.quoted_charge
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Quote.create_for_charge_items_and_charges({
  :customer_id => "__test__KyVlFpS4cWCm4J",
  :item_prices => [
    {
      :item_price_id => "ssl-charge-USD"
    }
  ]
})

quote = result.quote
quoted_charge = result.quoted_charge
```

## Sample Response

```json
{
  "quote": {
    "amount_due": 500,
    "amount_paid": 0,
    "billing_address": {
      "first_name": "John",
      "last_name": "Doe",
      "object": "billing_address",
      "validation_status": "not_validated"
    },
    "charge_on_acceptance": 500,
    "credits_applied": 0,
    "currency_code": "USD",
    "customer_id": "__test__KyVlFpS4cWCm4J",
    "date": 1517485104,
    "id": "2",
    "line_item_discounts": {},
    "line_item_taxes": {},
    "line_items": [
      {
        "amount": 500,
        "customer_id": "__test__KyVlFpS4cWCm4J",
        "date_from": 1517485104,
        "date_to": 1517485104,
        "description": "SSL Charge USD Monthly",
        "discount_amount": 0,
        "entity_id": "ssl-charge-USD",
        "entity_type": "charge_item_price",
        "id": "__test__KyVlFpS4cWCzmS",
        "is_taxed": false,
        "item_level_discount_amount": 0,
        "object": "line_item",
        "pricing_model": "flat_fee",
        "quantity": 1,
        "tax_amount": 0,
        "unit_amount": 500
      },
      {..}
    ],
    "object": "quote",
    "operation_type": "onetime_invoice",
    "price_type": "tax_exclusive",
    "resource_version": 1517485104000,
    "status": "open",
    "sub_total": 500,
    "taxes": {},
    "total": 500,
    "total_payable": 500,
    "updated_at": 1517485104,
    "valid_till": 1517596199,
    "version": 1
  }
}
```

## URL Format

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

## Input Parameters

- `name` (optional, string, max chars=100)
  The quote name will be used as the pdf name of the quote.

- `customer_id` (required, string, max chars=50)
  Identifier of the customer for which the quote needs to be created.

- `po_number` (optional, string, max chars=100)
  Purchase Order Number for this quote.

- `notes` (optional, string, max chars=10000)
  Notes specific to this quote that you want customers to see on the quote PDF.

- `expires_at` (optional, timestamp(UTC) in seconds)
  Quotes will be valid till this date. After this quote will be marked as closed.

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

- `coupon` (optional, string, max chars=100)
  The 'One Time' coupon to be applied.

- `coupon_ids` (optional, string, max chars=100)
  List of Coupons to be added.

- `net_term_days` (optional, integer)
  The number of days from [`invoice.date`](/docs/api/invoices/invoice-object#date) until payment for the invoice is due.
  
  **Prerequisite** You can use this parameter only when Chargebee CPQ is enabled. Contact [Chargebee Support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team) to request access.

- `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://i18napis.appspot.com/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.

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

- `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/getting-started) 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/getting-started) .
  - `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/getting-started) is enabled.
  - `service_period_days` (optional, integer)
    Defines service period of the item in days from the day of charge.

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

- `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. The value is in [major units of the currency](/docs/api/getting-started). Applicable only when multi-decimal pricing is enabled.
  - `description` (optional, string, max chars=250)
    Description for this charge
  - `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.
  - `service_period` (optional, integer)
    Service period for charge

- `discounts` (optional, array)
  Parameters for discounts
  - `percentage` (optional, double)
    The percentage of the original amount that should be deducted from it.
  - `quantity` (optional, integer)
    Specifies the number of free units provided for the item, without affecting the total quantity sold
  - `amount` (optional, in cents)
    The value of the discount. [The format of this value](/docs/api/currencies) depends on the kind of currency.
  - `apply_on` (required, enumerated string)
    The amount on the quote to which the discount is applied.
    Possible enum values:
      - `invoice_amount`
        The discount is applied to the invoice `sub_total` .
      - `specific_item_price`
        The discount is applied to the `invoice.line_item.amount` that corresponds to the item price specified by `item_price_id` .
  - `item_price_id` (optional, string, max chars=100)
    The [id of the item price](/docs/api/subscriptions/subscription-object#subscription_items_item_price_id) in the subscription to which the discount is to be applied. Relevant only when `apply_on` = `specific_item_price`.

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

## Returns

- `quote` (Quote object)
  Resource object representing quote

- `quoted_charge` (Quoted charge object)
  Resource object representing quoted\_charge
