Skip to main content
POST
/
v1
/
usage
/
groups
Get usage data with paginated groupings
curl --request POST \
  --url https://api.metronome.com/v1/usage/groups \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "customer_id": "04ca7e72-4229-4a6e-ab11-9f7376fccbcb",
  "billable_metric_id": "222796fd-d29c-429e-89b2-549fabda4ed6",
  "starting_on": "2021-01-01T00:00:00Z",
  "ending_before": "2021-01-03T00:00:00Z",
  "window_size": "day",
  "group_by": {
    "key": "region",
    "values": [
      "US-East",
      "US-West",
      "EU-Central"
    ]
  }
}'
{
  "data": [
    {
      "starting_on": "2021-01-01T00:00:00Z",
      "ending_before": "2021-01-02T00:00:00Z",
      "group_key": null,
      "group_value": null,
      "value": 1234
    },
    {
      "starting_on": "2021-01-02T00:00:00Z",
      "ending_before": "2021-01-03T00:00:00Z",
      "group_key": "region",
      "group_value": "US-East",
      "value": 567
    }
  ],
  "next_page": null
}

Authorizations

Authorization
string
header
required

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

Query Parameters

limit
integer

Max number of results that should be returned

Required range: 1 <= x <= 100
next_page
string

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

Body

application/json

The usage query to run

customer_id
string<uuid>
required
billable_metric_id
string<uuid>
required
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>
ending_before
string<date-time>
group_by
object
current_period
boolean

If true, will return the usage for the current billing period. Will return an error if the customer is currently uncontracted or starting_on and ending_before are specified when this is true.

Response

200 - application/json

Success

data
object[]
required
next_page
string | null
required