Billing API
Manage billing, pricing, quotes, and promotional codes programmatically
Overview
The Billing API allows you to retrieve pricing information, manage billing history, handle quotations, and work with promotional codes. This API is essential for understanding costs, generating quotes, and managing billing-related operations.
GET Get Currencies
Retrieve available currencies for billing.
Request
{
"cmd": "billing.currency.get"
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=billing.currency.get');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={'cmd': 'billing.currency.get'},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=billing.currency.get" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET /api/rest/v2.9/billing/currencies Authorization: Bearer YOUR_JWT_TOKEN
Response
{
"code": "OK",
"message": "Currencies Retrieved Successfully",
"currencies": [
{
"code": "AUD",
"name": "Australian Dollar",
"symbol": "$"
},
{
"code": "USD",
"name": "US Dollar",
"symbol": "$"
}
]
}
GET Get Pricing
Retrieve pricing information for a specific customer.
Request
{
"cmd": "pricing.get",
"customerId": 123
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=pricing.get&customerId=123');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={
'cmd': 'pricing.get',
'customerId': 123
},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=pricing.get&customerId=123" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET /api/rest/v2.9/billing/pricing?customerId=123 Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
customerId |
integer | Yes | Customer ID to retrieve pricing for |
Response
{
"code": "OK",
"message": "Pricing List Retrieved Successfully",
"pricing": {
"customerId": 123,
"prices": [...]
}
}
GET Get All Pricing
Retrieve pricing information for the authenticated customer.
Request
GET /api/rest/v2.9/billing/{customerId}
Response
{
"code": "OK",
"message": "Pricing Retrieved Successfully",
"pricing": [...]
}
GET Get Pricing Options
Retrieve available pricing options and configurations.
Request
GET /api/rest/v2.9/billing/options GET /api/rest/v2.9/billing/pricing/options
Response
{
"code": "OK",
"message": "Pricing Options Retrieved Successfully",
"pricing": [...]
}
GET Get Billing Statistics
Retrieve billing statistics and analytics.
Request
GET /api/rest/v2.9/billing/statistics
Response
{
"code": "OK",
"message": "Statistics Retrieved Successfully",
"statistics": [...]
}
GET Get Billing History
Retrieve billing history for the authenticated customer.
Request
GET /api/rest/v2.9/billing/history?resStart=0&resWindow=50
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
resStart |
integer | No | Pagination start offset (default: 0) |
resWindow |
integer | No | Number of results per page (default: 20) |
Response
{
"code": "OK",
"message": "Billing History Retrieved Successfully",
"history": [...]
}
GET Get Quotations
Retrieve list of quotations for the authenticated customer.
Request
GET /api/rest/v2.9/billing/quotes
Response
{
"code": "OK",
"message": "Quotation Retrieved Successfully",
"quotations": [...],
"matches": 10
}
GET Validate Promo Code
Validate a promotional code to check if it's valid and applicable.
Request
{
"cmd": "billing.promo.validate",
"promocode": "PROMO123"
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=billing.promo.validate&promocode=PROMO123');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={
'cmd': 'billing.promo.validate',
'promocode': 'PROMO123'
},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=billing.promo.validate&promocode=PROMO123" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET /api/rest/v2.9/billing/promocode/validate?promocode=PROMO123 Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
promocode |
string | Yes | Promotional code to validate |
Response
{
"code": "OK",
"message": "Promo Code is valid",
"promocode": {
"code": "PROMO123",
"discount": 10,
"currencycode": "AUD"
}
}
GET Get Promo Codes
Retrieve all promotional codes available to the authenticated customer.
Request
GET /api/rest/v2.9/billing/promocode
Response
{
"code": "OK",
"message": "Promo Codes Retrieved Successfully",
"promocodes": [...]
}
POST Create Promo Code
Create a new promotional code.
Request
POST /api/rest/v2.9/billing/promocode
Content-Type: application/json
{
"code": "PROMO123",
"discount": 10,
"type": "PERCENTAGE",
"expires": "2024-12-31"
}
Response
{
"code": "OK",
"message": "Promo Code Created Successfully"
}
PUT Update Promo Code
Update an existing promotional code.
Request
PUT /api/rest/v2.9/billing/promocode/{id}
Content-Type: application/json
{
"discount": 15,
"expires": "2025-12-31"
}
Response
{
"code": "OK",
"message": "Promo Code Updated Successfully"
}
POST Add Promo Code to Customer
Apply a promotional code to a customer account.
Request
{
"cmd": "billing.promo.addcode",
"promocode": "PROMO123",
"customerid": 123
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'cmd' => 'billing.promo.addcode',
'promocode' => 'PROMO123',
'customerid' => 123
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.post(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
json={
'cmd': 'billing.promo.addcode',
'promocode': 'PROMO123',
'customerid': 123
},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X POST "https://api.rackcorp.net/api/rest/v2.9/json.php" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cmd": "billing.promo.addcode",
"promocode": "PROMO123",
"customerid": 123
}'
POST /api/rest/v2.9/billing/promocode/add
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json
{
"promocode": "PROMO123",
"customerid": 123
}
Response
{
"code": "OK",
"message": "Promo Code Added Successfully"
}
GET Get Promo Code Types
Retrieve available promotional code types.
Request
GET /api/rest/v2.9/billing/promo/types
Response
{
"code": "OK",
"message": "Promo Types Retrieved Successfully",
"promotypes": [...]
}
GET Get Service Promo Codes
Retrieve promotional codes applicable to services.
Request
GET /api/rest/v2.9/billing/service/promo
Response
{
"code": "OK",
"message": "Campaign Promo Codes Retrieved Successfully",
"servicepromos": [...]
}
GET Get Service Billing
Retrieve billing information for all services.
Request
GET /api/rest/v2.9/billing/services
Response
{
"code": "OK",
"message": "Service Billing retrieved successfully",
"servicebilling": [...],
"matches": 25
}
GET Get Billing Usage
Retrieve billing usage statistics and analytics.
Request
GET /api/rest/v2.9/billing/usage?type=usage&summary=services&time_start=2024-01-01&time_finish=2024-12-31
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type |
string | Yes | Type of data: "usage" or "billing" |
summary |
string | Yes | Summary type: "customer_resource" or "services" |
time_start |
string | Yes | Start date (YYYY-MM-DD format) |
time_finish |
string | Yes | End date (YYYY-MM-DD format) |
customerid |
integer | No | Filter by specific customer ID |
costs |
integer | No | Set to 1 to include individual costs by service |
contracts |
integer | No | Set to 1 to include all contracts by service |
Response
{
"code": "OK",
"message": "Billing usage retrieved successfully",
"usage": [...]
}
Error Responses
If an error occurs, the API will return a response with code: "FAULT":
{
"code": "FAULT",
"message": "Error message"
}