Get a billable metric
curl --request GET \
--url https://api.metronome.com/v1/billable-metrics/{billable_metric_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.metronome.com/v1/billable-metrics/{billable_metric_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.metronome.com/v1/billable-metrics/{billable_metric_id}', 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://api.metronome.com/v1/billable-metrics/{billable_metric_id}",
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://api.metronome.com/v1/billable-metrics/{billable_metric_id}"
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://api.metronome.com/v1/billable-metrics/{billable_metric_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.metronome.com/v1/billable-metrics/{billable_metric_id}")
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": {
"id": "8deed800-1b7a-495d-a207-6c52bac54dc9",
"name": "CPU Hours",
"event_type_filter": {
"in_values": [
"cpu_usage"
]
},
"property_filters": [
{
"name": "cpu_hours",
"exists": true
},
{
"name": "region",
"exists": true,
"in_values": [
"EU",
"NA"
]
},
{
"name": "machine_type",
"exists": true,
"in_values": [
"slow",
"fast"
]
}
],
"aggregation_type": "SUM",
"aggregation_key": "cpu_hours",
"group_keys": [
[
"region"
],
[
"machine_type"
]
]
}
}{
"message": "<string>"
}Billable metrics
Get a billable metric
Retrieves the complete configuration for a specific billable metric by its ID. Use this to review billable metric setup before associating it with products. Returns the metric’s name, event_type_filter, property_filters, aggregation_type, aggregation_key, group_keys, custom fields, and SQL query (if it’s a SQL billable metric).
Important:
- Archived billable metrics will include an
archived_attimestamp; they no longer process new usage events but remain accessible for historical reference.
GET
/
v1
/
billable-metrics
/
{billable_metric_id}
Get a billable metric
curl --request GET \
--url https://api.metronome.com/v1/billable-metrics/{billable_metric_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.metronome.com/v1/billable-metrics/{billable_metric_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.metronome.com/v1/billable-metrics/{billable_metric_id}', 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://api.metronome.com/v1/billable-metrics/{billable_metric_id}",
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://api.metronome.com/v1/billable-metrics/{billable_metric_id}"
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://api.metronome.com/v1/billable-metrics/{billable_metric_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.metronome.com/v1/billable-metrics/{billable_metric_id}")
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": {
"id": "8deed800-1b7a-495d-a207-6c52bac54dc9",
"name": "CPU Hours",
"event_type_filter": {
"in_values": [
"cpu_usage"
]
},
"property_filters": [
{
"name": "cpu_hours",
"exists": true
},
{
"name": "region",
"exists": true,
"in_values": [
"EU",
"NA"
]
},
{
"name": "machine_type",
"exists": true,
"in_values": [
"slow",
"fast"
]
}
],
"aggregation_type": "SUM",
"aggregation_key": "cpu_hours",
"group_keys": [
[
"region"
],
[
"machine_type"
]
]
}
}{
"message": "<string>"
}⌘I