Metering
Plans Pricing on a Metric
The charges that consume a billable metric, each with its plan and charge model — the reverse lookup of a plan’s charges.
GET
/
v1
/
billable-metrics
/
{id}
/
charges
Plans pricing on this meter (reverse lookup)
curl --request GET \
--url https://billing.example.com/v1/billable-metrics/{id}/charges \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/billable-metrics/{id}/charges"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://billing.example.com/v1/billable-metrics/{id}/charges', 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://billing.example.com/v1/billable-metrics/{id}/charges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/billable-metrics/{id}/charges"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://billing.example.com/v1/billable-metrics/{id}/charges")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/billable-metrics/{id}/charges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"charge_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_name": "<string>",
"plan_code": "<string>",
"plan_active": true,
"charge_model": "<string>",
"pay_in_advance": true
}
]
}Returns the charges that consume this billable metric, each with its plan
(name, code, active flag) and charge model — the meter page’s “which plans
price on this meter”, the reverse of a plan’s charges. Use it before
deleting or reshaping a metric to see what
pricing depends on it.
Example Request
curl "https://api.recurso.dev/v1/billable-metrics/3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f/charges" \
-H "Authorization: Bearer $API_KEY"
Response
{
"data": [
{
"charge_id": "9f8e7d6c-5b4a-4938-8271-605f4e3d2c1b",
"plan_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"plan_name": "Growth",
"plan_code": "growth-monthly",
"plan_active": true,
"charge_model": "graduated",
"pay_in_advance": false
},
{
"charge_id": "7e9f0a1b-2c3d-4e5f-8a6b-7c8d9e0f1a2b",
"plan_id": "5c7d8e9f-0a1b-4c2d-8e3f-4a5b6c7d8e9f",
"plan_name": "Scale",
"plan_code": "scale-monthly",
"plan_active": true,
"charge_model": "package",
"pay_in_advance": true
}
]
}
Fields
| Field | Type | Description |
|---|---|---|
charge_id | string (uuid) | The charge on the plan |
plan_id / plan_name / plan_code | uuid / string / string | The plan the charge belongs to |
plan_active | boolean | Whether that plan is currently active |
charge_model | string | How the charge prices usage (e.g. standard, graduated, package) |
pay_in_advance | boolean | Whether the charge bills in advance rather than in arrears |
Read-only. A metric no plan prices on returns an empty list; a missing or
cross-tenant
id returns 404.⌘I
Plans pricing on this meter (reverse lookup)
curl --request GET \
--url https://billing.example.com/v1/billable-metrics/{id}/charges \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/billable-metrics/{id}/charges"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://billing.example.com/v1/billable-metrics/{id}/charges', 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://billing.example.com/v1/billable-metrics/{id}/charges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/billable-metrics/{id}/charges"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://billing.example.com/v1/billable-metrics/{id}/charges")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/billable-metrics/{id}/charges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"charge_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"plan_name": "<string>",
"plan_code": "<string>",
"plan_active": true,
"charge_model": "<string>",
"pay_in_advance": true
}
]
}