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

List Costs

Get customer costs
client.V1.Customers.ListCosts(ctx, params) (*CursorPage[CreditTypesmapEndTimestampTimeStartTimestampTimeV1CustomerListCostsResponse], error)
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
paramsCustomerIDfieldEndingBeforefieldStartingOnfieldLimitfieldNextPagefieldV1CustomerListCostsParams
Hide ParametersShow Parameters
CustomerIDfield
param.Field[string]

Path param:

formatuuid
EndingBeforefield
param.Field[Time]

Query param: RFC 3339 timestamp (exclusive)

formatdate-time
StartingOnfield
param.Field[Time]

Query param: RFC 3339 timestamp (inclusive)

formatdate-time
Limitfield
optional
param.Field[int64]

Query param: Max number of results that should be returned

minimum1
maximum100
NextPagefield
optional
param.Field[string]

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

Returns
V1CustomerListCostsResponsestruct
Hide ParametersShow Parameters
CreditTypesmap
Hide ParametersShow Parameters
Costfloat64
optional
Hide ParametersShow Parameters
Costfloat64
Namestring
GroupKeystring
optional
GroupValuestring
optional
Namestring
optional
EndTimestampTime
formatdate-time
StartTimestampTime
formatdate-time
package main

import (
  "context"
  "fmt"
  "time"

  "github.com/Metronome-Industries/metronome-go"
  "github.com/Metronome-Industries/metronome-go/option"
)

func main() {
  client := metronome.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  page, err := client.V1.Customers.ListCosts(context.TODO(), metronome.V1CustomerListCostsParams{
    CustomerID: metronome.F("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),
    EndingBefore: metronome.F(time.Now()),
    StartingOn: metronome.F(time.Now()),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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"
}