Unbilled charge represents the charges that are held by passing invoice_later in various operations such as update subscription, add charge, create subscription, etc. Learn more.

If any invoice is to be created for a subscription all the unbilled charges associated with the subscription will be included in that invoice.

If any invoice is to be created for a customer, all the unbilled charges associated with its subscriptions will be included in that invoice.

Any automatic invoice creation like renewal, activation, etc., will include the unbilled charges.

Subscriptions are invoiced at the start of every term based on the recurring items and charged immediately against the customer's credit card if 'auto_collection' is turned 'on', otherwise the resulting invoice will be created as 'Payment Due'.

If consolidated invoicing is enabled, the charges during the subscription renewals/activations will be held and consolidated at the last renewal/activation that takes place on that particular day.

Sample unbilled charge [ JSON ]

{ "amount": 895, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWSjBm2e", "date_from": 1517501348, "date_to": 1519920548, "deleted": false, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWSjQY2g", "is_voided": false, "object": "unbilled_charge", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWSjBm2e", "unit_amount": 895 }

API Index URL GET

https://{site}.chargebee.com/api/v2/unbilled_charges
id
Uniquely identifies an unbilled charge.
optional, string, max chars=50
customer_id
A unique identifier for the customer being charged.
optional, string, max chars=50
subscription_id
A unique identifier for the subscription this charge belongs to.
optional, string, max chars=50
date_from
Start date of this charge.
optional, timestamp(UTC) in seconds
date_to
End date of this charge.
optional, timestamp(UTC) in seconds
unit_amount
Unit amount of the charge item.
optional, in cents, min=0
pricing_model
The pricing scheme for this line item.
optional, enumerated string
Possible values are
flat_feeA fixed price that is not quantity-based.per_unitA fixed price per unit quantity.tieredThe per unit price is based on the tier that the total quantity falls in.volumeThere are quantity tiers for which per unit prices are set. Quantities are purchased from successive tiers.stairstepA quantity-based pricing scheme. The item is charged a fixed price based on the tier that the total quantity falls in.
quantity
Quantity of the item which is represented by this charge.
optional, integer, min=0
amount
Total amount of this charge. Typically equals to unit amount x quantity.
optional, in cents, min=0
currency_code
The currency code (ISO 4217 format) for the charge.
string, max chars=3
discount_amount
Total discounts for this charge.
optional, in cents, min=0
description
Detailed description about this charge.
optional, string, max chars=250
entity_type
Specifies the modelled entity this line item is based on.
enumerated string
Possible values are
plan_setupIndicates that this lineitem is based on 'Plan Setup' charge. The 'entity_id' attribute specifies the plan id.planIndicates that this lineitem is based on 'Plan' entity. The 'entity_id' attribute specifies the plan id.addonIndicates that this lineitem is based on 'Addon' entity. The 'entity_id' attribute specifies the addon id.adhocIndicates that this lineitem is not modelled. i.e created adhoc. So the 'entity_id' attribute will be null in this case.
entity_id
The identifier of the modelled entity this charge is based on. Will be null for 'adhoc' entity type.
optional, string, max chars=100
is_voided
Will be true if the charge has been voided. Usually the unbilled charge will be voided and revised to different charges(s) during proration.
boolean, default=false
voided_at
Timestamp indicating the date and time this charge got voided.
optional, timestamp(UTC) in seconds
unit_amount_in_decimal
The decimal representation of the amount for the charge, in major units of the currency. Typically equals to unit_amount_in_decimal x quantity_in_decimal. Returned when multi-decimal pricing is enabled.
optional, string, max chars=33
quantity_in_decimal
The decimal representation of the quantity of this entity. Returned when the entity is quantity-based and multi-decimal pricing is enabled.
optional, string, max chars=33
amount_in_decimal
The decimal representation of the unit amount for the entity. The value is in major units of the currency. Returned when the entity is quantity-based and multi-decimal pricing is enabled.
optional, string, max chars=33
deleted
Indicates that this resource has been deleted.
boolean
The list of tiers applicable for this line item.
optional, list of line_item_tier
Tier attributes
starting_unit
The lower limit of a range of units for the tier.
integer, min=0
ending_unit
The upper limit of a range of units for the tier.
optional, integer
quantity_used
The number of units purchased in a range.
integer, min=0
unit_amount
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.
in cents, min=0
starting_unit_in_decimal
The decimal representation of the 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.
optional, string, max chars=33
ending_unit_in_decimal
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.
optional, string, max chars=33
quantity_used_in_decimal
The decimal representation of the quantity purchased from this tier. Returned when the line_item is quantity-based and multi-decimal pricing is enabled.
optional, string, max chars=33
unit_amount_in_decimal
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.
optional, string, max chars=40

Use this API to bill the unbilled charges. Available Credits and Excess Payments will automatically be applied while creating the invoice.

If the Auto Collection is turned on for the particular customer, the invoice will be created in payment_due state and the payment collection will be scheduled immediately.

During invoice creation, the PO number for the line items will be filled from the subscription’s current PO number, if available.

If no recurring item is present in the created invoice, the invoice will be marked as recurring=false.

If consolidated invoicing is enabled and the parameter ‘customer_id’ is passed, multiple invoices can be created based on the following factors.

  • Currency
  • PO number if ‘Group by PO number’ is enabled
  • Shipping address
  • Auto Collection
  • Payment method
Sample Request
curl  https://{site}.chargebee.com/api/v2/unbilled_charges/invoice_unbilled_charges \
     -X POST  \
     -u {site_api_key}:\
     -d subscription_id="__test__KyVnHhSBWSjWC2p"
copy
curl  https://{site}.chargebee.com/api/v2/unbilled_charges/invoice_unbilled_charges \
     -X POST  \
     -u {site_api_key}:\
     -d subscription_id="__test__KyVnHhSBWSjWC2p"

Sample Response [ JSON ]

Show more...
{"invoices": [ { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 895, "amount_paid": 0, "amount_to_collect": 895, "applied_credits": [], "base_currency_code": "USD", "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWSjWC2p", "date": 1517501348, "deleted": false, "due_date": 1517501348, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": true, "has_advance_charges": false, "id": "__demo_inv__1", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnHhSBWSjWC2p", "date_from": 1517501348, "date_to": 1519920548, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWSjXc2r", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWSjWC2p", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 895 }, {..} ], "linked_orders": [], "linked_payments": [], "net_term_days": 0, "new_sales_amount": 895, "object": "invoice", "price_type": "tax_exclusive", "recurring": true, "resource_version": 1517501348000, "round_off_amount": 0, "status": "payment_due", "sub_total": 895, "subscription_id": "__test__KyVnHhSBWSjWC2p", "tax": 0, "term_finalized": true, "total": 895, "updated_at": 1517501348, "write_off_amount": 0 }, {..} ]}

URL Format POST

https://{site}.chargebee.com/api/v2/unbilled_charges/invoice_unbilled_charges
subscription_id
Identifier of the subscription for which this invoice needs to be created. Should be specified if 'customer_id' is not specified.
optional, string, max chars=50
customer_id
Identifier of the customer for whom this invoice needs to be created. Should be specified if 'subscription_id' is not specified. Applicable only if the consolidated invoicing is enabled. .
optional, string, max chars=50
Resource object representing invoice.
always returned
Use this API to delete an unbilled charge by specifying the id of the charge.
Sample Request
curl  https://{site}.chargebee.com/api/v2/unbilled_charges/li___test__KyVnHhSBWSjQY2g/delete \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/unbilled_charges/li___test__KyVnHhSBWSjQY2g/delete \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

Show more...
{"unbilled_charge": { "amount": 895, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWSjBm2e", "date_from": 1517501348, "date_to": 1519920548, "deleted": false, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWSjQY2g", "is_voided": false, "object": "unbilled_charge", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWSjBm2e", "unit_amount": 895 }}

URL Format POST

https://{site}.chargebee.com/api/v2/unbilled_charges/{unbilled_charge_id}/delete
Resource object representing unbilled_charge.
always returned
Lists all the unbilled charges.
Sample Request
curl  https://{site}.chargebee.com/api/v2/unbilled_charges \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=2 \
     --data-urlencode customer_id[is]="__test__KyVnHhSBWSjfS30"
copy
curl  https://{site}.chargebee.com/api/v2/unbilled_charges \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=2 \
     --data-urlencode customer_id[is]="__test__KyVnHhSBWSjfS30"

Sample Response [ JSON ]

Show more...
{"list": [ {"unbilled_charge": { "amount": 895, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWSjfS30", "date_from": 1517501349, "date_to": 1519920549, "deleted": false, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWSjhc32", "is_voided": false, "object": "unbilled_charge", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWSjfS30", "unit_amount": 895 }}, {..} ]}

URL Format GET

https://{site}.chargebee.com/api/v2/unbilled_charges
limit
The number of resources to be returned.
optional, integer, default=10, min=1, max=100
offset
Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set offset to the value of next_offset obtained in the previous iteration of the API call.
optional, string, max chars=1000
include_deleted
If set to true, includes the deleted resources in the response. For the deleted resources in the response, the 'deleted' attribute will be 'true'.
optional, boolean, default=false
Filter Params
For operator usages, see the Pagination and Filtering section.
is_voided
Will be true if the charge has been voided. Usually the unbilled charge will be voided and revised to different charges(s) during proration.
optional, boolean, default=false
subscription_id[<operator>]
A unique identifier for the subscription this charge belongs to.
Supported operators : is, is_not, starts_with, is_present, in, not_in

Example subscription_id[is] = "5hjdk8nOpd0b12"
optional, string filter
customer_id[<operator>]
A unique identifier for the customer being charged.
Supported operators : is, is_not, starts_with, is_present, in, not_in

Example customer_id[is] = "5hjdk8nOpd0b12"
optional, string filter
Resource object representing unbilled_charge.
always returned
next_offset
This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
optional, string, max chars=1000

This is similar to the "Create an invoice for unbilled charges" API but no invoice will be created, only an estimate for this operation is created.

In the estimate response,

  • estimate.invoice_estimates is an array of estimate.invoice_estimate. This has the details of the invoices that will be generated now.

Note:

  • This API when invoked does not perform the actual operation. It just generates an estimate.
  • Both subscription_id and customer_id parameters should not be given at the same time.

Sample Request
curl  https://{site}.chargebee.com/api/v2/unbilled_charges/invoice_now_estimate \
     -X POST  \
     -u {site_api_key}:\
     -d customer_id="__test__KyVnHhSBWSjn239"
copy
curl  https://{site}.chargebee.com/api/v2/unbilled_charges/invoice_now_estimate \
     -X POST  \
     -u {site_api_key}:\
     -d customer_id="__test__KyVnHhSBWSjn239"

Sample Response [ JSON ]

Show more...
{"estimate": { "created_at": 1517501349, "invoice_estimates": [ { "amount_due": 895, "amount_paid": 0, "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWSjn239", "date": 1517501349, "line_item_discounts": [], "line_item_taxes": [], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnHhSBWSjn239", "date_from": 1517501349, "date_to": 1519920549, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWSjoI3B", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWSjn239", "tax_amount": 0, "unit_amount": 895 }, {..} ], "object": "invoice_estimate", "price_type": "tax_exclusive", "recurring": true, "round_off_amount": 0, "sub_total": 895, "taxes": [], "total": 895 }, {..} ], "object": "estimate" }}

URL Format POST

https://{site}.chargebee.com/api/v2/unbilled_charges/invoice_now_estimate
subscription_id
Identifier of the subscription for which this estimate needs to be created. Should be given if 'customer_id' is not specified.
optional, string, max chars=50
customer_id
Identifier of the customer for whom this estimate is created. Is given if 'subscription_id' is not specified. Applicable only if the 'Consolidated Invoicing' is enabled. If 'Consolidated Invoicing' is not enabled, an invoice will be generated for every subscription.
optional, string, max chars=50
Resource object representing estimate.
always returned