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.
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.
If you are calling our APIs without any of the client libraries, you can set the User-Agent
header to a custom value to differentiate API calls from different applications and help with troubleshooting.
curl https://{site}.chargebee.com/api/v2/customers \ -X POST \ -H 'User-Agent: my-app' \ -u {site_api_key}: \ -d first_name="John" \ -d last_name="Doe" \ -d email="[email protected]"
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 [email protected] 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"
As part of our commitment to enhance the developer experience, we're thrilled to introduce the Chargebee OpenAPI specification. It's the first step in a series of planned improvements.
The Chargebee OpenAPI specification is a version of our API spec that is fully compliant with the OpenAPI Specification v3.0.1. Stay tuned for more updates!