POST /credit_notes/import_credit_note

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 and can be allocated to other invoices or recorded as refunded to the customer.

Impacts

Credit Note

The credit note's billing_address, shipping_address, and vat_number are copied from the reference invoice.

Invoices

Reference invoice
  • See Impact on reference invoice.
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 record is created to track the allocation.

Transactions

If linked_refunds[] are provided, then for each refund provided, a transaction of type refund is created with status set to success.

Servers

Request headers

Name Type Required Description
chargebee-request-origin-device String No

The device from which the customer has made the request

Content-Type String Yes The media type of the request body.

Default value: "application/x-www-form-urlencoded"

chargebee-event-webhook String No

skip only webhooks

Valid values:

  • "all-disabled"
chargebee-business-entity-id String No

If the site has multiple business entities, you can use this custom HTTP header to specify the business entity for which Chargebee should perform the operation.

chargebee-event-actions String No

skip all actions to be done on the events

Valid values:

  • "all-disabled"
chargebee-request-origin-user String No

The email address of your customer/user. Use this when the email address has only ASCII characters.

chargebee-request-origin-ip String No

The IP address of the customer where the request originated

chargebee-request-origin-user-encoded String No

The Base64-encoded email address of your customer/user. Use this if the email address has UTF-8 characters. When this header is provided, the header chargebee-request-origin-user is ignored.

chargebee-event-email String No

skip only emails

Valid values:

  • "all-disabled"

Request body fields

Name Type Required Description
discounts Object No

Parameters for discounts. Used to specify discounts, coupons, or promotional credits applied to the credit note at the document level or item level.

discounts.description[] Array No

Description for this deduction.

discounts.entity_id[] Array No

The unique identifier of the coupon.

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.
discounts.amount[] Array Yes

The amount deducted. The format of this value depends on the kind of currency .

discounts.line_item_id[] Array No

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).
discounts.entity_type[] Array Yes
reference_invoice_id String Yes

The unique identifier of the invoice against which this credit note is issued. The invoice must already exist in your Chargebee Billing site.

currency_code String No

The currency code (ISO 4217 format) for the credit note.

Required if

  • Multi-currency pricing is enabled for the site and customer_id is provided.
sub_total Integer No

The credit note sub-total (total before round-off, fractional correction, and taxes).

status String No

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.
* 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][].
* 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.
* voided -

The credit note has been cancelled.

Constraints

  • linked_refunds[] and allocations[] must not be provided when status is voided.
* 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.

Valid values:

  • "refund_due"
  • "adjusted"
  • "refunded"
  • "voided"
voided_at Integer No

The timestamp indicating when this credit note was voided.

Constraints

  • status must be voided.

Default value

  • The credit note date.
date Integer Yes

The date when the credit note was issued.

Constraints

  • Must be a date in the past.
  • Must be after the date of the reference invoice.
round_off_amount Integer No

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.
create_reason_code String Yes

The reason code 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.

total Integer No

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.
  • For adjustment credit notes (type = adjustment), this must be less than or equal to the reference invoice's amount_to_collect.

Default value: 0

allocations Object No

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.
allocations.allocated_at[] Array Yes

The timestamp when the allocation occurred.

Constraints

  • Must be equal to or after the credit note date.

Default value

  • The credit note date.
allocations.invoice_id[] Array Yes

The unique identifier of the invoice to which this credit note amount is allocated. The invoice must already exist in Chargebee.

allocations.allocated_amount[] Array Yes

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.
id String Yes

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.
customer_id String No

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 of the reference_invoice_id.
line_items Object No

Parameters for line items. At least one line item is required.

line_items.tax3_name[] Array No

Third tax name.

Required if

  • line_items[tax3_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.tax9_name[] Array No

Ninth tax name.

Required if

  • line_items[tax9_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.description[] Array Yes

Description for this line item

line_items.tax6_name[] Array No

Sixth tax name.

Required if

  • line_items[tax6_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.tax2_amount[] Array No

Second tax amount.

Required if

  • line_items[tax2_name] is provided.
line_items.item_level_discount1_amount[] Array No

First item level discount amount

line_items.tax1_amount[] Array No

First tax amount.

Required if

  • line_items[tax1_name] is provided.
line_items.tax3_amount[] Array No

Third tax amount.

Required if

  • line_items[tax3_name] is provided.
line_items.unit_amount_in_decimal[] Array No

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 is enabled.

line_items.item_level_discount2_amount[] Array No

Second item level discount amount

line_items.id[] Array No

The unique identifier for this line item.

line_items.tax4_amount[] Array No

Fourth tax amount.

Required if

  • line_items[tax4_name] is provided.
line_items.tax5_amount[] Array No

Fifth tax amount.

Required if

  • line_items[tax5_name] is provided.
line_items.tax6_amount[] Array No

Sixth tax amount.

Required if

  • line_items[tax6_name] is provided.
line_items.tax7_amount[] Array No

Seventh tax amount.

Required if

  • line_items[tax7_name] is provided.
line_items.amount_in_decimal[] Array No

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 is enabled.

line_items.tax2_name[] Array No

Second tax name.

Required if

  • line_items[tax2_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.reference_line_item_id[] Array No

The unique identifier of the line item 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 must exist in the reference invoice. Contact Support to enable this feature.
line_items.item_level_discount2_entity_id[] Array No

Second item level discount entity id

line_items.subscription_id[] Array No

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 must match the customer of the reference invoice.
line_items.date_to[] Array No

End date of this line item.

line_items.quantity[] Array No

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 in the reference invoice. Contact Support to enable this feature.
line_items.quantity_in_decimal[] Array No

The decimal representation of the quantity of this line_item. Returned when the line_item is quantity-based and multi-decimal pricing is enabled.

line_items.tax9_amount[] Array No

Ninth tax amount.

Required if

  • line_items[tax9_name] is provided.
line_items.tax5_name[] Array No

Fifth tax name.

Required if

  • line_items[tax5_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.tax8_amount[] Array No

Eighth tax amount.

Required if

  • line_items[tax8_name] is provided.
line_items.tax10_amount[] Array No

Tenth tax amount.

Required if

  • line_items[tax10_name] is provided.
line_items.entity_type[] Array No
line_items.tax8_name[] Array No

Eighth tax name.

Required if

  • line_items[tax8_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.unit_amount[] Array No

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 in the reference invoice. Contact Support to enable this feature.
line_items.tax1_name[] Array No

First tax name.

Required if

  • line_items[tax1_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.item_level_discount1_entity_id[] Array No

First item level discount entity id

line_items.date_from[] Array No

Start date of this line item.

line_items.amount[] Array No

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 in the reference invoice. Contact Support to enable this feature.
line_items.entity_id[] Array No

The identifier of the modelled entity this line item is based on. Will be null for 'adhoc' entity type

line_items.tax7_name[] Array No

Seventh tax name.

Required if

  • line_items[tax7_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.tax4_name[] Array No

Fourth tax name.

Required if

  • line_items[tax4_amount] is provided.

Constraints

  • Must match one of taxes[name].
line_items.tax10_name[] Array No

Tenth tax name.

Required if

  • line_items[tax10_amount] is provided.

Constraints

  • Must match one of taxes[name].
fractional_correction Integer No

Indicates the fractional correction amount.

vat_number_prefix String No

An overridden value for the first two characters of the full VAT number. Only applicable specifically for customers with billing_address

country as XI (which is United Kingdom - Northern Ireland ).

When you have enabled EU VAT in 2021 or have manually enabled the Brexit configuration, you have the option of setting 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.

type String Yes

The credit note type. Determines how the credit note can be used. Learn more about credit note types.

* refundable -

Refundable credit note.

* store -

Store credit note.

Constraints

  • The type value store is not supported for this API operation.
* adjustment -

Adjustment credit note.

Valid values:

  • "refundable"
  • "store"
  • "adjustment"
linked_refunds Object No

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.
linked_refunds.id[] Array No
linked_refunds.reference_number[] Array No

Reference number for this refund.

linked_refunds.amount[] Array Yes

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.
linked_refunds.payment_method[] Array Yes
linked_refunds.date[] Array Yes

The date when the refund occurred.
Constraints

  • Must be a date in the past.
line_item_tiers Object No

Parameters for line item tiers. Used to specify tiered pricing details for line items with tiered, volume, or stairstep pricing models.

line_item_tiers.unit_amount[] Array No

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.

line_item_tiers.starting_unit_in_decimal[] Array No

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 is enabled.

line_item_tiers.ending_unit[] Array No

The upper limit of the unit range for this tier. Not applicable for the highest tier.

line_item_tiers.quantity_used_in_decimal[] Array No

The decimal representation of the quantity purchased from this tier. Returned when the line_item is quantity-based and multi-decimal pricing is enabled.

line_item_tiers.line_item_id[] Array Yes

The unique identifier of the line item this tier belongs to.

line_item_tiers.starting_unit[] Array No

The lower limit of a range of units for the tier

line_item_tiers.ending_unit_in_decimal[] Array No

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 is enabled.

line_item_tiers.unit_amount_in_decimal[] Array No

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 is enabled.

line_item_tiers.quantity_used[] Array No

The number of units purchased within this tier range.

taxes Object No

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 on the reference invoice are set to customer_exempt, reverse_charge, or export).
taxes.rate[] Array Yes

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.
taxes.juris_name[] Array No

The name of the tax jurisdiction

taxes.name[] Array Yes

The name of the tax applied.

Constraints

  • Must match at least one line_items[tax*_name].
taxes.description[] Array No

Description of tax

taxes.amount[] Array No

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.
taxes.juris_code[] Array No

The tax jurisdiction code

taxes.juris_type[] Array No
subscription_id String No

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 of the reference_invoice_id.
  • Must not be provided if line_items[subscription_id][] is provided.
refunded_at Integer No

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.

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.