curl --request PATCH \
--url https://api.paygentic.io/v0/billableMetrics/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "<string>",
"name": "<string>",
"unit": "<string>",
"itemId": "<string>",
"eventType": "<string>",
"valueProperty": "<string>",
"groupBy": {},
"eventFrom": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.paygentic.io/v0/billableMetrics/{id}"
payload = {
"description": "<string>",
"name": "<string>",
"unit": "<string>",
"itemId": "<string>",
"eventType": "<string>",
"valueProperty": "<string>",
"groupBy": {},
"eventFrom": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
description: '<string>',
name: '<string>',
unit: '<string>',
itemId: '<string>',
eventType: '<string>',
valueProperty: '<string>',
groupBy: {},
eventFrom: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.paygentic.io/v0/billableMetrics/{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.paygentic.io/v0/billableMetrics/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'description' => '<string>',
'name' => '<string>',
'unit' => '<string>',
'itemId' => '<string>',
'eventType' => '<string>',
'valueProperty' => '<string>',
'groupBy' => [
],
'eventFrom' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.paygentic.io/v0/billableMetrics/{id}"
payload := strings.NewReader("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"unit\": \"<string>\",\n \"itemId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"valueProperty\": \"<string>\",\n \"groupBy\": {},\n \"eventFrom\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.paygentic.io/v0/billableMetrics/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"unit\": \"<string>\",\n \"itemId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"valueProperty\": \"<string>\",\n \"groupBy\": {},\n \"eventFrom\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paygentic.io/v0/billableMetrics/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"unit\": \"<string>\",\n \"itemId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"valueProperty\": \"<string>\",\n \"groupBy\": {},\n \"eventFrom\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"id": "bm_u3v4w5x6y7z8a9b0",
"object": "billableMetric",
"aggregation": "SUM",
"createdAt": "2024-02-01T14:45:30Z",
"description": "Language model token consumption",
"merchantId": "org_c1d2e3f4g5h6i7j8",
"name": "LLM Tokens",
"productId": "prod_k9l0m1n2o3p4q5r6",
"unit": "tokens",
"updatedAt": "2024-03-15T11:30:00Z"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}Update
curl --request PATCH \
--url https://api.paygentic.io/v0/billableMetrics/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "<string>",
"name": "<string>",
"unit": "<string>",
"itemId": "<string>",
"eventType": "<string>",
"valueProperty": "<string>",
"groupBy": {},
"eventFrom": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.paygentic.io/v0/billableMetrics/{id}"
payload = {
"description": "<string>",
"name": "<string>",
"unit": "<string>",
"itemId": "<string>",
"eventType": "<string>",
"valueProperty": "<string>",
"groupBy": {},
"eventFrom": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
description: '<string>',
name: '<string>',
unit: '<string>',
itemId: '<string>',
eventType: '<string>',
valueProperty: '<string>',
groupBy: {},
eventFrom: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.paygentic.io/v0/billableMetrics/{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.paygentic.io/v0/billableMetrics/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'description' => '<string>',
'name' => '<string>',
'unit' => '<string>',
'itemId' => '<string>',
'eventType' => '<string>',
'valueProperty' => '<string>',
'groupBy' => [
],
'eventFrom' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.paygentic.io/v0/billableMetrics/{id}"
payload := strings.NewReader("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"unit\": \"<string>\",\n \"itemId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"valueProperty\": \"<string>\",\n \"groupBy\": {},\n \"eventFrom\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://api.paygentic.io/v0/billableMetrics/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"unit\": \"<string>\",\n \"itemId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"valueProperty\": \"<string>\",\n \"groupBy\": {},\n \"eventFrom\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paygentic.io/v0/billableMetrics/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"name\": \"<string>\",\n \"unit\": \"<string>\",\n \"itemId\": \"<string>\",\n \"eventType\": \"<string>\",\n \"valueProperty\": \"<string>\",\n \"groupBy\": {},\n \"eventFrom\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"id": "bm_u3v4w5x6y7z8a9b0",
"object": "billableMetric",
"aggregation": "SUM",
"createdAt": "2024-02-01T14:45:30Z",
"description": "Language model token consumption",
"merchantId": "org_c1d2e3f4g5h6i7j8",
"name": "LLM Tokens",
"productId": "prod_k9l0m1n2o3p4q5r6",
"unit": "tokens",
"updatedAt": "2024-03-15T11:30:00Z"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}Authorizations
API key authentication
Path Parameters
Unique identifier for a billable metric
^bm_[a-zA-Z0-9]+$Body
Revised explanation of what the metric represents. Sample values: 'Language model token consumption', 'Database storage capacity used', 'Machine learning prediction API calls', 'AI-generated content items'
Updated label for the metric. Sample values: 'LLM Tokens', 'Database Storage', 'Prediction Requests', 'Content Generations'
Updated measurement unit. Common examples: 'tokens', 'GB', 'requests', 'items', 'hours'
Optional item tag, used to map this metric's invoice lines to an external accounting/tax identity. Send a new id to re-tag — the item must be filed under this charge's own product, and an archived item is rejected. An item from another product is refused with ITEM_PRODUCT_MISMATCH: a tag is an accounting grouping and does not move the charge between products, and no field here could move it back. Re-file the item to move every charge anchored to it together. Send null to untag. Every line item whose invoice has not closed reports this charge's current tag, so a re-tag takes effect on the bill in progress and on any generated ahead of it — no further action, and no window to wait for. Lines on a closed invoice keep the item recorded at close and never move. Un-tagging works the same way: those lines report no item.
^itm_[a-zA-Z0-9]+$CloudEvents type for meter routing.
JSONPath to extract a numeric value from event data. Must start with $. (example: $.amount or $.payload.bytes).
^\$\.[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*$Map of dimension name to JSONPath for group-by queries. Each value must start with $. (example: $.region).
Show child attributes
Show child attributes
Only count events after this timestamp.
Response
Billable metric updated successfully
Unique identifier for a billable metric
^bm_[a-zA-Z0-9]+$billableMetric SUM, COUNT, AVG, MIN, MAX, UNIQUE_COUNT, LATEST Unique identifier for an organization
^org_[a-zA-Z0-9]+$The product this metric belongs to. Always populated; derived from the item's catalog when the metric is tagged with an item.
^prod_[a-zA-Z0-9]+$The item this metric is tagged with, or null when untagged. Used to map this metric's invoice lines to an external accounting/tax identity.
^itm_[a-zA-Z0-9]+$Show child attributes
Show child attributes
Was this page helpful?