chargebee chatChat with us

Chargebee provides HTTP based API which follows the essence of REST*. The HTTP protocol's rules are followed thereby enabling simple HTTP client tools like "curl" to be used.

The following client libraries provide a "easy to use" wrapper around the raw http based api.

Please do mail us at support@chargebee.com if you need any other language bindings.

Sample Snippets

Want us to generate ready-to-test snippets to use with your ChargeBee sandbox site?
to ChargeBee and open the API docs from there and you'll find ready to use sample codes here. Don't have an account with Chargebee yet? .

Sample Apps

Checkout our collection of sample applications with tutorials on integrating with ChargeBee.

Need more help with the terminologies?

Refer to our documentation for a detailed definition & description of all the components in ChargeBee.

You could use CURL to test chargebee api easily from command line.

curl https://{site}.chargebee.com/api/v1 -u {site_api_key}:

Chargebee uses HTTP BASIC Auth for authenticating the api calls. The user name is your "api key" and the password is empty. The api key could be got from 'Your Api Keys' page under integration tab in the web client console.

Note: The api keys are different for your sandbox site and your production site.

Authentication in curl

For curl you could specify the apikey using the -u option

curl {api url} -u {api key}:

Since the password is not present, nothing is specified after the colon(:)

Resources

ChargeBee follows the REST model of exposing resources as urls.
The following resources are exposed via the api.

Resource URLs

The following URLs point to the resources


https://{site}.chargebee.com/api/v1/subscriptions

https://{site}.chargebee.com/api/v1/customers

https://{site}.chargebee.com/api/v1/cards

https://{site}.chargebee.com/api/v1/invoices

https://{site}.chargebee.com/api/v1/transactions

https://{site}.chargebee.com/api/v1/hosted_pages

https://{site}.chargebee.com/api/v1/estimates

https://{site}.chargebee.com/api/v1/plans

https://{site}.chargebee.com/api/v1/addons

https://{site}.chargebee.com/api/v1/coupons

https://{site}.chargebee.com/api/v1/coupon_codes

https://{site}.chargebee.com/api/v1/addresses

https://{site}.chargebee.com/api/v1/events

https://{site}.chargebee.com/api/v1/comments

https://{site}.chargebee.com/api/v1/downloads

Operations

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

Invoking operations in CURL

By default curl uses GET method. You could pass the parameters for GET operations using

curl {api url}?{param}={value}&{param}={value}

For passing parameters for POST operations, use -d option. CURL automatically uses to POST if any parameter is sent via -d option. Use -X option to specify a specific http method to use.

Response

The response is in JSON format. Currently we are not supporting any other format.

HTTP status code is used to indicate success or failure of an API call. The detailed error code and description is present in the JSON content in response body.

The standard response codes are used.

  • 2XX The response code in this range implies the API call has succeeded.
  • 3XX This range is not used currently.
  • 4XX response codes indicate failure due to wrong input (i.e, client) side.
    Notable among them are:
    • 400 - Bad request - Mostly due to missing or malformed parameters. The specific error type is present in the error code attribute in the content.
    • 401 - Unauthorized - The Authorization header required for basic authentication is either missing or contains invalid site + API key combo.
    • 403 - Forbidden - The API key is valid but the operation is not allowed due to security constraints.
    • 404 - Not Found - The requested resource is not found.
  • 5XX response codes indicate API request was valid but failed due to bugs on the ChargeBee server side.

Sample error response in JSON:

{ http_code:"400", error_code:"param_not_present", message:"plan_id is not present", param:"plan_id", }