Get usage by subscription
curl --request POST \
--url https://us.api.flexprice.io/v1/subscriptions/usage \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"subscription_id": "123",
"end_time": "2024-03-20T00:00:00Z",
"lifetime_usage": false,
"start_time": "2024-03-13T00:00:00Z"
}
'import requests
url = "https://us.api.flexprice.io/v1/subscriptions/usage"
payload = {
"subscription_id": "123",
"end_time": "2024-03-20T00:00:00Z",
"lifetime_usage": False,
"start_time": "2024-03-13T00:00:00Z"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscription_id: '123',
end_time: '2024-03-20T00:00:00Z',
lifetime_usage: false,
start_time: '2024-03-13T00:00:00Z'
})
};
fetch('https://us.api.flexprice.io/v1/subscriptions/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://us.api.flexprice.io/v1/subscriptions/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'subscription_id' => '123',
'end_time' => '2024-03-20T00:00:00Z',
'lifetime_usage' => false,
'start_time' => '2024-03-13T00:00:00Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://us.api.flexprice.io/v1/subscriptions/usage"
payload := strings.NewReader("{\n \"subscription_id\": \"123\",\n \"end_time\": \"2024-03-20T00:00:00Z\",\n \"lifetime_usage\": false,\n \"start_time\": \"2024-03-13T00:00:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://us.api.flexprice.io/v1/subscriptions/usage")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription_id\": \"123\",\n \"end_time\": \"2024-03-20T00:00:00Z\",\n \"lifetime_usage\": false,\n \"start_time\": \"2024-03-13T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/subscriptions/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription_id\": \"123\",\n \"end_time\": \"2024-03-20T00:00:00Z\",\n \"lifetime_usage\": false,\n \"start_time\": \"2024-03-13T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"amount": 123,
"charges": [
{
"amount": 123,
"currency": "<string>",
"display_amount": "<string>",
"filter_values": {},
"is_overage": true,
"meter_display_name": "<string>",
"meter_id": "<string>",
"overage_factor": 123,
"price": {
"amount": "<string>",
"billing_cadence": "RECURRING",
"billing_period_count": 123,
"conversion_rate": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"currency": "<string>",
"description": "<string>",
"display_amount": "<string>",
"display_name": "<string>",
"display_price_unit_amount": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"entity_id": "<string>",
"environment_id": "<string>",
"group_id": "<string>",
"id": "<string>",
"lookup_key": "<string>",
"metadata": {},
"meter_id": "<string>",
"min_quantity": "<string>",
"parent_price_id": "<string>",
"price_unit": "<string>",
"price_unit_amount": "<string>",
"price_unit_id": "<string>",
"price_unit_tiers": [
{
"flat_amount": "<string>",
"unit_amount": "<string>",
"up_to": 123
}
],
"sequence": 123,
"start_date": "2023-11-07T05:31:56Z",
"tenant_id": "<string>",
"tiers": [
{
"flat_amount": "<string>",
"unit_amount": "<string>",
"up_to": 123
}
],
"transform_quantity": {
"divide_by": 123
},
"trial_period_days": 123,
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
},
"quantity": 123,
"subscription_line_item_id": "<string>"
}
],
"commitment_amount": 123,
"commitment_utilized": 123,
"currency": "<string>",
"display_amount": "<string>",
"end_time": "2023-11-07T05:31:56Z",
"has_overage": true,
"overage_amount": 123,
"overage_factor": 123,
"start_time": "2023-11-07T05:31:56Z"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}Subscriptions
Get usage by subscription
Use when showing usage for a subscription (e.g. in a portal or for overage checks). Supports time range and filters.
POST
/
subscriptions
/
usage
Get usage by subscription
curl --request POST \
--url https://us.api.flexprice.io/v1/subscriptions/usage \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"subscription_id": "123",
"end_time": "2024-03-20T00:00:00Z",
"lifetime_usage": false,
"start_time": "2024-03-13T00:00:00Z"
}
'import requests
url = "https://us.api.flexprice.io/v1/subscriptions/usage"
payload = {
"subscription_id": "123",
"end_time": "2024-03-20T00:00:00Z",
"lifetime_usage": False,
"start_time": "2024-03-13T00:00:00Z"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscription_id: '123',
end_time: '2024-03-20T00:00:00Z',
lifetime_usage: false,
start_time: '2024-03-13T00:00:00Z'
})
};
fetch('https://us.api.flexprice.io/v1/subscriptions/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://us.api.flexprice.io/v1/subscriptions/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'subscription_id' => '123',
'end_time' => '2024-03-20T00:00:00Z',
'lifetime_usage' => false,
'start_time' => '2024-03-13T00:00:00Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://us.api.flexprice.io/v1/subscriptions/usage"
payload := strings.NewReader("{\n \"subscription_id\": \"123\",\n \"end_time\": \"2024-03-20T00:00:00Z\",\n \"lifetime_usage\": false,\n \"start_time\": \"2024-03-13T00:00:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://us.api.flexprice.io/v1/subscriptions/usage")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription_id\": \"123\",\n \"end_time\": \"2024-03-20T00:00:00Z\",\n \"lifetime_usage\": false,\n \"start_time\": \"2024-03-13T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/subscriptions/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription_id\": \"123\",\n \"end_time\": \"2024-03-20T00:00:00Z\",\n \"lifetime_usage\": false,\n \"start_time\": \"2024-03-13T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"amount": 123,
"charges": [
{
"amount": 123,
"currency": "<string>",
"display_amount": "<string>",
"filter_values": {},
"is_overage": true,
"meter_display_name": "<string>",
"meter_id": "<string>",
"overage_factor": 123,
"price": {
"amount": "<string>",
"billing_cadence": "RECURRING",
"billing_period_count": 123,
"conversion_rate": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"currency": "<string>",
"description": "<string>",
"display_amount": "<string>",
"display_name": "<string>",
"display_price_unit_amount": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"entity_id": "<string>",
"environment_id": "<string>",
"group_id": "<string>",
"id": "<string>",
"lookup_key": "<string>",
"metadata": {},
"meter_id": "<string>",
"min_quantity": "<string>",
"parent_price_id": "<string>",
"price_unit": "<string>",
"price_unit_amount": "<string>",
"price_unit_id": "<string>",
"price_unit_tiers": [
{
"flat_amount": "<string>",
"unit_amount": "<string>",
"up_to": 123
}
],
"sequence": 123,
"start_date": "2023-11-07T05:31:56Z",
"tenant_id": "<string>",
"tiers": [
{
"flat_amount": "<string>",
"unit_amount": "<string>",
"up_to": 123
}
],
"transform_quantity": {
"divide_by": 123
},
"trial_period_days": 123,
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
},
"quantity": 123,
"subscription_line_item_id": "<string>"
}
],
"commitment_amount": 123,
"commitment_utilized": 123,
"currency": "<string>",
"display_amount": "<string>",
"end_time": "2023-11-07T05:31:56Z",
"has_overage": true,
"overage_amount": 123,
"overage_factor": 123,
"start_time": "2023-11-07T05:31:56Z"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}Authorizations
Enter your API key in the format x-api-key <api-key>*
Body
application/json
Usage request
Response
OK
Show child attributes
Show child attributes
Amount of commitment used
Whether any usage exceeded commitment
Amount charged at overage rate
⌘I

