Calculate usage-based costs
1 min
POST
https://app.amberflo.io/payments/cost/usage-cost
Body Parameters
- bodypayment.cost.UsageCostsKey.inDescription
- productIdstringDescription
- timeRangepayment.common.TimeRange.inDescription
- startTimeInSecondsinteger<int64>Description
- endTimeInSecondsinteger<int64>Description
- timeGroupingIntervalcommon.aggregation.AggregationInterval.inDescription
- filtersmap<string, string[]>Description
- groupBystring[]Description
- pagepayment.common.Page.inDescription
- numberinteger<int32>Description
- sizeinteger<int32>Description
- tokenstringDescription
- takepayment.common.Take.inDescription
- limitinteger<int32>Description
- isAscendingbooleanDescription
Responses
200
- payment.cost.UsageCosts.outDescription
- keypayment.cost.UsageCostsKey.outDescription
- productIdstringDescription
- timeRangepayment.common.TimeRange.inDescription
- startTimeInSecondsinteger<int64>Description
- endTimeInSecondsinteger<int64>Description
- timeGroupingIntervalcommon.aggregation.AggregationInterval.inDescription
- filtersmap<string, string[]>Description
- groupBystring[]Description
- pagepayment.common.Page.inDescription
- numberinteger<int32>Description
- sizeinteger<int32>Description
- tokenstringDescription
- takepayment.common.Take.inDescription
- limitinteger<int32>Description
- isAscendingbooleanDescription
- secondsSinceEpochIntervalsinteger[]Description
- costListpayment.cost.UsageGroupCosts.out[]Description
- groupInfosmap<string, string>Description
- meteredUnitsnumberDescription
- pricenumberDescription
- priceBeforeDiscountsnumberDescription
- prepaidUsednumberDescription
- priceMinusPrepaidnumberDescription
- payAsYouGoPromotionUsednumberDescription
- nonPayAsYouGoPromotionUsednumberDescription
- priceAfterPayAsYouGoPromotionnumberDescription
- priceAfterNonPayAsYouGoPromotionnumberDescription
- costspayment.cost.UsageGroupCostValue.out[]Description
- startTimeInSecondsinteger<int64>Description
- meteredUnitsnumberDescription
- pricenumberDescription
- pricePercentageDiffnumberDescription
- meterUnitsPercentageDiffnumberDescription
- priceBeforeDiscountsnumberDescription
- prepaidUsednumberDescription
- payAsYouGoPromotionUsednumberDescription
- pageInfopayment.common.PageInfo.outDescription
- pageNumberinteger<int32>Description
- pageSizeinteger<int32>Description
- pageTokenstringDescription
- totalPagesinteger<int32>Description
- totalResultsinteger<int32>Description
400
401
403
404
500
curl
curl --request POST \
--url https://app.amberflo.io/payments/cost/usage-cost \
--header 'accept: application/json'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var requestOptions = {
method: 'POST',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://app.amberflo.io/payments/cost/usage-cost", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://app.amberflo.io/payments/cost/usage-cost")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://app.amberflo.io/payments/cost/usage-cost"
payload = {}
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
200
// Returns detailed usage cost breakdown with pricing calculations and charge allocations
{
"key": {
"productId": "",
"timeRange": {
"startTimeInSeconds": "",
"endTimeInSeconds": ""
},
"timeGroupingInterval": "",
"filters": "",
"groupBy": [
""
],
"page": {
"number": "",
"size": "",
"token": ""
},
"take": {
"limit": "",
"isAscending": false
}
},
"secondsSinceEpochIntervals": [
0
],
"costList": [
{
"groupInfos": "",
"meteredUnits": 0,
"price": 0,
"priceBeforeDiscounts": 0,
"prepaidUsed": 0,
"priceMinusPrepaid": 0,
"payAsYouGoPromotionUsed": 0,
"nonPayAsYouGoPromotionUsed": 0,
"priceAfterPayAsYouGoPromotion": 0,
"priceAfterNonPayAsYouGoPromotion": 0,
"costs": [
{
"startTimeInSeconds": "",
"meteredUnits": 0,
"price": 0,
"pricePercentageDiff": 0,
"meterUnitsPercentageDiff": 0,
"priceBeforeDiscounts": 0,
"prepaidUsed": 0,
"payAsYouGoPromotionUsed": 0
}
]
}
],
"pageInfo": {
"pageNumber": "",
"pageSize": "",
"pageToken": "",
"totalPages": "",
"totalResults": ""
}
}400
// Invalid usage cost parameters or unsupported time period format
401
// Authentication required or invalid API key provided
403
// Insufficient permissions to access usage cost data
404
// Customer or usage data not found for specified parameters
500
// Internal server error occurred while calculating usage costs