Skip to content
  • Auto
  • Light
  • Dark
Talk to an expert

List Costs

Get customer costs
v1.customers.list_costs(**kwargs) -> CursorPage<credit_typeshashend_timestampTimestart_timestampTimeCustomerListCostsResponse>
get/v1/customers/{customer_id}/costs

Fetch daily pending costs for the specified customer, broken down by credit type and line items. Note: this is not supported for customers whose plan includes a UNIQUE-type billable metric.

Parameters
customer_idString
formatuuid
ending_beforeTime

RFC 3339 timestamp (exclusive)

formatdate-time
starting_onTime

RFC 3339 timestamp (inclusive)

formatdate-time
limitInteger
optional

Max number of results that should be returned

minimum1
maximum100
next_pageString
optional

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

Returns
CustomerListCostsResponseclass
Hide ParametersShow Parameters
credit_typeshash
Hash[Symbol, { cost, line_item_breakdown, name}]
Hide ParametersShow Parameters
costFloat
optional
line_item_breakdownarray
optional
Array[{ cost, name, group_key, group_value}]
Hide ParametersShow Parameters
costFloat
nameString
group_keyString
optional
group_valueString
optional
nameString
optional
end_timestampTime
formatdate-time
start_timestampTime
formatdate-time
require "metronome_sdk"

metronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")

page = metronome.v1.customers.list_costs(
  customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
  ending_before: "2019-12-27T18:11:19.117Z",
  starting_on: "2019-12-27T18:11:19.117Z"
)

puts(page)
200 Example
{
  "data": [
    {
      "credit_types": {
        "foo": {
          "cost": 0,
          "line_item_breakdown": [
            {
              "cost": 0,
              "name": "name",
              "group_key": "group_key",
              "group_value": "group_value"
            }
          ],
          "name": "name"
        }
      },
      "end_timestamp": "2019-12-27T18:11:19.117Z",
      "start_timestamp": "2019-12-27T18:11:19.117Z"
    }
  ],
  "next_page": "next_page"
}