Skip to main content
POST
/
v1
/
usage
Get batched usage data
curl --request POST \
  --url https://api.metronome.com/v1/usage \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "window_size": "day",
  "starting_on": "2021-01-01T00:00:00Z",
  "ending_before": "2021-01-03T00:00:00Z"
}'
{
  "data": [
    {
      "customer_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
      "billable_metric_id": "9570e4f3-d1da-4b95-ba81-bd40ee002727",
      "billable_metric_name": "CPU hours",
      "start_timestamp": "2021-01-01T00:00:00Z",
      "end_timestamp": "2021-01-02T00:00:00Z",
      "value": 1234
    },
    {
      "customer_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
      "billable_metric_id": "9570e4f3-d1da-4b95-ba81-bd40ee002727",
      "billable_metric_name": "CPU hours",
      "start_timestamp": "2021-01-02T00:00:00Z",
      "end_timestamp": "2021-01-03T00:00:00Z",
      "value": 1234
    }
  ],
  "next_page": null
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

next_page
string

Cursor that indicates where the next page of results should start.

Body

application/json

The usage query to run

window_size
enum<string>
required

A window_size of "day" or "hour" will return the usage for the specified period segmented into daily or hourly aggregates. A window_size of "none" will return a single usage aggregate for the entirety of the specified period.

Available options:
hour,
day,
none,
HOUR,
DAY,
NONE,
Hour,
Day,
None
starting_on
string<date-time>
required
ending_before
string<date-time>
required
customer_ids
string<uuid>[]

A list of Metronome customer IDs to fetch usage for. If absent, usage for all customers will be returned.

billable_metrics
object[]

A list of billable metrics to fetch usage for. If absent, all billable metrics will be returned.

Response

200 - application/json

Success

data
object[]
required
next_page
string | null
required