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

List Costs

Get customer costs
v1.customers.list_costs(CustomerListCostsParams**kwargs) -> SyncCursorPage[credit_typesDict[str, CreditTypes]end_timestampdatetimestart_timestampdatetimeCustomerListCostsResponse]
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_idstr
formatuuid
ending_beforeunion
Union[str, datetime]

RFC 3339 timestamp (exclusive)

formatdate-time
starting_onunion
Union[str, datetime]

RFC 3339 timestamp (inclusive)

formatdate-time
limitint
optional

Max number of results that should be returned

minimum1
maximum100
next_pagestr
optional

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

Returns
CustomerListCostsResponseclass
Hide ParametersShow Parameters
credit_typesDict[str, CreditTypes]
Dict[str, CreditTypes]
Hide ParametersShow Parameters
costfloat
optional
line_item_breakdownlist
optional
Hide ParametersShow Parameters
costfloat
namestr
group_keystr
optional
group_valuestr
optional
namestr
optional
end_timestampdatetime
formatdate-time
start_timestampdatetime
formatdate-time
from datetime import datetime
from metronome import Metronome

client = Metronome(
    bearer_token="My Bearer Token",
)
page = client.v1.customers.list_costs(
    customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
    ending_before=datetime.fromisoformat("2019-12-27T18:11:19.117"),
    starting_on=datetime.fromisoformat("2019-12-27T18:11:19.117"),
)
page = page.data[0]
print(page.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"
}