Chargebee provides an HTTP-based API that follows the principles of REST. The HTTP rules followed allow simple HTTP clients like cURL to be used as well. The URLs are resource-oriented, the request format is form-encoded, and the responses are in JSON.
Depending on the type of operation, the endpoints use one of two HTTP methods:
GET
: Used for all read-only operations such as retrieving a resource or listing a group of resources.POST
: Used for all write operations. Such operations modify the state of a resource.A history of changes to the API is provided in the API Changelog.
Note
Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
Some features in the API are part of the Early Access Program and are labeled "EAP," "Beta," or "Early Access." Please review the terms and conditions that apply to these features before using them.
Chargebee follows the REST model of exposing resources as urls. For example, subscriptions are exposed as
The HTTP method (like GET,POST) determines the operation type on the resource. Query parameters allow you to provide additional options to the GET requests. POST parameters provide the data to write operations like creation, modification of resource(s).
By default curl uses GET method. Use -X option to specify a specific HTTP method to use. For passing parameters, use -d option. ( Note: cURL automatically uses to POST method if any parameter is sent via -d option ).
The response is in JSON format. Currently Chargebee does not support any other response format.
Note: Sometimes, while working with Chargebee APIs, you may see undocumented attributes returned in the response. Such attributes should be ignored.
# creates a subscription with customer information and billing details. curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d auto_collection="off" \ -d customer[first_name]="John" \ -d customer[last_name]="Doe" \ -d customer[email]="john@user.com" \ -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"
# creates a subscription with customer information and billing details. curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d auto_collection="off" \ -d customer[first_name]="John" \ -d customer[last_name]="Doe" \ -d customer[email]="john@user.com" \ -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"
# creates a subscription by overriding plan's default price. curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d auto_collection="off" \ -d plan_unit_price=200 \ -d billing_alignment_mode="immediate"
# creates a subscription with addons and coupons. curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d addons[id][0]="ssl" \ -d coupon_ids[0]="plan_only_coupon" \ -d auto_collection="off"
# creates a subscription with meta data and custom fields. curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d auto_collection="off" \ -d "cf_gender"="Male" \ -d meta_data="{'features':{'usage-limit':'5GB','speed-within-quota':'2MBbps','post-usage-quota':'512kbps'}}"
# creates a subscription with unbilled charges. curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}:\ -d plan_id="no_trial" \ -d invoice_immediately="false" \ -d terms_to_charge=2 \ -d addons[id][0]="ssl" \ -d auto_collection="off"
{ "customer": { "allow_direct_debit": false, "auto_collection": "on", "billing_address": { "city": "Walnut", "country": "US", "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "object": "billing_address", "state": "California", "state_code": "CA", "validation_status": "not_validated", "zip": "91789" }, "card_status": "no_card", "created_at": 1517505643, "deleted": false, "email": "john@user.com", "excess_payments": 0, "first_name": "John", "id": "__test__KyVnHhSBWkkwI2Tn", "last_name": "Doe", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517505643000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517505643 }, "invoice": { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 895, "amount_paid": 0, "amount_to_collect": 895, "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", "state_code": "CA", "validation_status": "not_validated", "zip": "91789" }, "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWkkwI2Tn", "date": 1517505643, "deleted": false, "due_date": 1517505643, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": true, "has_advance_charges": false, "id": "__demo_inv__11", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnHhSBWkkwI2Tn", "date_from": 1517505643, "date_to": 1519924843, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWkkxu2Tp", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWkkwI2Tn", "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": 1517505643000, "round_off_amount": 0, "status": "payment_due", "sub_total": 895, "subscription_id": "__test__KyVnHhSBWkkwI2Tn", "tax": 0, "term_finalized": true, "total": 895, "updated_at": 1517505643, "write_off_amount": 0 }, "subscription": { "activated_at": 1517505643, "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "created_at": 1517505643, "currency_code": "USD", "current_term_end": 1519924843, "current_term_start": 1517505643, "customer_id": "__test__KyVnHhSBWkkwI2Tn", "deleted": false, "due_invoices_count": 1, "due_since": 1517505643, "has_scheduled_changes": false, "id": "__test__KyVnHhSBWkkwI2Tn", "mrr": 0, "next_billing_at": 1519924843, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517505643000, "started_at": 1517505643, "status": "active", "total_dues": 895, "updated_at": 1517505643 } }
{ "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "no_card", "created_at": 1517505647, "deleted": false, "excess_payments": 0, "id": "__test__KyVnHhSBWklx92UA", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517505647000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517505647 }, "invoice": { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 200, "amount_paid": 0, "amount_to_collect": 200, "applied_credits": [], "base_currency_code": "USD", "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWklx92UA", "date": 1517505647, "deleted": false, "due_date": 1517505647, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": true, "has_advance_charges": false, "id": "__demo_inv__14", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 200, "customer_id": "__test__KyVnHhSBWklx92UA", "date_from": 1517505647, "date_to": 1519924847, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWklyY2UC", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWklx92UA", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 200 }, {..} ], "linked_orders": [], "linked_payments": [], "net_term_days": 0, "new_sales_amount": 200, "object": "invoice", "price_type": "tax_exclusive", "recurring": true, "resource_version": 1517505647000, "round_off_amount": 0, "status": "payment_due", "sub_total": 200, "subscription_id": "__test__KyVnHhSBWklx92UA", "tax": 0, "term_finalized": true, "total": 200, "updated_at": 1517505647, "write_off_amount": 0 }, "subscription": { "activated_at": 1517505647, "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "created_at": 1517505647, "currency_code": "USD", "current_term_end": 1519924847, "current_term_start": 1517505647, "customer_id": "__test__KyVnHhSBWklx92UA", "deleted": false, "due_invoices_count": 1, "due_since": 1517505647, "has_scheduled_changes": false, "id": "__test__KyVnHhSBWklx92UA", "mrr": 0, "next_billing_at": 1519924847, "object": "subscription", "plan_amount": 200, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 200, "resource_version": 1517505647000, "started_at": 1517505647, "status": "active", "total_dues": 200, "updated_at": 1517505647 } }
{ "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "no_card", "created_at": 1517505645, "deleted": false, "excess_payments": 0, "id": "__test__KyVnHhSBWklIN2Tu", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517505645000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517505645 }, "invoice": { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 1300, "amount_paid": 0, "amount_to_collect": 1300, "applied_credits": [], "base_currency_code": "USD", "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWklIN2Tu", "date": 1517505645, "deleted": false, "discounts": [ { "amount": 90, "description": "Plan Only Coupon", "entity_id": "plan_only_coupon", "entity_type": "item_level_coupon", "object": "discount" }, {..} ], "due_date": 1517505645, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": true, "has_advance_charges": false, "id": "__demo_inv__12", "is_gifted": false, "issued_credit_notes": [], "line_item_discounts": [ { "coupon_id": "plan_only_coupon", "discount_amount": 90, "discount_type": "item_level_coupon", "line_item_id": "li___test__KyVnHhSBWklKE2Tw", "object": "line_item_discount" }, {..} ], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnHhSBWklIN2Tu", "date_from": 1517505645, "date_to": 1519924845, "description": "No Trial", "discount_amount": 90, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWklKE2Tw", "is_taxed": false, "item_level_discount_amount": 90, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWklIN2Tu", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 895 }, {..} ], "linked_orders": [], "linked_payments": [], "net_term_days": 0, "new_sales_amount": 1300, "object": "invoice", "price_type": "tax_exclusive", "recurring": true, "resource_version": 1517505645000, "round_off_amount": 0, "status": "payment_due", "sub_total": 1300, "subscription_id": "__test__KyVnHhSBWklIN2Tu", "tax": 0, "term_finalized": true, "total": 1300, "updated_at": 1517505645, "write_off_amount": 0 }, "subscription": { "activated_at": 1517505645, "addons": [ { "amount": 495, "id": "ssl", "object": "addon", "quantity": 1, "unit_price": 495 }, {..} ], "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "coupon": "plan_only_coupon", "coupons": [ { "applied_count": 1, "coupon_id": "plan_only_coupon", "object": "coupon" }, {..} ], "created_at": 1517505645, "currency_code": "USD", "current_term_end": 1519924845, "current_term_start": 1517505645, "customer_id": "__test__KyVnHhSBWklIN2Tu", "deleted": false, "due_invoices_count": 1, "due_since": 1517505645, "has_scheduled_changes": false, "id": "__test__KyVnHhSBWklIN2Tu", "mrr": 0, "next_billing_at": 1519924845, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517505645000, "started_at": 1517505645, "status": "active", "total_dues": 1300, "updated_at": 1517505645 } }
{ "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "no_card", "created_at": 1517505646, "deleted": false, "excess_payments": 0, "id": "__test__KyVnHhSBWklcY2U3", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517505646000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517505646 }, "invoice": { "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__KyVnHhSBWklcY2U3", "date": 1517505646, "deleted": false, "due_date": 1517505646, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": true, "has_advance_charges": false, "id": "__demo_inv__13", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnHhSBWklcY2U3", "date_from": 1517505646, "date_to": 1519924846, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnHhSBWkldr2U5", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnHhSBWklcY2U3", "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": 1517505646000, "round_off_amount": 0, "status": "payment_due", "sub_total": 895, "subscription_id": "__test__KyVnHhSBWklcY2U3", "tax": 0, "term_finalized": true, "total": 895, "updated_at": 1517505646, "write_off_amount": 0 }, "subscription": { "activated_at": 1517505646, "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "cf_gender": "Male", "created_at": 1517505646, "currency_code": "USD", "current_term_end": 1519924846, "current_term_start": 1517505646, "customer_id": "__test__KyVnHhSBWklcY2U3", "deleted": false, "due_invoices_count": 1, "due_since": 1517505646, "has_scheduled_changes": false, "id": "__test__KyVnHhSBWklcY2U3", "meta_data": {"features": { "post-usage-quota": "512kbps", "speed-within-quota": "2MBbps", "usage-limit": "5GB" }}, "mrr": 0, "next_billing_at": 1519924846, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517505646000, "started_at": 1517505646, "status": "active", "total_dues": 895, "updated_at": 1517505646 } }
{ "customer": { "allow_direct_debit": false, "auto_collection": "on", "balances": [ { "balance_currency_code": "USD", "currency_code": "USD", "excess_payments": 0, "object": "customer_balance", "promotional_credits": 0, "refundable_credits": 0, "unbilled_charges": 2780 }, {..} ], "card_status": "no_card", "created_at": 1517505649, "deleted": false, "excess_payments": 0, "id": "__test__KyVnHhSBWkmHx2UH", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517505649000, "taxability": "taxable", "unbilled_charges": 2780, "updated_at": 1517505649 }, "subscription": { "activated_at": 1517505649, "addons": [ { "amount": 495, "id": "ssl", "object": "addon", "quantity": 1, "unit_price": 495 }, {..} ], "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "created_at": 1517505649, "currency_code": "USD", "current_term_end": 1519924849, "current_term_start": 1517505649, "customer_id": "__test__KyVnHhSBWkmHx2UH", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__KyVnHhSBWkmHx2UH", "mrr": 0, "next_billing_at": 1522603249, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517505649000, "started_at": 1517505649, "status": "active", "updated_at": 1517505649 }, "unbilled_charges": [ { "amount": 495, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWkmHx2UH", "date_from": 1519924849, "date_to": 1522603249, "deleted": false, "description": "SSL", "discount_amount": 0, "entity_id": "ssl", "entity_type": "addon", "id": "li___test__KyVnHhSBWkmLK2UM", "is_voided": false, "object": "unbilled_charge", "pricing_model": "flat_fee", "quantity": 1, "subscription_id": "__test__KyVnHhSBWkmHx2UH", "unit_amount": 495 }, {..} ] }
Chargebee provides the following open-source client libraries as a wrapper around the HTTP API:
To view this API reference tailored to the programming language of your choice, select the language in the “Library” dropdown above. Reach out to us at Chargebee Support if you’d like to request any other language bindings.Note
Select the programming language of your choice from the “Library” dropdown at the top of the page.
You can use cURL to test Chargebee API from a CLI. When you pass input parameters to the API using -d
or --data-urlencode
options, the HTTP POST
method is used:
curl https://{site}.chargebee.com/api/v2/subscriptions/{subscription_id}/change_term_end -u {site_api_key}:\ -d term_ends_at=1601490600
GET
method by default:
curl https://{site}.chargebee.com/api/v2/subscriptions/{subscription_id} \ -u {site_api_key}:
POST
request without providing any input parameters, use the -X POST
option:
curl -X POST https://{site}.chargebee.com/api/v2/exports/subscriptions \ -u {site_api_key}:
GET
requests with parameters, you must use the -G
option:
curl -X POST https://{site}.chargebee.com/api/v2/v2/orders \ -G \ -u {site_api_key}:\ --data-urlencode limit=3 \ --data-urlencode status[is]="queued"