ChargebeeAPI

Import invoice

Idempotency Supported
Try in API Explorer

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

Accounting Integrations

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

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

Constraints

  • 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 resource to which this invoice belongs.

Required if

  • subscription_id is not provided.

Constraints

subscription_id
optional, string, max chars=50

The ID of the subscription resource to which this invoice belongs.

Required if

  • customer_id is not provided. OR
  • The invoice is a recurring invoice and line_items.subscription_id[] are not provided.
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
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 or UK VAT is enabled.)

customer_exempt

The customer is exempted from tax.

export

The customer is from a non-taxable region or the billing address and shipping address are unavailable.

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

date
required, timestamp(UTC) in seconds

Date when invoice raised.

total
required, in cents, min=0

Invoice total amount.

Constraints

  • Must be equal to (sum of line_items[amount][]) - (sum of discounts[amount][]) + (sum of taxes[amount][]) + round_off_amount.
  • Cannot be 0 if hiding zero-value line items is enabled.
round_off
optional, in cents, min=-99, max=99
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.

Prerequisites

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 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_invoicesattribute is set to true. The invoice is yet to be closed (sent for payment collection). All invoices are generated with this status when Metered Billing is enabled for the site.

Prerequisites

  • The value of status can be pending only if Metered Billing 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.

Prerequisites

Required if

  • status is posted.

Constraints

  • Must be a date in the future if status is posted.
  • Must be a date in the past if status is payment_due.
net_term_days
optional, integer, default=0

Invoice net term days.

Prerequisites

Required if

  • status is posted.
has_advance_charges
optional, boolean, default=false

Boolean indicating any advance charge is present in this invoice.

Contraints

use_for_proration
optional, boolean, default=false

If the invoice falls within the subscription current term will be used for proration.

credit_note
optional, string

Parameters for credit_note

billing_address
optional, string

Parameters for billing_address

shipping_address
optional, string

Parameters for shipping_address

line_items
optional, string

Parameters for line_items

payment_reference_numbers
optional, string

Parameters for payment_reference_numbers

line_item_tiers
optional, string

Parameters for line_item_tiers

discounts
optional, string

Parameters for discounts

taxes
optional, string

Parameters for taxes

payments
optional, string

Parameters for payments

notes
optional, enumerated string

Parameters for notes

line_item_addresses
optional, string

The list of addresses used for tax calculation on line items.

Returns

invoiceInvoice object

Resource object representing invoice

credit_noteCredit note object

Resource object representing credit_note