cURL
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",
"timezone": "<string>"
}
'from flexprice import Flexprice
from flexprice.utils import parse_datetime
with Flexprice(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.events.get_usage_by_meter(meter_id="123", billing_anchor=parse_datetime("2024-03-05T14:30:45Z"), customer_id="customer456", end_time=parse_datetime("2024-12-09T00:00:00Z"), external_customer_id="user_5", start_time=parse_datetime("2024-11-09T00:00:00Z"))
# Handle response
print(res)import { Flexprice } from "@flexprice/sdk";
const flexprice = new Flexprice({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await flexprice.events.getUsageByMeter({
billingAnchor: new Date("2024-03-05T14:30:45Z"),
customerId: "customer456",
endTime: new Date("2024-12-09T00:00:00Z"),
externalCustomerId: "user_5",
meterId: "123",
startTime: new Date("2024-11-09T00:00:00Z"),
});
console.log(result);
}
run();package main
import(
"context"
flexprice "github.com/flexprice/go-sdk/v2"
"github.com/flexprice/go-sdk/v2/types"
"github.com/flexprice/go-sdk/v2/models/types"
"log"
)
func main() {
ctx := context.Background()
s := flexprice.New(
flexprice.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Events.GetUsageByMeter(ctx, types.GetUsageByMeterRequest{
BillingAnchor: types.MustNewTimeFromString("2024-03-05T14:30:45Z"),
CustomerID: flexprice.Pointer("customer456"),
EndTime: types.MustNewTimeFromString("2024-12-09T00:00:00Z"),
ExternalCustomerID: flexprice.Pointer("user_5"),
MeterID: "123",
StartTime: types.MustNewTimeFromString("2024-11-09T00:00:00Z"),
})
if err != nil {
log.Fatal(err)
}
if res.GetUsageResponse != nil {
// handle response
}
}{
"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
cURL
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",
"timezone": "<string>"
}
'from flexprice import Flexprice
from flexprice.utils import parse_datetime
with Flexprice(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.events.get_usage_by_meter(meter_id="123", billing_anchor=parse_datetime("2024-03-05T14:30:45Z"), customer_id="customer456", end_time=parse_datetime("2024-12-09T00:00:00Z"), external_customer_id="user_5", start_time=parse_datetime("2024-11-09T00:00:00Z"))
# Handle response
print(res)import { Flexprice } from "@flexprice/sdk";
const flexprice = new Flexprice({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await flexprice.events.getUsageByMeter({
billingAnchor: new Date("2024-03-05T14:30:45Z"),
customerId: "customer456",
endTime: new Date("2024-12-09T00:00:00Z"),
externalCustomerId: "user_5",
meterId: "123",
startTime: new Date("2024-11-09T00:00:00Z"),
});
console.log(result);
}
run();package main
import(
"context"
flexprice "github.com/flexprice/go-sdk/v2"
"github.com/flexprice/go-sdk/v2/types"
"github.com/flexprice/go-sdk/v2/models/types"
"log"
)
func main() {
ctx := context.Background()
s := flexprice.New(
flexprice.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Events.GetUsageByMeter(ctx, types.GetUsageByMeterRequest{
BillingAnchor: types.MustNewTimeFromString("2024-03-05T14:30:45Z"),
CustomerID: flexprice.Pointer("customer456"),
EndTime: types.MustNewTimeFromString("2024-12-09T00:00:00Z"),
ExternalCustomerID: flexprice.Pointer("user_5"),
MeterID: "123",
StartTime: types.MustNewTimeFromString("2024-11-09T00:00:00Z"),
})
if err != nil {
log.Fatal(err)
}
if res.GetUsageResponse != nil {
// handle response
}
}{
"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:
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:
MINUTE, 15MIN, 30MIN, HOUR, 3HOUR, 6HOUR, 12HOUR, DAY, WEEK, MONTH 
