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

List Costs

Get customer costs
client.v1.customers.listCosts(CustomerListCostsParamsparams, RequestOptionsoptions?): CursorPage<credit_typesRecord<string, CreditTypes>end_timestampstringstart_timestampstringCustomerListCostsResponse>
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
paramscustomer_idstringending_beforestringstarting_onstringlimitnumbernext_pagestringCustomerListCostsParams
Hide ParametersShow Parameters
customer_idstring

Path param:

formatuuid
ending_beforestring

Query param: RFC 3339 timestamp (exclusive)

formatdate-time
starting_onstring

Query param: RFC 3339 timestamp (inclusive)

formatdate-time
limitnumber
optional

Query param: Max number of results that should be returned

minimum1
maximum100
next_pagestring
optional

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

Returns
CustomerListCostsResponse
Hide ParametersShow Parameters
credit_typesRecord<string, CreditTypes>
Hide ParametersShow Parameters
costnumber
optional
line_item_breakdownarray
optional
Hide ParametersShow Parameters
costnumber
namestring
group_keystring
optional
group_valueunion
optional
string | null
namestring
optional
end_timestampstring
formatdate-time
start_timestampstring
formatdate-time
import Metronome from '@metronome/sdk';

const client = new Metronome({
  bearerToken: 'My Bearer Token',
});

// Automatically fetches more pages as needed.
for await (const customerListCostsResponse of client.v1.customers.listCosts({
  customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
  ending_before: '2019-12-27T18:11:19.117Z',
  starting_on: '2019-12-27T18:11:19.117Z',
})) {
  console.log(customerListCostsResponse.credit_types);
}
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"
}