Get Account Billing or Usage Details
GET Method
Kaleyra.io offers an API that enables you to get the billing/usage details for a direct user account (that is, a user with no subaccount), for a parent account (that is a user with a subaccount), or for any given single sub-account. You can get the details such as account type (prepaid or postpaid user), currency symbol, balance amount (the balance amount available to the prepaid user), usage amount (in the current month, the total amount spent by the postpaid user), and many more.
Also, you have the option to get the sub-account billing details for a prepaid parent user. You can get sub-account details such as account type, balance amount, currency symbol, auto debit active status, and many more.
If a sub-account user sends the request with its own SID and API Key, in return this API sends their billing/usage details.
Notes:
- To get the sub-account's usage details, a prepaid parent user has to provide the sub-account's email address in the request parameter and in response they will get the billing/usage details.
- Currently, Kaleyra.io supports the sub-account's billing/usage details only for prepaid parent user.
You can get the following account details using this API:
- Prepaid Account - If you are a prepaid account user, you can view the following details in the response format:
- Account type
- Balance amount (the balance amount available to the prepaid user)
- Currency symbol
- Auto debit status
- Last recharge date
- Last recharge amount
- Postpaid Account -If you are a prepaid account user, you can view the following details in the response format:
- Account type
- Currency symbol
- Usage amount (in the current month, the total amount spent by the postpaid user)
- Whether 75% of the maximum postpaid limit has been utilized or not
- The duration in which the postpaid amount limit has been utilized
Base URL
<https://api.kaleyra.io>
To get the parent account billing/usage details, perform the following steps:
API request to get the account balance detail
To get the parent account billing/usage details, use the billing/balance
endpoint with the following request method:
Request Format
curl --location --request GET '<url>/v1/<sid>/billing/balance' \
--header 'Content-Type: <content-type>' \
--header 'api-key: <api-key>'
The following table describes the parameter used for getting the billing/usage details:
Parameter | Data Type | Description | Example | Mandatory |
---|---|---|---|---|
sid | String | Parent account SID (Security Identifier). | HXXXXXXX071IN | Yes |
content-type | String | The format in which the data is sent. | application/json | Yes |
api-key | String | Parent account API key. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes |
subaccount-email | String | Sub-account email address for which you want to know billing/usage details. | [email protected] | No (Optional) |
Sample Request
The following is the sample request to get the billing/usage details by an parent account:
curl --location --request GET 'https://api.kaleyra.io/v1/HXXXXXXX071IN/billing/balance' \
--header 'Content-Type: application/json' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3'
Sample Success Response for a Prepaid User
The following is the sample success response to get billing/usage details for a prepaid parent account:
{
"code": "RBC103",
"message": "Request processed successfully.",
"data": {
"account_type": "prepaid",
"balance_amount": 100000,
"currency_symbol": "₹",
"is_auto_debit_active": true,
"last_recharge_date": 1675209600000,
"last_recharge_amount": 1000
}
}
Sample Success Response for a Postpaid User
The following is the sample success response to get billing/usage details for a postpaid parent account:
{
"code": "RBC103",
"message": "Request processed successfully.",
"data": {
"account_type": "postpaid",
"currency_symbol": "₹",
"usage_amount": 1250,
"is_usage_greater_than_75": false,
"usage_from_date": 1675209600000,
"usage_to_date": 1676287830479
}
}
Sample Success Response for a Sub-account User with Prepaid Parent Account
The following is the sample success response to get billing/usage details of a sub-account user with a prepaid parent account:
{
"code": "RBC103",
"message": "Request processed successfully.",
"data": {
"account_type": "prepaid",
"balance_amount": 200,
"currency_symbol": "₹",
"is_auto_debit_active": false,
"is_subaccount": true
}
}
Sample Success Response when a Sub-account User sends Request with Own API Key and SID
The following is the sample success response to get billing/usage details when a sub-account user sends the request with its own API key and SID:
{
"code": "RBC103",
"message": "Request processed successfully.",
"data": {
"account_type": "prepaid",
"currency_symbol": "₹",
"balance_amount": 100,
"is_auto_debit_active": false
}
}
Sample Failure Response for a Sub-account User with Postpaid Parent Account
The following is the sample failure response to get billing/usage details of a sub-account user with a postpaid parent account:
{
"code": "RBC400",
"error": "account currently not supported",
"message": "Bad Request"
}
Sample Failure Response with an Invalid SID
The following is a sample failure response when an invalid SID is sent in the request:
{
"code": "RBC001",
"message": "Incorrect SID or API key.",
"data": [],
"error": {
"error": "Incorrect SID or API key."
}
}
For more information about response codes and statuses for getting account billing/usage details API, see Response Codes and Statuses for Billing Detail.
Updated about 1 year ago