# Import invoice

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


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

Imports an invoice into Chargebee Billing.

Use this API to import invoices from your other billing or accounting system into Chargebee Billing. You can import both current-term and historical invoices.

**Caution: Importing current-term invoices** To ensure accurate [proration](https://www.chargebee.com/docs/billing/2.0/subscriptions/proration#proration) for any changes to the subscription in the current term, import only one current-term invoice. Chargebee considers only the first imported invoice for the current term when calculating proration. If you have multiple invoices for the current term in the source system, consolidate them into a single invoice before importing it into Chargebee.

### Impacts

**

RevenueStory

**

-   You must run the [MRR History Builder](https://www.chargebee.com/docs/billing/2.0/reports-and-analytics/monthly-recurring-revenue#how-are-the-metrics-calculated-from-historical-data) to update Revenue Story metrics after importing invoices. [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 do this.

**

Accounting Integrations

**

-   Chargebee Billing [accounting integrations](https://www.chargebee.com/docs/billing/2.0/integrations/finance-integration-index) sync imported invoices, unless you disable them from syncing.

### Implementation Notes

-   If discounts are present on the invoice, then the following parameters must be passed:
    -   `discounts[entity_type][]`
    -   `discounts[amount][]`
    -   `discounts[line_item_id][i]` if `discounts[entity_type][i]` is `item_level_coupon` or `document_level_coupon`.
-   If taxes are present on the invoice, then the following parameters must be passed:
    -   `taxes[name][]`
    -   `taxes[rate][]`
    -   `line_items[tax*_name][]`
    -   `line_items[tax*_amount][]`

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/import_invoice \
     -u {site_api_key}:\
     -d id="old_inv_001" \
     -d customer_id="__test__8asyKSOcTJGo2N" \
     -d subscription_id="__test__8asyKSOcTJMw2U" \
     -d date=1517490271 \
     -d total=4900 \
     -d status="PAYMENT_DUE" \
     -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" \
     -d "line_items[date_from][0]"=1517490271 \
     -d "line_items[date_to][0]"=1519909471 \
     -d "line_items[description][0]"="Standard" \
     -d "line_items[unit_amount][0]"=4900 \
     -d "line_items[quantity][0]"=1 \
     -d "line_items[entity_type][0]"="PLAN_ITEM_PRICE" \
     -d "line_items[entity_id][0]"="standard-USD"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Invoice.ImportInvoice()
		.Id("old_inv_001")
		.CustomerId("__test__8asyKSOcTJGo2N")
		.SubscriptionId("__test__8asyKSOcTJMw2U")
		.Date(1517490271)
		.Total(4900)
		.Status(Invoice.StatusEnum.PaymentDue)
		.BillingAddressFirstName("John")
		.BillingAddressLastName("Doe")
		.BillingAddressLine1("PO Box 9999")
		.BillingAddressCity("Walnut")
		.BillingAddressState("California")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.LineItemDateFrom(0, 1517490271)
		.LineItemDateTo(0, 1519909471)
		.LineItemDescription(0, "Standard")
		.LineItemUnitAmount(0, 4900)
		.LineItemQuantity(0, 1)
		.LineItemEntityType(0, Invoice.InvoiceLineItem.EntityTypeEnum.PlanItemPrice)
		.LineItemEntityId(0, "standard-USD")
		.Request();

Invoice invoice = result.Invoice;
CreditNote creditNote = result.CreditNote;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    invoiceAction "github.com/chargebee/chargebee-go/v3/actions/invoice"
    "github.com/chargebee/chargebee-go/v3/models/invoice"
    invoiceEnum "github.com/chargebee/chargebee-go/v3/models/invoice/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceAction.ImportInvoice(&invoice.ImportInvoiceRequestParams{
        LineItems : []*invoice.ImportInvoiceLineItemParams{
            {
                DateFrom : chargebee.Int64(1517490271),
                DateTo : chargebee.Int64(1519909471),
                Description : "Standard",
                UnitAmount : chargebee.Int64(4900),
                Quantity : chargebee.Int32(1),
                EntityType : invoiceEnum.LineItemEntityTypePlanItemPrice,
                EntityId : "standard-USD",
            },
        },
        Id : "old_inv_001",
        CustomerId : "__test__8asyKSOcTJGo2N",
        SubscriptionId : "__test__8asyKSOcTJMw2U",
        Date : chargebee.Int64(1517490271),
        Total : chargebee.Int64(4900),
        Status : invoiceEnum.StatusPaymentDue,
        BillingAddress : &invoice.ImportInvoiceBillingAddressParams{
            FirstName : "John",
            LastName : "Doe",
            Line1 : "PO Box 9999",
            City : "Walnut",
            State : "California",
            Zip : "91789",
            Country : "US",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
        CreditNote := res.CreditNote
    }
}
```

#### 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.InvoiceImportInvoiceRequest{
    LineItems : []*chargebee.InvoiceImportInvoiceLineItem{
        {
            DateFrom : chargebee.Int64(1517490271),
            DateTo : chargebee.Int64(1519909471),
            Description : "Standard",
            UnitAmount : chargebee.Int64(4900),
            Quantity : chargebee.Int32(1),
            EntityType : chargebee.InvoiceLineItemEntityTypePlanItemPrice,
            EntityId : "standard-USD",
        },
    },
    Id : "old_inv_001",
    CustomerId : "__test__8asyKSOcTJGo2N",
    SubscriptionId : "__test__8asyKSOcTJMw2U",
    Date : chargebee.Int64(1517490271),
    Total : chargebee.Int64(4900),
    Status : chargebee.InvoiceStatusPaymentDue,
    BillingAddress : &chargebee.InvoiceImportInvoiceBillingAddress{
        FirstName : "John",
        LastName : "Doe",
        Line1 : "PO Box 9999",
        City : "Walnut",
        State : "California",
        Zip : "91789",
        Country : "US",
    },
}
  res, err := client.Invoice.ImportInvoice(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
        CreditNote := res.CreditNote
    }
}
```

#### Java

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

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Invoice.importInvoice()
            .id("old_inv_001")
            .customerId("__test__8asyKSOcTJGo2N")
            .subscriptionId("__test__8asyKSOcTJMw2U")
            .date(new Timestamp(1517490271L * 1000))
            .total(4900L)
            .status(Invoice.Status.PAYMENT_DUE)
            .billingAddressFirstName("John")
            .billingAddressLastName("Doe")
            .billingAddressLine1("PO Box 9999")
            .billingAddressCity("Walnut")
            .billingAddressState("California")
            .billingAddressZip("91789")
            .billingAddressCountry("US")
            .lineItemDateFrom(0, new Timestamp(1517490271L * 1000))
            .lineItemDateTo(0, new Timestamp(1519909471L * 1000))
            .lineItemDescription(0, "Standard")
            .lineItemUnitAmount(0, 4900L)
            .lineItemQuantity(0, 1)
            .lineItemEntityType(0, Invoice.LineItem.EntityType.PLAN_ITEM_PRICE)
            .lineItemEntityId(0, "standard-USD")
            .request();

        Invoice invoice = result.invoice();
        CreditNote creditNote = result.creditNote();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.creditNote.CreditNote;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoice.params.ImportInvoiceParams;
import com.chargebee.v4.models.invoice.responses.ImportInvoiceResponse;
import java.sql.Timestamp;
import java.util.List;

public class ImportInvoice {

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

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

        ImportInvoiceParams.LineItemsParams lineItem0 =
            ImportInvoiceParams.LineItemsParams.builder()
                .dateFrom(new Timestamp(1517490271L * 1000))
                .dateTo(new Timestamp(1519909471L * 1000))
                .description("Standard")
                .unitAmount(4900L)
                .quantity(1)
                .entityType(ImportInvoiceParams.LineItemsParams.EntityType.PLAN_ITEM_PRICE)
                .entityId("standard-USD")
                .build();

        List<ImportInvoiceParams.LineItemsParams> lineItemsList =
            List.of(lineItem0);

        ImportInvoiceParams params = ImportInvoiceParams.builder()
            .id("old_inv_001")
            .customerId("__test__8asyKSOcTJGo2N")
            .subscriptionId("__test__8asyKSOcTJMw2U")
            .date(new Timestamp(1517490271L * 1000))
            .total(4900L)
            .status(ImportInvoiceParams.Status.PAYMENT_DUE)
            .billingAddress(billingAddressParams)
            .lineItems(lineItemsList)
            .build();

        ImportInvoiceResponse response = client.invoices().importInvoice(params);

        Invoice invoice = response.getInvoice();
        CreditNote creditNote = response.getCreditNote();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoice.importInvoice({
        line_items: [
            {
                date_from: 1517490271,
                date_to: 1519909471,
                description: "Standard",
                unit_amount: 4900,
                quantity: 1,
                entity_type: "plan_item_price",
                entity_id: "standard-USD"
            }
        ],
        id: "old_inv_001",
        customer_id: "__test__8asyKSOcTJGo2N",
        subscription_id: "__test__8asyKSOcTJMw2U",
        date: 1517490271,
        total: 4900,
        status: "payment_due",
        billing_address: {
            first_name: "John",
            last_name: "Doe",
            line1: "PO Box 9999",
            city: "Walnut",
            state: "California",
            zip: 91789,
            country: "US"
        }
    });

    console.log(result);
    const invoice = result.invoice;
    const creditNote = result.credit_note;
} 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->invoice()->importInvoice([
    "line_items" => [
        [
            "date_from" => 1517490271,
            "date_to" => 1519909471,
            "description" => "Standard",
            "unit_amount" => 4900,
            "quantity" => 1,
            "entity_type" => "plan_item_price",
            "entity_id" => "standard-USD"
        ]
    ],
    "id" => "old_inv_001",
    "customer_id" => "__test__8asyKSOcTJGo2N",
    "subscription_id" => "__test__8asyKSOcTJMw2U",
    "date" => 1517490271,
    "total" => 4900,
    "status" => "payment_due",
    "billing_address" => [
        "first_name" => "John",
        "last_name" => "Doe",
        "line1" => "PO Box 9999",
        "city" => "Walnut",
        "state" => "California",
        "zip" => "91789",
        "country" => "US"
    ]
]);
$invoice = $result->invoice;
$creditNote = $result->credit_note;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Invoice.import_invoice(
    cb_client.Invoice.ImportInvoiceParams(
        line_items=[
            cb_client.Invoice.ImportInvoiceLineItemParams(
              date_from=1517490271,
              date_to=1519909471,
              description="Standard",
              unit_amount=4900,
              quantity=1,
              entity_type=chargebee.Invoice.LineItemEntityType.PLAN_ITEM_PRICE,
              entity_id="standard-USD"
            )
        ],
        id="old_inv_001",
        customer_id="__test__8asyKSOcTJGo2N",
        subscription_id="__test__8asyKSOcTJMw2U",
        date=1517490271,
        total=4900,
        status=chargebee.Invoice.Status.PAYMENT_DUE,
        billing_address=cb_client.Invoice.ImportInvoiceBillingAddressParams(
            first_name="John",
            last_name="Doe",
            line1="PO Box 9999",
            city="Walnut",
            state="California",
            zip="91789",
            country="US"
        )
    )
)
invoice = response.invoice
credit_note = response.credit_note
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Invoice.import_invoice({
  :id => "old_inv_001",
  :customer_id => "__test__8asyKSOcTJGo2N",
  :subscription_id => "__test__8asyKSOcTJMw2U",
  :date => 1517490271,
  :total => 4900,
  :status => "PAYMENT_DUE",
  :billing_address => {
    :first_name => "John",
    :last_name => "Doe",
    :line1 => "PO Box 9999",
    :city => "Walnut",
    :state => "California",
    :zip => "91789",
    :country => "US"
  },
  :line_items => [
    {
      :date_from => 1517490271,
      :date_to => 1519909471,
      :description => "Standard",
      :unit_amount => 4900,
      :quantity => 1,
      :entity_type => "PLAN_ITEM_PRICE",
      :entity_id => "standard-USD"
    }
  ]
})

invoice = result.invoice
credit_note = result.credit_note
```

## Sample Response

```json
{
  "invoice": {
    "adjustment_credit_notes": {},
    "amount_adjusted": 0,
    "amount_due": 4900,
    "amount_paid": 0,
    "amount_to_collect": 4900,
    "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",
      "validation_status": "not_validated",
      "zip": "91789"
    },
    "credits_applied": 0,
    "currency_code": "USD",
    "customer_id": "__test__8asyKSOcTJGo2N",
    "date": 1517490271,
    "deleted": false,
    "due_date": 1517490271,
    "dunning_attempts": {},
    "exchange_rate": 1,
    "first_invoice": false,
    "has_advance_charges": false,
    "id": "old_inv_001",
    "is_gifted": false,
    "issued_credit_notes": {},
    "line_items": [
      {
        "amount": 4900,
        "customer_id": "__test__8asyKSOcTJGo2N",
        "date_from": 1517490271,
        "date_to": 1519909471,
        "description": "Standard",
        "discount_amount": 0,
        "entity_id": "standard-USD",
        "entity_type": "plan_item_price",
        "id": "li___test__8asyKSOcTJYG2e",
        "is_taxed": false,
        "item_level_discount_amount": 0,
        "object": "line_item",
        "pricing_model": "per_unit",
        "quantity": 1,
        "subscription_id": "__test__8asyKSOcTJMw2U",
        "tax_amount": 0,
        "tax_exempt_reason": "tax_not_configured",
        "unit_amount": 4900
      },
      {..}
    ],
    "linked_orders": {},
    "linked_payments": {},
    "net_term_days": 0,
    "object": "invoice",
    "price_type": "tax_exclusive",
    "recurring": true,
    "resource_version": 1517490271788,
    "round_off_amount": 0,
    "status": "payment_due",
    "sub_total": 4900,
    "subscription_id": "__test__8asyKSOcTJMw2U",
    "tax": 0,
    "term_finalized": true,
    "total": 4900,
    "updated_at": 1517490271,
    "write_off_amount": 0
  }
}
```

## URL Format

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

## Input Parameters

- `id` (required, string, max chars=50)
  The invoice ID (also known as the invoice number). Must be unique so that it does not conflict with any existing `invoice.id`.

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

- `customer_id` (optional, string, max chars=50)
  Identifier of the [customer](/docs/api/customers) resource to which this invoice belongs.

- `subscription_id` (optional, string, max chars=50)
  The ID of the [subscription](/docs/api/subscriptions) resource to which this invoice belongs.

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

- `price_type` (optional, enumerated string, default=tax_exclusive)
  The price type of the invoice.
  Possible enum values:
    - `tax_exclusive`
      All amounts in the document are exclusive of tax.
    - `tax_inclusive`
      All amounts in the document are inclusive of tax.

- `tax_override_reason` (optional, enumerated string)
  The reason for exempting the invoice from tax. (Applicable only for exempted invoices.).
  Possible enum values:
    - `zero_rated`
      If the rate of tax is 0% and no Sales/ GST tax is collectable for that line item
    - `id_exempt`
      The customer is from a different country than your business and they have a valid VAT number or, the customer is a business entity. (This reason is only applicable when [EU VAT](https://www.chargebee.com/docs/eu-vat.html) or [UK VAT](https://www.chargebee.com/docs/uk-vat.html) is enabled.)
    - `customer_exempt`
      The customer is [exempted](/docs/api/customers/customer-object#taxability) from tax.
    - `region_non_taxable`
      If the product sold is not taxable in this region, but it is taxable in other regions, hence this region is not part of the Taxable jurisdiction
    - `product_exempt`
      If the Plan or Addon is marked as Tax exempt
    - `export`
      The customer is from a non-taxable region or the billing address and shipping address are unavailable.
    - `high_value_physical_goods`
      If physical goods are sold from outside Australia to customers in Australia, and the price of all the physical good line items is greater than AUD 1000, then tax will not be applied
    - `zero_value_item`
      If the total invoice value/amount is equal to zero. E.g., If the total order value is $10 and a $10 coupon has been applied against that order, the total order value becomes $0. Hence the invoice value also becomes $0.
    - `tax_not_configured_external_provider`
      If the tax is not configured for the country in 3rd party tax provider.

- `vat_number` (optional, string, max chars=20)
  Vat Number. Required if this invoice is VAT exempted.

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

- `date` (required, timestamp(UTC) in seconds)
  Date when invoice raised.

- `total` (required, in cents, min=0)
  Invoice total amount.

- `round_off` (optional, in cents, min=-99, max=99)
  [Round off amount](/docs/api/invoices/invoice-object#round_off_amount).

- `status` (optional, enumerated string)
  Current status of this invoice.
  Possible enum values:
    - `paid`
      Indicates a paid invoice.
    - `posted`
      Indicates the payment is not yet collected and will be in this state till the due date to indicate the due period.
    - `payment_due`
      Indicates the payment is not yet collected and is being retried as per retry settings.
    - `not_paid`
      Indicates the payment is not made and all attempts to collect is failed.
    - `voided`
      Indicates a voided invoice.
    - `pending`
      The [invoice](/docs/api/invoices/invoice-object#status) is yet to be closed (sent for payment collection). An invoice is generated with this `status` when it has line items that belong to items that are `metered` or when the `subscription.create_pending_invoices`attribute is set to `true`. The [invoice](/docs/api/v2/pcv-1/invoices/invoice-object#status) is yet to be closed (sent for payment collection). All invoices are generated with this `status` when [Metered Billing](https://www.chargebee.com/docs/1.0/metered_billing.html) is enabled for the site.

- `voided_at` (optional, timestamp(UTC) in seconds)
  Timestamp indicating the date & time this invoice got voided.

- `void_reason_code` (optional, string, max chars=100)
  Reason code for voiding the invoice. Select from a list of reason codes set in the Chargebee app in **Settings > Configure Chargebee > Reason Codes > Invoices > Void invoice**. Must be passed if set as mandatory in the app. The codes are case-sensitive.

- `is_written_off` (optional, boolean, default=false)
  If is\_written\_off is true then the invoice is written off.

- `write_off_amount` (optional, in cents, default=0, min=0)
  Amount written off against this invoice. If this value is not present then the due amount of the invoice will be written off.

- `write_off_date` (optional, timestamp(UTC) in seconds)
  The date on which the write\_off invoice has occurred. This is a mandatory field if is\_written\_off is true. The same date reflects on the created credit note.

- `due_date` (optional, timestamp(UTC) in seconds)
  The due date of the invoice.

- `net_term_days` (optional, integer, default=0)
  The number of days from [`invoice.date`](/docs/api/invoices/invoice-object#date) until payment for the invoice is due.

- `has_advance_charges` (optional, boolean, default=false)
  Boolean indicating any advance charge is present in this invoice.

- `use_for_proration` (optional, boolean, default=false)
  If the invoice falls within the subscription current term will be used for proration.

- `paid_at` (optional, timestamp(UTC) in seconds)
  Timestamp when the invoice was paid. Applicable only when `status` is `paid`.

- `credit_note` (optional, string)
  Parameters for credit\_note
  - `id` (optional, string, max chars=50)
    A unique identifier for the credit note.
    
    This is a mandatory field if is\_written\_off is true.

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

- `line_items` (optional, array)
  Parameters for line\_items
  - `id` (optional, string, max chars=40)
    Uniquely identifies a line\_item
  - `date_from` (optional, timestamp(UTC) in seconds)
    Start date of this line item.
  - `date_to` (optional, timestamp(UTC) in seconds)
    End date of this line item.
  - `subscription_id` (optional, string, max chars=50)
    A unique identifier for the [subscription](/docs/api/subscriptions) resource to which this line item belongs.
    
    **Note**
    
    -   When multiple different `line_items.subscription_id[]` are specified, this indicates a [consolidated invoice](https://www.chargebee.com/docs/billing/2.0/invoices-credit-notes-and-quotes/consolidated-invoicing).
  - `description` (required, string, max chars=250)
    Description for this line item. Append `- prorated charges` to the description if the line item is prorated. This will prevent it from being considered for [MRR](/docs/api/subscriptions/subscription-object#mrr) calculations.
  - `unit_amount` (optional, in cents)
    Unit amount of the line item.
  - `quantity` (optional, integer)
    [Quantity of the recurring item](/docs/api/invoices/invoice-object#line_items_quantity) which is represented by this line item. For `metered` line items, this value is updated from [usages](/docs/api/usages) once when the invoice is generated as `pending` and finally when the invoice is [closed](/docs/api/invoices/close-a-pending-invoice). [Quantity of the recurring item](/docs/api/v2/pcv-1/invoices/invoice-object#line_items_quantity) which is represented by this line item.
  - `amount` (optional, in cents)
    Total amount of this lineitem. Not required if the line\_items\[unit\_amount\] param is passed
  - `unit_amount_in_decimal` (optional, string, max chars=39)
    The decimal representation of the unit amount of the `line_item`. The value is in major units of the currency. Returned when the `line_item` is quantity-based and [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of this entity. Returned when the entity is quantity-based and [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `amount_in_decimal` (optional, string, max chars=39)
    The decimal representation of the amount for the `line_item` , in major units of the currency. Typically equals to `unit_amount_in_decimal` x `quantity_in_decimal`. Returned when [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `entity_type` (optional, enumerated string)
    Specifies the modelled entity this line item is based on.
    Possible enum values:
      - `adhoc`
        Indicates that this lineitem is not modelled. i.e created adhoc. So the 'entity\_id' attribute will be null in this case
      - `plan_item_price`
        Indicates that this line item corresponds to an `item_price` of `item_type` `plan`.
      - `addon_item_price`
        Indicates that this line item corresponds to an `item_price` of `item_type` `addon`.
      - `charge_item_price`
        Indicates that this line item corresponds to an `item_price` of `item_type` `charge`.
  - `entity_id` (optional, string, max chars=100)
    The ID of the entity that this line item corresponds to.
  - `item_level_discount1_entity_id` (optional, string, max chars=100)
    First item level discount entity id
  - `item_level_discount1_amount` (optional, in cents)
    First item level discount amount
  - `item_level_discount2_entity_id` (optional, string, max chars=100)
    Second item level discount entity id
  - `item_level_discount2_amount` (optional, in cents)
    Second item level discount amount
  - `tax1_name` (optional, string, max chars=50)
    First tax name
  - `tax1_amount` (optional, in cents)
    First tax amount
  - `tax2_name` (optional, string, max chars=50)
    Second tax name
  - `tax2_amount` (optional, in cents)
    Second tax amount
  - `tax3_name` (optional, string, max chars=50)
    Third tax name
  - `tax3_amount` (optional, in cents)
    Third tax amount
  - `tax4_name` (optional, string, max chars=50)
    Fourth tax name
  - `tax4_amount` (optional, in cents)
    Fourth tax amount
  - `tax5_name` (optional, string, max chars=50)
    Fifth tax name
  - `tax5_amount` (optional, in cents)
    Fifth tax amount
  - `tax6_name` (optional, string, max chars=50)
    Sixth tax name
  - `tax6_amount` (optional, in cents)
    Sixth tax amount
  - `tax7_name` (optional, string, max chars=50)
    Seventh tax name
  - `tax7_amount` (optional, in cents)
    Seventh tax amount
  - `tax8_name` (optional, string, max chars=50)
    Eighth tax name
  - `tax8_amount` (optional, in cents)
    Eighth tax amount
  - `tax9_name` (optional, string, max chars=50)
    Ninth tax name
  - `tax9_amount` (optional, in cents)
    Ninth tax amount
  - `tax10_name` (optional, string, max chars=50)
    Tenth tax name
  - `tax10_amount` (optional, in cents)
    Tenth tax amount
  - `proration_mode` (optional, enumerated string)
    Proration mode for the line item.
    Possible enum values:
      - `reset`
      - `delta`
      - `service_period_revision`
      - `adjusted_term`
  - `created_at` (optional, timestamp(UTC) in seconds)

- `payment_reference_numbers` (optional, array)
  Parameters for payment\_reference\_numbers
  - `id` (optional, string, max chars=40)
    If `id` is not provided then our system will automatically generate a unique id.
  - `type` (required, enumerated string)
    This attribute helps `type` field in the API, specifies how to reconcile offline payments, and generate `payment_reference_number` on invoices based on country-specific rules. Setting the `type` field generates `payment_reference_number` for the respective country and includes them on the invoice for correct reconciliation.
    Possible enum values:
      - `kid`
        The KID number (kundeidentifikasjon) in Norway is an abbreviation for "Customer identification". It is used to associate payments with the customer and invoice.
      - `ocr`
        A OCR-based payment, contains an OCR reference, which is used to identify the vendor and the purchase document in connection with a payment. Swedish reference number can contain customer ID and/or invoice number to identify customer and invoice.
      - `frn`
        The reference number printed on invoices in Finland is utilized by buyers for payment via bank transfer, facilitating the association of payments with invoices.
      - `fik`
        Denmark based number calculated using recursive MOD 10 algorithm.
      - `swiss_reference`
        Switzerland based number calculated using the recursive MOD 10 algorithm for QR references, or the MOD 97 algorithm for ISO 11649 creditor references, based on the reference type.
  - `number` (required, string, max chars=100)
    If you have already generated a `payment_reference_number` in another system, you can provide it in this field. This number will then be made available to you both in PDF format and via the `/api/v2/invoices/payment_reference_numbers` API.

- `line_item_tiers` (optional, array)
  Parameters for line\_item\_tiers
  - `line_item_id` (required, string, max chars=40)
    Uniquely identifies a line\_item
  - `starting_unit` (optional, integer)
    The lower limit of a range of units for the tier
  - `ending_unit` (optional, integer)
    The upper limit of a range of units for the tier
  - `quantity_used` (optional, integer)
    The number of units purchased in a range.
  - `unit_amount` (optional, in cents)
    The price of the tier if the charge model is a `stairtstep` pricing , or the price of each unit in the tier if the charge model is `tiered` /`volume` pricing.
  - `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 `line_items.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 `line_items.pricing_model` is `tiered` , `volume` or stairstep and [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `quantity_used_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity purchased from this tier. Returned when the `line_item` is quantity-based and [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `unit_amount_in_decimal` (optional, string, max chars=40)
    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 `line_item`. The value is in major units of the currency. Returned when the `line_item` is quantity-based and [multi-decimal pricing](/docs/api/currencies) is enabled.

- `discounts` (optional, array)
  Parameters for discounts
  - `line_item_id` (optional, string, max chars=40)
    The unique id of the line item that this deduction is for.
  - `entity_type` (required, enumerated string)
    The type of deduction and the amount to which it is applied.
    Possible enum values:
      - `item_level_coupon`
        The deduction is due to a coupon applied to line item. The coupon `id` is passed as `entity_id` .
      - `document_level_coupon`
        The deduction is due to a coupon applied to the invoice `sub_total`. The coupon id is passed as `entity_id` .
      - `promotional_credits`
        The deduction is due to a [promotional credit](/docs/api/promotional_credits) applied to the invoice.
      - `item_level_discount`
        The deduction is due to a [discount](/docs/api/discounts) applied to a line item of the invoice. The discount `id` is available as the `entity_id`.
      - `document_level_discount`
        The deduction is due to a [discount](/docs/api/discounts) applied to the invoice `sub_total`. The discount `id` is available as the `entity_id`.
  - `entity_id` (optional, string, max chars=100)
    When the deduction is due to a `coupon` , then this is the `id` of the coupon.
  - `description` (optional, string, max chars=250)
    Description for this deduction.
  - `amount` (required, in cents)
    The amount deducted.

- `taxes` (optional, array)
  Parameters for taxes
  - `name` (required, string, max chars=100)
    The name of the tax applied.
  - `rate` (required, double)
    The rate of tax used to calculate tax amount.
    
    **Impacts**
    
    -   None. Although required, this parameter is not used by Chargebee.
  - `amount` (optional, in cents)
    Total tax amount charged for this invoice
  - `description` (optional, string, max chars=50)
    Description of tax
  - `juris_type` (optional, enumerated string)
    The type of tax jurisdiction
    Possible enum values:
      - `country`
        The tax jurisdiction is a country
      - `federal`
        The tax jurisdiction is a federal
      - `state`
        The tax jurisdiction is a state
      - `county`
        The tax jurisdiction is a county
      - `city`
        The tax jurisdiction is a city
      - `special`
        Special tax jurisdiction.
      - `unincorporated`
        Combined tax of state and county.
      - `other`
        Jurisdictions other than the ones listed above.
  - `juris_name` (optional, string, max chars=250)
    The name of the tax jurisdiction
  - `juris_code` (optional, string, max chars=250)
    The tax jurisdiction code

- `payments` (optional, array)
  Parameters for payments
  - `id` (optional, string, max chars=40)
  - `amount` (required, in cents)
    Payment made for this invoice.
  - `payment_method` (required, enumerated string)
    Mode of payment
    Possible enum values:
      - `cash`
        Cash
      - `check`
        Check
      - `bank_transfer`
        Bank Transfer
      - `other`
        Payment Methods other than the above types
      - `custom`
        Custom
      - `dana`
      - `touch_n_go`
      - `tamara`
      - `qpay`
      - `ovo`
      - `momo`
      - `mercado_pago`
      - `nequi`
      - `nupay`
      - `picpay`
      - `thai_qr`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
      - `rakuten_pay`
  - `date` (optional, timestamp(UTC) in seconds)
    Payment date
  - `reference_number` (optional, string, min chars=1, max chars=100)
    Reference number for this payment

- `notes` (optional, array)
  Parameters for notes
  - `entity_type` (optional, enumerated string)
    Type of entity to which the note belongs.
    Possible enum values:
      - `coupon`
        Entity that represents a coupon.
      - `plan_item_price`
        Indicates that this line item is based on plan Item Price
      - `addon_item_price`
        Indicates that this line item is based on addon Item Price
      - `charge_item_price`
        Indicates that this line item is based on charge Item Price
  - `entity_id` (optional, string, max chars=50)
    Id of the mentioned entity type.
  - `note` (optional, string, max chars=65k)
    Actual note.

- `line_item_addresses` (optional, array)
  The list of addresses used for tax calculation on line items.
  - `line_item_id` (optional, string, max chars=40)
    Line item reference
  - `first_name` (optional, string, max chars=150)
    First name of the customer
  - `last_name` (optional, string, max chars=150)
    Last name of the customer
  - `email` (optional, string, max chars=70)
    Email address of the customer
  - `company` (optional, string, max chars=250)
    Name of the company
  - `phone` (optional, string, max chars=50)
    Phone number of the customer
  - `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)
    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) 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)
    State or Province
  - `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 of the customer, specified as an [ISO 3166 alpha-2 code](https://www.iso.org/iso-3166-country-codes.html). Entering an invalid code will return an error.
    
    If [EU VAT](https://www.chargebee.com/docs/eu-vat.html) (2021 or later) or [Brexit configuration](https://www.chargebee.com/docs/brexit.html#what-needs-to-be-done-in-chargebee) is enabled, 'United Kingdom-Northern Ireland' is a valid option.
  - `validation_status` (optional, enumerated string)
    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.

## Returns

- `invoice` (Invoice object)
  Resource object representing invoice

- `credit_note` (Credit note object)
  Resource object representing credit\_note
