# Import credit note

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


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

Imports a credit note into Chargebee Billing. This endpoint allows you to import a credit note from external systems, such as accounting software, into Chargebee.

Use this operation during data migration or reconciliation to ensure historical credits are represented in the system. The credit note is linked to a reference [invoice](/docs/api/invoices) and can be allocated to other invoices or recorded as refunded to the customer.

### Impacts

**

Credit Note

**

The credit note's [`billing_address`](/docs/api/credit_notes/credit-note-object#credit_note_billing_address), [`shipping_address`](/docs/api/credit_notes/credit-note-object#credit_note_shipping_address), and [`vat_number`](/docs/api/credit_notes/credit-note-object#credit_note_vat_number) are copied from the reference invoice.

**

Invoices

**

##### Reference invoice[](#reference-invoice)

-   See [Impact on reference invoice](/docs/api/credit_notes/credit-note-object#ref-invoice-impact).

##### Other invoices[](#other-invoices)

-   If `allocations[]` are provided, then for each allocated invoice:
    -   the invoice's `amount_due` decreases by the allocated amount
    -   the invoice `status` changes to `paid` if the `amount_due` becomes zero
    -   an [applied credit](/docs/api/invoices/invoice-object#applied_credits) record is created to track the allocation.

**

Transactions

**

If `linked_refunds[]` are provided, then for each refund provided, a [`transaction`](/docs/api/transactions/transaction-object) of `type` `refund` is created with `status` set to `success`.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/credit_notes/import_credit_note \
     -u {site_api_key}:\
     -d id="old_cn_001" \
     -d customer_id="__test__XpbBxQiS4HD1nWYL" \
     -d subscription_id="__test__XpbBxQiS4HD1nWYL" \
     -d reference_invoice_id="__demo_inv__7" \
     -d type="REFUNDABLE" \
     -d currency_code="USD" \
     -d create_reason_code="Product Unsatisfactory" \
     -d date=1517429430 \
     -d total=4900 \
     -d status="REFUND_DUE" \
     -d "line_items[date_from][0]"=1517429430 \
     -d "line_items[date_to][0]"=1519848630 \
     -d "line_items[description][0]"="Support Charge" \
     -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]"="plan1"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = CreditNote.ImportCreditNote()
		.Id("old_cn_001")
		.CustomerId("__test__XpbBxQiS4HD1nWYL")
		.SubscriptionId("__test__XpbBxQiS4HD1nWYL")
		.ReferenceInvoiceId("__demo_inv__7")
		.Type(CreditNote.TypeEnum.Refundable)
		.CurrencyCode("USD")
		.CreateReasonCode("Product Unsatisfactory")
		.Date(1517429430)
		.Total(4900)
		.Status(CreditNote.StatusEnum.RefundDue)
		.LineItemDateFrom(0, 1517429430)
		.LineItemDateTo(0, 1519848630)
		.LineItemDescription(0, "Support Charge")
		.LineItemUnitAmount(0, 4900)
		.LineItemQuantity(0, 1)
		.LineItemEntityType(0, CreditNote.CreditNoteLineItem.EntityTypeEnum.PlanItemPrice)
		.LineItemEntityId(0, "plan1")
		.Request();

CreditNote creditNote = result.CreditNote;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    creditnoteAction "github.com/chargebee/chargebee-go/v3/actions/creditnote"
    "github.com/chargebee/chargebee-go/v3/models/creditnote"
    creditNoteEnum "github.com/chargebee/chargebee-go/v3/models/creditnote/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := creditnoteAction.ImportCreditNote(&creditnote.ImportCreditNoteRequestParams{
        LineItems : []*creditnote.ImportCreditNoteLineItemParams{
            {
                DateFrom : chargebee.Int64(1517429430),
                DateTo : chargebee.Int64(1519848630),
                Description : "Support Charge",
                UnitAmount : chargebee.Int64(4900),
                Quantity : chargebee.Int32(1),
                EntityType : creditNoteEnum.LineItemEntityTypePlanItemPrice,
                EntityId : "plan1",
            },
        },
        Id : "old_cn_001",
        CustomerId : "__test__XpbBxQiS4HD1nWYL",
        SubscriptionId : "__test__XpbBxQiS4HD1nWYL",
        ReferenceInvoiceId : "__demo_inv__7",
        Type : creditNoteEnum.TypeRefundable,
        CurrencyCode : "USD",
        CreateReasonCode : "Product Unsatisfactory",
        Date : chargebee.Int64(1517429430),
        Total : chargebee.Int64(4900),
        Status : creditNoteEnum.StatusRefundDue,
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        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.CreditNoteImportCreditNoteRequest{
    LineItems : []*chargebee.CreditNoteImportCreditNoteLineItem{
        {
            DateFrom : chargebee.Int64(1517429430),
            DateTo : chargebee.Int64(1519848630),
            Description : "Support Charge",
            UnitAmount : chargebee.Int64(4900),
            Quantity : chargebee.Int32(1),
            EntityType : chargebee.CreditNoteLineItemEntityTypePlanItemPrice,
            EntityId : "plan1",
        },
    },
    Id : "old_cn_001",
    CustomerId : "__test__XpbBxQiS4HD1nWYL",
    SubscriptionId : "__test__XpbBxQiS4HD1nWYL",
    ReferenceInvoiceId : "__demo_inv__7",
    Type : chargebee.CreditNoteTypeRefundable,
    CurrencyCode : "USD",
    CreateReasonCode : "Product Unsatisfactory",
    Date : chargebee.Int64(1517429430),
    Total : chargebee.Int64(4900),
    Status : chargebee.CreditNoteStatusRefundDue,
}
  res, err := client.CreditNote.ImportCreditNote(req)
      if err != nil {
        fmt.Println(err)
    } else {
        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 = CreditNote.importCreditNote()
            .id("old_cn_001")
            .customerId("__test__XpbBxQiS4HD1nWYL")
            .subscriptionId("__test__XpbBxQiS4HD1nWYL")
            .referenceInvoiceId("__demo_inv__7")
            .type(CreditNote.Type.REFUNDABLE)
            .currencyCode("USD")
            .createReasonCode("Product Unsatisfactory")
            .date(new Timestamp(1517429430L * 1000))
            .total(4900L)
            .status(CreditNote.Status.REFUND_DUE)
            .lineItemDateFrom(0, new Timestamp(1517429430L * 1000))
            .lineItemDateTo(0, new Timestamp(1519848630L * 1000))
            .lineItemDescription(0, "Support Charge")
            .lineItemUnitAmount(0, 4900L)
            .lineItemQuantity(0, 1)
            .lineItemEntityType(0, CreditNote.LineItem.EntityType.PLAN_ITEM_PRICE)
            .lineItemEntityId(0, "plan1")
            .request();

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

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.creditNote.CreditNote;
import com.chargebee.v4.models.creditNote.params.ImportCreditNoteParams;
import com.chargebee.v4.models.creditNote.responses.ImportCreditNoteResponse;
import java.sql.Timestamp;
import java.util.List;

public class ImportCreditNote {

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

        ImportCreditNoteParams.LineItemsParams lineItem0 =
            ImportCreditNoteParams.LineItemsParams.builder()
                .dateFrom(new Timestamp(1517429430L * 1000))
                .dateTo(new Timestamp(1519848630L * 1000))
                .description("Support Charge")
                .unitAmount(4900L)
                .quantity(1)
                .entityType(ImportCreditNoteParams.LineItemsParams.EntityType.PLAN_ITEM_PRICE)
                .entityId("plan1")
                .build();

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

        ImportCreditNoteParams params = ImportCreditNoteParams.builder()
            .id("old_cn_001")
            .customerId("__test__XpbBxQiS4HD1nWYL")
            .subscriptionId("__test__XpbBxQiS4HD1nWYL")
            .referenceInvoiceId("__demo_inv__7")
            .type(ImportCreditNoteParams.Type.REFUNDABLE)
            .currencyCode("USD")
            .createReasonCode("Product Unsatisfactory")
            .date(new Timestamp(1517429430L * 1000))
            .total(4900L)
            .status(ImportCreditNoteParams.Status.REFUND_DUE)
            .lineItems(lineItemsList)
            .build();

        ImportCreditNoteResponse response = client.creditNotes().importCreditNote(params);

        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.creditNote.importCreditNote({
        line_items: [
            {
                date_from: 1517429430,
                date_to: 1519848630,
                description: "Support Charge",
                unit_amount: 4900,
                quantity: 1,
                entity_type: "plan_item_price",
                entity_id: "plan1"
            }
        ],
        id: "old_cn_001",
        customer_id: "__test__XpbBxQiS4HD1nWYL",
        subscription_id: "__test__XpbBxQiS4HD1nWYL",
        reference_invoice_id: "__demo_inv__7",
        type: "refundable",
        currency_code: "USD",
        create_reason_code: "Product Unsatisfactory",
        date: 1517429430,
        total: 4900,
        status: "refund_due"
    });

    console.log(result);
    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->creditNote()->importCreditNote([
    "line_items" => [
        [
            "date_from" => 1517429430,
            "date_to" => 1519848630,
            "description" => "Support Charge",
            "unit_amount" => 4900,
            "quantity" => 1,
            "entity_type" => "plan_item_price",
            "entity_id" => "plan1"
        ]
    ],
    "id" => "old_cn_001",
    "customer_id" => "__test__XpbBxQiS4HD1nWYL",
    "subscription_id" => "__test__XpbBxQiS4HD1nWYL",
    "reference_invoice_id" => "__demo_inv__7",
    "type" => "refundable",
    "currency_code" => "USD",
    "create_reason_code" => "Product Unsatisfactory",
    "date" => 1517429430,
    "total" => 4900,
    "status" => "refund_due"
]);
$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.CreditNote.import_credit_note(
    cb_client.CreditNote.ImportCreditNoteParams(
        line_items=[
            cb_client.CreditNote.ImportCreditNoteLineItemParams(
              date_from=1517429430,
              date_to=1519848630,
              description="Support Charge",
              unit_amount=4900,
              quantity=1,
              entity_type=chargebee.CreditNote.LineItemEntityType.PLAN_ITEM_PRICE,
              entity_id="plan1"
            )
        ],
        id="old_cn_001",
        customer_id="__test__XpbBxQiS4HD1nWYL",
        subscription_id="__test__XpbBxQiS4HD1nWYL",
        reference_invoice_id="__demo_inv__7",
        type=chargebee.CreditNote.Type.REFUNDABLE,
        currency_code="USD",
        create_reason_code="Product Unsatisfactory",
        date=1517429430,
        total=4900,
        status=chargebee.CreditNote.Status.REFUND_DUE
    )
)
credit_note = response.credit_note
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::CreditNote.import_credit_note({
  :id => "old_cn_001",
  :customer_id => "__test__XpbBxQiS4HD1nWYL",
  :subscription_id => "__test__XpbBxQiS4HD1nWYL",
  :reference_invoice_id => "__demo_inv__7",
  :type => "REFUNDABLE",
  :currency_code => "USD",
  :create_reason_code => "Product Unsatisfactory",
  :date => 1517429430,
  :total => 4900,
  :status => "REFUND_DUE",
  :line_items => [
    {
      :date_from => 1517429430,
      :date_to => 1519848630,
      :description => "Support Charge",
      :unit_amount => 4900,
      :quantity => 1,
      :entity_type => "PLAN_ITEM_PRICE",
      :entity_id => "plan1"
    }
  ]
})

credit_note = result.credit_note
```

## Sample Response

```json
{
  "credit_note": {
    "allocations": {},
    "amount_allocated": 0,
    "amount_available": 500,
    "amount_refunded": 0,
    "base_currency_code": "USD",
    "create_reason_code": "Product Unsatisfactory",
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWT0XH7a",
    "date": 1517501414,
    "deleted": false,
    "exchange_rate": 1,
    "fractional_correction": 0,
    "id": "__demo_cn__7",
    "line_item_discounts": {},
    "line_item_taxes": {},
    "line_items": [
      {
        "amount": 500,
        "customer_id": "__test__KyVnHhSBWT0XH7a",
        "date_from": 1517501414,
        "date_to": 1517501414,
        "description": "Support Charge",
        "discount_amount": 0,
        "entity_type": "adhoc",
        "id": "li___test__KyVnHhSBWT0c77n",
        "is_taxed": false,
        "item_level_discount_amount": 0,
        "object": "line_item",
        "pricing_model": "flat_fee",
        "quantity": 1,
        "tax_amount": 0,
        "tax_exempt_reason": "tax_not_configured",
        "unit_amount": 500
      },
      {..}
    ],
    "linked_refunds": {},
    "object": "credit_note",
    "price_type": "tax_exclusive",
    "reason_code": "product_unsatisfactory",
    "reference_invoice_id": "__demo_inv__7",
    "resource_version": 1517501414000,
    "round_off_amount": 0,
    "status": "refund_due",
    "sub_total": 500,
    "taxes": {},
    "total": 500,
    "type": "refundable",
    "updated_at": 1517501414
  }
}
```

## URL Format

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

## Input Parameters

- `id` (required, string, max chars=50)
  The unique identifier for the credit note (credit note number).
  
  **Constraints**
  
  -   Must not conflict with existing credit note numbers in your Chargebee Billing site.
  -   Must not conflict with future credit note numbers that your Chargebee Billing site may [generate](https://www.chargebee.com/docs/billing/2.0/invoices-credit-notes-and-quotes/invoice-numbering).

- `customer_id` (optional, string, max chars=50)
  The unique identifier of the customer for whom the credit note is created.
  
  **Required if**
  
  -   `subscription_id` is not provided.
  
  **Constraints**
  
  -   Must match the [customer](/docs/api/invoices/invoice-object#invoice_customer_id) of the `reference_invoice_id`.

- `subscription_id` (optional, string, max chars=50)
  The unique identifier of the subscription for which this credit note is created.
  
  **Required if**
  
  -   `customer_id` is not provided.
  
  **Constraints**
  
  -   Must match the [subscription](/docs/api/invoices/invoice-object#invoice_subscription_id) of the `reference_invoice_id`.
  -   Must not be provided if `line_items[subscription_id][]` is provided.

- `reference_invoice_id` (required, string, max chars=50)
  The unique identifier of the invoice against which this credit note is issued. The invoice must already exist in your Chargebee Billing site.

- `type` (required, enumerated string)
  The credit note type. Determines how the credit note can be used. [Learn more](/docs/api/credit_notes/credit-note-object#credit_note_types) about credit note types.
  Possible enum values:
    - `adjustment`
      Adjustment credit note.
    - `refundable`
      Refundable credit note.
    - `store`
      Store credit note.
      
      **Constraints**
      
      -   The `type` value `store` is not supported for this API operation.

- `currency_code` (required if Multicurrency is enabled, string, max chars=3)
  The currency code ([ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) format) for the credit note.
  
  **Required if**
  
  -   [Multi-currency pricing](https://www.chargebee.com/docs/billing/2.0/site-configuration/multi-currency-pricing) is enabled for the site and `customer_id` is provided.

- `create_reason_code` (required, string, max chars=100)
  The [reason code](https://www.chargebee.com/docs/billing/2.0/site-configuration/reason-codes#managing-reason-codes-for-credit-notes) for creating the credit note.
  
  **Required if**
  
  -   Reason codes are mandatory in Chargebee Billing.
  
  **Constraints**
  
  -   Must be a valid and enabled reason code from the list configured in Chargebee Billing.
  -   The reason code can also be from **Refund Credit Note** reason codes.
  -   The codes are case-sensitive.

- `date` (required, timestamp(UTC) in seconds)
  The date when the credit note was issued.
  
  **Constraints**
  
  -   Must be a date in the past.
  -   Must be after the [`date`](/docs/api/invoices/invoice-object#invoice_date) of the reference invoice.

- `status` (optional, enumerated string)
  The status of the credit note. Determines the current state of the credit note and how it can be used.
  
  **Default value**
  
  -   `adjusted` if `type` is `adjustment`.
  -   if `type` is `refundable`:
      -   `refunded` if the credit note `total` is equal to the sum of `linked_refunds[amount][]` plus the sum of `allocations[allocated_amount][]`.
      -   `refund_due` otherwise.
  Possible enum values:
    - `adjusted`
      The credit note has been adjusted against an invoice.
      
      **Constraints**
      
      -   Must only be set when `type` is `adjustment`.
      -   Requires `allocations[]` to be provided and `linked_refunds[]` must not be provided.
    - `refunded`
      The entire credit note amount has been used (either allocated to invoices or refunded).
      
      **Constraints**
      
      -   Must only be set when `type` is `refundable`.
      -   Requires `linked_refunds[]` and/or `allocations[]` to be provided.
      -   The sum of `linked_refunds[amount][]` plus the sum of `allocations[allocated_amount][]` must equal the credit note `total`.
    - `refund_due`
      The credits are yet to be used or have been partially used.
      
      **Constraints**
      
      -   Must only be set when `type` is `refundable`.
      -   The credit note `total` must be greater than the sum of `linked_refunds[amount][]` plus the sum of `allocations[allocated_amount][]`.
    - `voided`
      The credit note has been cancelled.
      
      **Constraints**
      
      -   `linked_refunds[]` and `allocations[]` must not be provided when `status` is `voided`.

- `total` (optional, in cents, default=0, min=0)
  The total amount of the credit note.
  
  **Constraints**
  
  -   For refundable credit notes (`type` = `refundable`), this must be less than or equal to the reference invoice's [refundable amount](/docs/api/invoices/invoice-object#refundable-amount).
  -   For adjustment credit notes (`type` = `adjustment`), this must be less than or equal to the reference invoice's [`amount_to_collect`](/docs/api/invoices/invoice-object#invoice_amount_to_collect).

- `refunded_at` (optional, timestamp(UTC) in seconds)
  The timestamp when this credit note was fully used (refunded or allocated). This field is automatically set when the credit note `status` becomes `refunded` or `adjusted`.

- `voided_at` (optional, timestamp(UTC) in seconds)
  The timestamp indicating when this credit note was voided.
  
  **Constraints**
  
  -   `status` must be `voided`.
  
  **Default value**
  
  -   The credit note `date`.

- `sub_total` (optional, in cents, min=0)
  The credit note sub-total (total before round-off, fractional correction, and taxes).

- `round_off_amount` (optional, in cents, min=-99, max=99)
  The rounded-off amount for the credit note. For example, if the credit note amount is $99.99 and it is rounded off to $100.00, then $0.01 is the `round_off_amount`.
  
  **Constraints**
  
  -   Not supported for zero-decimal [currencies](/docs/api/currencies).

- `fractional_correction` (optional, in cents, min=-50000, max=50000)
  Indicates the fractional correction amount.

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

- `line_items` (optional, array)
  Parameters for line items. At least one line item is required.
  - `reference_line_item_id` (optional, string, max chars=40)
    The unique identifier of the [line item](/docs/api/invoices/invoice-object#invoice_line_items) from the reference invoice that this credit note line item reverses.
    
    **Constraints**
    
    -   If **Validate credit note lines against invoice** is enabled, the [`line_item.id`](/docs/api/invoices/invoice-object#invoice_line_items) must exist in the reference invoice. [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 this feature.
  - `id` (optional, string, max chars=40)
    The unique identifier for this 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)
    The unique identifier of the subscription this line item belongs to.
    
    **Constraints**
    
    -   Must not be provided if `subscription_id` is provided.
    -   The subscription's [customer](/docs/api/subscriptions/subscription-object#subscription_customer_id) must match the [customer](/docs/api/invoices/invoice-object#invoice_customer_id) of the reference invoice.
  - `description` (required, string, max chars=250)
    Description for this line item
  - `unit_amount` (optional, in cents)
    The unit amount of the line item.
    
    **Required if**
    
    -   Pricing model for the line item is `flat_fee`, `per_unit`, or `volume`.
    
    **Constraints**
    
    -   If **Validate credit note lines against invoice** is enabled, the amount must not exceed the `unit_amount` of the [line item](/docs/api/invoices/invoice-object#invoice_line_items) in the reference invoice. [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 this feature.
  - `quantity` (optional, integer)
    The quantity of the line item.
    
    **Required if**
    
    -   Pricing model for the line item is `per_unit` or `volume`.
    
    **Constraints**
    
    -   If **Validate credit note lines against invoice** is enabled, the quantity must not exceed the quantity of the [line item](/docs/api/invoices/invoice-object#invoice_line_items) in the reference invoice. [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 this feature.
  - `amount` (optional, in cents)
    The total amount of this line item.
    
    **Required if**
    
    -   Pricing model for the line item is `stairstep` or `tiered`.
    -   `line_items[unit_amount]` is not provided.
    
    **Constraints**
    
    -   Must be consistent with `line_items[unit_amount]` and `line_items[quantity]`, when both are provided.
    -   If **Validate credit note lines against invoice** is enabled, the amount must not exceed the `amount` of the [line item](/docs/api/invoices/invoice-object#invoice_line_items) in the reference invoice. [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 this feature.
  - `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 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=100)
    The identifier of the modelled entity this line item is based on. Will be null for 'adhoc' entity type
  - `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.
    
    **Required if**
    
    -   `line_items[tax1_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax1_amount` (optional, in cents)
    First tax amount.
    
    **Required if**
    
    -   `line_items[tax1_name]` is provided.
  - `tax2_name` (optional, string, max chars=50)
    Second tax name.
    
    **Required if**
    
    -   `line_items[tax2_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax2_amount` (optional, in cents)
    Second tax amount.
    
    **Required if**
    
    -   `line_items[tax2_name]` is provided.
  - `tax3_name` (optional, string, max chars=50)
    Third tax name.
    
    **Required if**
    
    -   `line_items[tax3_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax3_amount` (optional, in cents)
    Third tax amount.
    
    **Required if**
    
    -   `line_items[tax3_name]` is provided.
  - `tax4_name` (optional, string, max chars=50)
    Fourth tax name.
    
    **Required if**
    
    -   `line_items[tax4_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax4_amount` (optional, in cents)
    Fourth tax amount.
    
    **Required if**
    
    -   `line_items[tax4_name]` is provided.
  - `tax5_name` (optional, string, max chars=50)
    Fifth tax name.
    
    **Required if**
    
    -   `line_items[tax5_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax5_amount` (optional, in cents)
    Fifth tax amount.
    
    **Required if**
    
    -   `line_items[tax5_name]` is provided.
  - `tax6_name` (optional, string, max chars=50)
    Sixth tax name.
    
    **Required if**
    
    -   `line_items[tax6_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax6_amount` (optional, in cents)
    Sixth tax amount.
    
    **Required if**
    
    -   `line_items[tax6_name]` is provided.
  - `tax7_name` (optional, string, max chars=50)
    Seventh tax name.
    
    **Required if**
    
    -   `line_items[tax7_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax7_amount` (optional, in cents)
    Seventh tax amount.
    
    **Required if**
    
    -   `line_items[tax7_name]` is provided.
  - `tax8_name` (optional, string, max chars=50)
    Eighth tax name.
    
    **Required if**
    
    -   `line_items[tax8_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax8_amount` (optional, in cents)
    Eighth tax amount.
    
    **Required if**
    
    -   `line_items[tax8_name]` is provided.
  - `tax9_name` (optional, string, max chars=50)
    Ninth tax name.
    
    **Required if**
    
    -   `line_items[tax9_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax9_amount` (optional, in cents)
    Ninth tax amount.
    
    **Required if**
    
    -   `line_items[tax9_name]` is provided.
  - `tax10_name` (optional, string, max chars=50)
    Tenth tax name.
    
    **Required if**
    
    -   `line_items[tax10_amount]` is provided.
    
    **Constraints**
    
    -   Must match one of `taxes[name]`.
  - `tax10_amount` (optional, in cents)
    Tenth tax amount.
    
    **Required if**
    
    -   `line_items[tax10_name]` is provided.
  - `proration_mode` (optional, enumerated string)
    Proration mode for the line item.
    Possible enum values:
      - `reset`
      - `delta`
      - `service_period_revision`
      - `adjusted_term`

- `line_item_tiers` (optional, array)
  Parameters for line item tiers. Used to specify tiered pricing details for line items with `tiered`, `volume`, or `stairstep` pricing models.
  - `line_item_id` (required, string, max chars=40)
    The unique identifier of the line item this tier belongs to.
  - `starting_unit` (optional, integer)
    The lower limit of a range of units for the tier
  - `ending_unit` (optional, integer)
    The upper limit of the unit range for this tier. Not applicable for the highest tier.
  - `quantity_used` (optional, integer)
    The number of units purchased within this tier 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. Used to specify discounts, coupons, or promotional credits applied to the credit note at the document level or item level.
  - `line_item_id` (optional, string, max chars=40)
    The unique identifier of the line item that this deduction is for. This must match the `line_items[id]` of the line item to which the discount is applied.
    
    **Required if**
    
    -   `discounts[entity_type]` is `item_level_coupon` or `item_level_discount`.
    
    **Constraints**
    
    -   The line item must have an `id` specified (i.e., `line_items[id]` must be provided for the line item).
  - `entity_type` (required, enumerated string)
    The type of deduction and the amount to which it is applied. Determines whether the discount is applied at the document level or item level, and whether it's a coupon, discount, or promotional credit.
    Possible enum values:
      - `item_level_coupon`
        The deduction is due to a [coupon](/docs/api/coupons) applied at the line item level.
        
        **Constraints**
        
        -   `discounts[line_item_id]` is required and must match the `line_items[id]` of the line item.
        -   Requires `discounts[entity_id]` to be provided to identify the coupon.
      - `document_level_coupon`
        The deduction is due to a [coupon](/docs/api/coupons) applied at the document level.
        
        **Constraints**
        
        -   Requires `discounts[entity_id]` to be provided to identify the coupon.
      - `promotional_credits`
        The deduction is due to a [promotional credit](/docs/api/promotional_credits) applied.
        
        **Constraints**
        
        -   Only one promotional credit discount entry is allowed per credit note.
        -   `discounts[entity_id]` must not be provided.
      - `item_level_discount`
        The deduction is due to a [discount](/docs/api/discounts) applied at the line item level.
        
        **Constraints**
        
        -   `discounts[line_item_id]` is required and must match the `line_items[id]` of the line item.
        -   `discounts[entity_id]` must not be provided.
      - `document_level_discount`
        The deduction is due to a [discount](/docs/api/discounts) applied at the document level.
        
        **Constraints**
        
        -   `discounts[entity_id]` must not be provided.
  - `entity_id` (optional, string, max chars=100)
    The unique identifier of the [coupon](/docs/api/coupons).
    
    **Required if**
    
    -   `discounts[entity_type]` is `item_level_coupon` or `document_level_coupon`.
    
    **Constraints**
    
    -   Must not be provided when `discounts[entity_type]` is `document_level_discount` or `item_level_discount`.
    -   For `item_level_coupon`, the coupon must be applicable to the plan or addon associated with the line item.
    -   For `document_level_coupon`, the coupon must have `apply_on` set to `invoice_amount`.
  - `description` (optional, string, max chars=250)
    Description for this deduction.
  - `amount` (required, in cents)
    The amount deducted. The format of this value depends on the [kind of currency](/docs/api/currencies) .

- `taxes` (optional, array)
  Parameters for document-level taxes. Used to specify tax information at the credit note level.
  
  **Prerequisite**
  
  -   `taxes[]` must not be provided if the reference invoice has **all** line items exempted from tax for any one of the following reasons: `customer_exempt`, `reverse_charge`, or `export` (i.e. if all [`line_items[].tax_exempt_reason`](/docs/api/invoices/invoice-object#invoice_line_items) on the reference invoice are set to `customer_exempt`, `reverse_charge`, or `export`).
  - `name` (required, string, max chars=100)
    The name of the tax applied.
    
    **Constraints**
    
    -   Must match at least one `line_items[tax*_name]`.
  - `rate` (required, double)
    The rate of tax.
    
    **Note**
    
    -   This parameter is only used to disambiguate between multiple taxes with the same `name` and other tax metadata. It is not used to calculate or validate the tax amount.
  - `amount` (optional, in cents)
    The total tax amount for this credit note.
    
    **Constraints**
    
    -   Must match the sum of the line-level tax amounts (`line_items[tax*_amount][]`) for the given combination of `name`, `rate`, `juris_type`, `juris_name`, and `juris_code`.
  - `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

- `allocations` (optional, array)
  Parameters for credit allocations. Used to specify how the credit note amount is allocated to invoices.
  
  **Required if**
  
  -   `status` is `adjusted`.
  
  **Constraints**
  
  -   For adjustment credit notes (`type` = `adjustment`), only one allocation is allowed.
  -   Must not be provided if `status` is `voided`.
  - `invoice_id` (required, string, max chars=50)
    The unique identifier of the invoice to which this credit note amount is allocated. The invoice must already exist in Chargebee.
  - `allocated_amount` (required, in cents)
    The amount allocated from this credit note to the specified invoice.
    
    **Constraints**
    
    -   The sum of `allocated_amount[]` plus the sum of `linked_refunds[amount][]` must not exceed the `total`.
  - `allocated_at` (required, timestamp(UTC) in seconds)
    The timestamp when the allocation occurred.
    
    **Constraints**
    
    -   Must be equal to or after the credit note `date`.
    
    **Default value**
    
    -   The credit note `date`.

- `linked_refunds` (optional, array)
  Parameters for linked refunds. Used to record refund transactions associated with this credit note.
  
  **Required if**
  
  -   `status` is `refunded` and no `allocations[]` are provided.
  
  **Constraints**
  
  -   Must not be provided if `status` is `adjusted` or `voided`.
  - `id` (optional, string, max chars=40)
  - `amount` (required, in cents)
    The amount of this refund transaction.
    
    **Constraints**
    
    -   The sum of `linked_refunds[amount][]` plus the sum of `allocations[allocated_amount][]` must not exceed the `total` of the credit note.
  - `payment_method` (required, enumerated string)
    The payment method used for the refund.
    Possible enum values:
      - `cash`
        Cash
      - `check`
        Check
      - `bank_transfer`
        Bank Transfer
      - `other`
        Payment Methods other than the above types
      - `custom`
        Custom
      - `tamara`
      - `qpay`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
  - `date` (required, timestamp(UTC) in seconds)
    The date when the refund occurred.
    
    **Constraints**
    
    -   Must be a date in the past.
  - `reference_number` (optional, string, min chars=1, max chars=100)
    Reference number for this refund.

## Returns

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