Get usage by meter
curl --request POST \
--url https://us.api.flexprice.io/v1/events/usage/meter \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"meter_id": "123",
"billing_anchor": "2024-03-05T14:30:45Z",
"customer_id": "customer456",
"end_time": "2024-12-09T00:00:00Z",
"external_customer_id": "user_5",
"filters": {},
"start_time": "2024-11-09T00:00:00Z"
}
'import requests
url = "https://us.api.flexprice.io/v1/events/usage/meter"
payload = {
"meter_id": "123",
"billing_anchor": "2024-03-05T14:30:45Z",
"customer_id": "customer456",
"end_time": "2024-12-09T00:00:00Z",
"external_customer_id": "user_5",
"filters": {},
"start_time": "2024-11-09T00: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({
meter_id: '123',
billing_anchor: '2024-03-05T14:30:45Z',
customer_id: 'customer456',
end_time: '2024-12-09T00:00:00Z',
external_customer_id: 'user_5',
filters: {},
start_time: '2024-11-09T00:00:00Z'
})
};
fetch('https://us.api.flexprice.io/v1/events/usage/meter', 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/events/usage/meter",
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([
'meter_id' => '123',
'billing_anchor' => '2024-03-05T14:30:45Z',
'customer_id' => 'customer456',
'end_time' => '2024-12-09T00:00:00Z',
'external_customer_id' => 'user_5',
'filters' => [
],
'start_time' => '2024-11-09T00: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/events/usage/meter"
payload := strings.NewReader("{\n \"meter_id\": \"123\",\n \"billing_anchor\": \"2024-03-05T14:30:45Z\",\n \"customer_id\": \"customer456\",\n \"end_time\": \"2024-12-09T00:00:00Z\",\n \"external_customer_id\": \"user_5\",\n \"filters\": {},\n \"start_time\": \"2024-11-09T00: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/events/usage/meter")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"meter_id\": \"123\",\n \"billing_anchor\": \"2024-03-05T14:30:45Z\",\n \"customer_id\": \"customer456\",\n \"end_time\": \"2024-12-09T00:00:00Z\",\n \"external_customer_id\": \"user_5\",\n \"filters\": {},\n \"start_time\": \"2024-11-09T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/events/usage/meter")
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 \"meter_id\": \"123\",\n \"billing_anchor\": \"2024-03-05T14:30:45Z\",\n \"customer_id\": \"customer456\",\n \"end_time\": \"2024-12-09T00:00:00Z\",\n \"external_customer_id\": \"user_5\",\n \"filters\": {},\n \"start_time\": \"2024-11-09T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"event_name": "<string>",
"results": [
{
"value": 123,
"window_size": "<string>"
}
],
"type": "COUNT",
"value": 123
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Events
Get usage by meter
Use when showing usage for a specific meter (e.g. dashboard or overage check). Supports time range, filters, and grouping by customer or subscription.
POST
/
events
/
usage
/
meter
Get usage by meter
curl --request POST \
--url https://us.api.flexprice.io/v1/events/usage/meter \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"meter_id": "123",
"billing_anchor": "2024-03-05T14:30:45Z",
"customer_id": "customer456",
"end_time": "2024-12-09T00:00:00Z",
"external_customer_id": "user_5",
"filters": {},
"start_time": "2024-11-09T00:00:00Z"
}
'import requests
url = "https://us.api.flexprice.io/v1/events/usage/meter"
payload = {
"meter_id": "123",
"billing_anchor": "2024-03-05T14:30:45Z",
"customer_id": "customer456",
"end_time": "2024-12-09T00:00:00Z",
"external_customer_id": "user_5",
"filters": {},
"start_time": "2024-11-09T00: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({
meter_id: '123',
billing_anchor: '2024-03-05T14:30:45Z',
customer_id: 'customer456',
end_time: '2024-12-09T00:00:00Z',
external_customer_id: 'user_5',
filters: {},
start_time: '2024-11-09T00:00:00Z'
})
};
fetch('https://us.api.flexprice.io/v1/events/usage/meter', 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/events/usage/meter",
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([
'meter_id' => '123',
'billing_anchor' => '2024-03-05T14:30:45Z',
'customer_id' => 'customer456',
'end_time' => '2024-12-09T00:00:00Z',
'external_customer_id' => 'user_5',
'filters' => [
],
'start_time' => '2024-11-09T00: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/events/usage/meter"
payload := strings.NewReader("{\n \"meter_id\": \"123\",\n \"billing_anchor\": \"2024-03-05T14:30:45Z\",\n \"customer_id\": \"customer456\",\n \"end_time\": \"2024-12-09T00:00:00Z\",\n \"external_customer_id\": \"user_5\",\n \"filters\": {},\n \"start_time\": \"2024-11-09T00: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/events/usage/meter")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"meter_id\": \"123\",\n \"billing_anchor\": \"2024-03-05T14:30:45Z\",\n \"customer_id\": \"customer456\",\n \"end_time\": \"2024-12-09T00:00:00Z\",\n \"external_customer_id\": \"user_5\",\n \"filters\": {},\n \"start_time\": \"2024-11-09T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/events/usage/meter")
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 \"meter_id\": \"123\",\n \"billing_anchor\": \"2024-03-05T14:30:45Z\",\n \"customer_id\": \"customer456\",\n \"end_time\": \"2024-12-09T00:00:00Z\",\n \"external_customer_id\": \"user_5\",\n \"filters\": {},\n \"start_time\": \"2024-11-09T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"event_name": "<string>",
"results": [
{
"value": 123,
"window_size": "<string>"
}
],
"type": "COUNT",
"value": 123
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Authorizations
Enter your API key in the format x-api-key <api-key>*
Body
application/json
Request body
Example:
"123"
BillingAnchor enables custom monthly billing periods for meter usage aggregation.
Usage guidelines:
- Only effective when WindowSize = "MONTH"
- For other window sizes (DAY, HOUR, WEEK), this field is ignored
- When nil, uses standard calendar months (1st to 1st)
- When provided, creates custom monthly periods (e.g., 5th to 5th)
Common use cases:
- Subscription billing periods that don't align with calendar months
- Customer-specific billing cycles (e.g., signed up on 15th)
- Multi-tenant systems with different billing anchor dates
Example: If BillingAnchor = "2024-03-05T14:30:45Z" and WindowSize = "MONTH":
- March period: 2024-03-05 14:30:45 to 2024-04-05 14:30:45
- April period: 2024-04-05 14:30:45 to 2024-05-05 14:30:45
Example:
"2024-03-05T14:30:45Z"
Available options:
MONTH, MINUTE, 15MIN, 30MIN, HOUR, 3HOUR, 6HOUR, 12HOUR, DAY, WEEK, MONTH Example:
"customer456"
Example:
"2024-12-09T00:00:00Z"
Example:
"user_5"
Show child attributes
Show child attributes
Example:
"2024-11-09T00:00:00Z"
Available options:
MONTH, MINUTE, 15MIN, 30MIN, HOUR, 3HOUR, 6HOUR, 12HOUR, DAY, WEEK, MONTH 
