Create a billable metric
Defines a new billable metric. A metric specifies the event name, optional filter groups, and aggregation logic that turns raw ingested events into a quantity the billing engine can price against.
curl --request POST \
--url https://api.alguna.io/metrics \
--header 'Alguna-Version: <alguna-version>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"aggregation": {
"method": "sum",
"field": "amount"
},
"event_name": "api_call",
"name": "API Calls",
"description": "Counts API calls per customer",
"filter_groups": [
{
"filters": [
{
"field": "region",
"operator": "equal",
"value": "us-east-1"
}
],
"operator": "and"
}
],
"tag_ids": [
"<string>"
]
}
'import requests
url = "https://api.alguna.io/metrics"
payload = {
"aggregation": {
"method": "sum",
"field": "amount"
},
"event_name": "api_call",
"name": "API Calls",
"description": "Counts API calls per customer",
"filter_groups": [
{
"filters": [
{
"field": "region",
"operator": "equal",
"value": "us-east-1"
}
],
"operator": "and"
}
],
"tag_ids": ["<string>"]
}
headers = {
"Alguna-Version": "<alguna-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Alguna-Version': '<alguna-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
aggregation: {method: 'sum', field: 'amount'},
event_name: 'api_call',
name: 'API Calls',
description: 'Counts API calls per customer',
filter_groups: [
{
filters: [{field: 'region', operator: 'equal', value: 'us-east-1'}],
operator: 'and'
}
],
tag_ids: ['<string>']
})
};
fetch('https://api.alguna.io/metrics', 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.alguna.io/metrics",
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([
'aggregation' => [
'method' => 'sum',
'field' => 'amount'
],
'event_name' => 'api_call',
'name' => 'API Calls',
'description' => 'Counts API calls per customer',
'filter_groups' => [
[
'filters' => [
[
'field' => 'region',
'operator' => 'equal',
'value' => 'us-east-1'
]
],
'operator' => 'and'
]
],
'tag_ids' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Alguna-Version: <alguna-version>",
"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.alguna.io/metrics"
payload := strings.NewReader("{\n \"aggregation\": {\n \"method\": \"sum\",\n \"field\": \"amount\"\n },\n \"event_name\": \"api_call\",\n \"name\": \"API Calls\",\n \"description\": \"Counts API calls per customer\",\n \"filter_groups\": [\n {\n \"filters\": [\n {\n \"field\": \"region\",\n \"operator\": \"equal\",\n \"value\": \"us-east-1\"\n }\n ],\n \"operator\": \"and\"\n }\n ],\n \"tag_ids\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Alguna-Version", "<alguna-version>")
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.post("https://api.alguna.io/metrics")
.header("Alguna-Version", "<alguna-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"aggregation\": {\n \"method\": \"sum\",\n \"field\": \"amount\"\n },\n \"event_name\": \"api_call\",\n \"name\": \"API Calls\",\n \"description\": \"Counts API calls per customer\",\n \"filter_groups\": [\n {\n \"filters\": [\n {\n \"field\": \"region\",\n \"operator\": \"equal\",\n \"value\": \"us-east-1\"\n }\n ],\n \"operator\": \"and\"\n }\n ],\n \"tag_ids\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.alguna.io/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Alguna-Version"] = '<alguna-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"aggregation\": {\n \"method\": \"sum\",\n \"field\": \"amount\"\n },\n \"event_name\": \"api_call\",\n \"name\": \"API Calls\",\n \"description\": \"Counts API calls per customer\",\n \"filter_groups\": [\n {\n \"filters\": [\n {\n \"field\": \"region\",\n \"operator\": \"equal\",\n \"value\": \"us-east-1\"\n }\n ],\n \"operator\": \"and\"\n }\n ],\n \"tag_ids\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"aggregation": {
"field": "amount",
"method": "sum"
},
"created_at": "2026-04-01T10:00:00Z",
"event_name": "api_call",
"id": "mtr_01H1VECT",
"name": "API Calls",
"updated_at": "2026-04-01T12:30:00Z",
"description": "Counts API calls per customer",
"filter_groups": [
{
"filters": [
{
"field": "region",
"operator": "equal",
"value": "us-east-1"
}
],
"operator": "and"
}
],
"tag_ids": [
"<string>"
]
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}Authorizations
API key authentication. Pass your API key as a Bearer token.
Headers
2026-04-01 A unique string used to ensure the request is processed exactly once. If you retry a request with the same idempotency key within 24 hours, the original response is returned without re-executing the operation.
255"ik_a1b2c3d4e5f6"
Body
How events are aggregated into a metric value
Show child attributes
Show child attributes
Event name that triggers this metric
"api_call"
Name of the metric
"API Calls"
Description of the metric
"Counts API calls per customer"
Filter groups to apply to events before aggregation
Show child attributes
Show child attributes
Tag identifiers to associate with this metric
Response
Success
How events are aggregated into a metric value
Show child attributes
Show child attributes
Timestamp when the metric was created
"2026-04-01T10:00:00Z"
Event name that triggers this metric
"api_call"
Unique identifier for the metric
"mtr_01H1VECT"
Name of the metric
"API Calls"
Timestamp when the metric was last updated
"2026-04-01T12:30:00Z"
Description of the metric
"Counts API calls per customer"
Filter groups applied to events before aggregation
Show child attributes
Show child attributes
Tag identifiers associated with this metric
curl --request POST \
--url https://api.alguna.io/metrics \
--header 'Alguna-Version: <alguna-version>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"aggregation": {
"method": "sum",
"field": "amount"
},
"event_name": "api_call",
"name": "API Calls",
"description": "Counts API calls per customer",
"filter_groups": [
{
"filters": [
{
"field": "region",
"operator": "equal",
"value": "us-east-1"
}
],
"operator": "and"
}
],
"tag_ids": [
"<string>"
]
}
'import requests
url = "https://api.alguna.io/metrics"
payload = {
"aggregation": {
"method": "sum",
"field": "amount"
},
"event_name": "api_call",
"name": "API Calls",
"description": "Counts API calls per customer",
"filter_groups": [
{
"filters": [
{
"field": "region",
"operator": "equal",
"value": "us-east-1"
}
],
"operator": "and"
}
],
"tag_ids": ["<string>"]
}
headers = {
"Alguna-Version": "<alguna-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Alguna-Version': '<alguna-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
aggregation: {method: 'sum', field: 'amount'},
event_name: 'api_call',
name: 'API Calls',
description: 'Counts API calls per customer',
filter_groups: [
{
filters: [{field: 'region', operator: 'equal', value: 'us-east-1'}],
operator: 'and'
}
],
tag_ids: ['<string>']
})
};
fetch('https://api.alguna.io/metrics', 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.alguna.io/metrics",
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([
'aggregation' => [
'method' => 'sum',
'field' => 'amount'
],
'event_name' => 'api_call',
'name' => 'API Calls',
'description' => 'Counts API calls per customer',
'filter_groups' => [
[
'filters' => [
[
'field' => 'region',
'operator' => 'equal',
'value' => 'us-east-1'
]
],
'operator' => 'and'
]
],
'tag_ids' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Alguna-Version: <alguna-version>",
"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.alguna.io/metrics"
payload := strings.NewReader("{\n \"aggregation\": {\n \"method\": \"sum\",\n \"field\": \"amount\"\n },\n \"event_name\": \"api_call\",\n \"name\": \"API Calls\",\n \"description\": \"Counts API calls per customer\",\n \"filter_groups\": [\n {\n \"filters\": [\n {\n \"field\": \"region\",\n \"operator\": \"equal\",\n \"value\": \"us-east-1\"\n }\n ],\n \"operator\": \"and\"\n }\n ],\n \"tag_ids\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Alguna-Version", "<alguna-version>")
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.post("https://api.alguna.io/metrics")
.header("Alguna-Version", "<alguna-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"aggregation\": {\n \"method\": \"sum\",\n \"field\": \"amount\"\n },\n \"event_name\": \"api_call\",\n \"name\": \"API Calls\",\n \"description\": \"Counts API calls per customer\",\n \"filter_groups\": [\n {\n \"filters\": [\n {\n \"field\": \"region\",\n \"operator\": \"equal\",\n \"value\": \"us-east-1\"\n }\n ],\n \"operator\": \"and\"\n }\n ],\n \"tag_ids\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.alguna.io/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Alguna-Version"] = '<alguna-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"aggregation\": {\n \"method\": \"sum\",\n \"field\": \"amount\"\n },\n \"event_name\": \"api_call\",\n \"name\": \"API Calls\",\n \"description\": \"Counts API calls per customer\",\n \"filter_groups\": [\n {\n \"filters\": [\n {\n \"field\": \"region\",\n \"operator\": \"equal\",\n \"value\": \"us-east-1\"\n }\n ],\n \"operator\": \"and\"\n }\n ],\n \"tag_ids\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"aggregation": {
"field": "amount",
"method": "sum"
},
"created_at": "2026-04-01T10:00:00Z",
"event_name": "api_call",
"id": "mtr_01H1VECT",
"name": "API Calls",
"updated_at": "2026-04-01T12:30:00Z",
"description": "Counts API calls per customer",
"filter_groups": [
{
"filters": [
{
"field": "region",
"operator": "equal",
"value": "us-east-1"
}
],
"operator": "and"
}
],
"tag_ids": [
"<string>"
]
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}