POST
/
events
/
usage
/
meter
Get usage by meter
curl --request POST \
  --url https://api.cloud.flexprice.io/v1/events/usage/meter \
  --header 'Content-Type: */*' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "billing_anchor": "2024-03-05T14:30:45Z",
  "bucket_size": "MINUTE",
  "customer_id": "customer456",
  "end_time": "2024-12-09T00:00:00Z",
  "external_customer_id": "user_5",
  "filters": {},
  "meter_id": "123",
  "start_time": "2024-11-09T00:00:00Z",
  "window_size": "MINUTE"
}'
{
  "event_name": "<string>",
  "results": [
    {
      "value": 123,
      "window_size": "<string>"
    }
  ],
  "type": "COUNT",
  "value": 123
}

Authorizations

x-api-key
string
header
required

Enter your API key in the format x-api-key <api-key>*

Body

*/*

Request body

meter_id
string
required
Example:

"123"

billing_anchor
string

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"

bucket_size
enum<string>
Available options:
MINUTE,
15MIN,
30MIN,
HOUR,
3HOUR,
6HOUR,
12HOUR,
DAY,
WEEK,
MONTH
customer_id
string
Example:

"customer456"

end_time
string
Example:

"2024-12-09T00:00:00Z"

external_customer_id
string
Example:

"user_5"

filters
object
start_time
string
Example:

"2024-11-09T00:00:00Z"

window_size
enum<string>
Available options:
MINUTE,
15MIN,
30MIN,
HOUR,
3HOUR,
6HOUR,
12HOUR,
DAY,
WEEK,
MONTH

Response

OK

event_name
string
results
object[]
type
enum<string>
Available options:
COUNT,
SUM,
AVG,
COUNT_UNIQUE,
LATEST,
SUM_WITH_MULTIPLIER,
MAX
value
number