Skip to content
Book a demoContact usGet started

Create Pricing Metric Summary

client.PricingMetrics.NewSummary(ctx, pricingMetricID, body) (*[]PricingMetricNewSummaryResponse, error)
post/pricing-metrics/{pricing_metric_id}/summary

Create Pricing Metric Summary

ParametersExpand Collapse
pricingMetricID string
body PricingMetricNewSummaryParams
Period param.Field[Period]

The period that the summary should be computed over.

SubjectID param.Field[string]

The ID or external ID of the subject that the summary should be computed for.

Dimensions param.Field[[]string]optional

The dimensions by which the events are grouped to compute the pricing metric.

PeriodGranularity param.Field[PricingMetricNewSummaryParamsPeriodGranularity]optional

The granularity of the period that the summary should be computed over.

const PricingMetricNewSummaryParamsPeriodGranularityHour PricingMetricNewSummaryParamsPeriodGranularity = "hour"
const PricingMetricNewSummaryParamsPeriodGranularityDay PricingMetricNewSummaryParamsPeriodGranularity = "day"
const PricingMetricNewSummaryParamsPeriodGranularityWeek PricingMetricNewSummaryParamsPeriodGranularity = "week"
ReturnsExpand Collapse
type PricingMetricNewSummaryResponse []PricingMetricNewSummaryResponse
ID string

The ID of the pricing metric summary.

DimensionCoordinates map[string, string]

The dimension coordinates that the summary is for.

Period Period

The period that the summary is computed over.

End Time
formatdate-time
Start Time
formatdate-time
InclusiveEnd booloptional
InclusiveStart booloptional
PricingMetricID string

The ID of the pricing metric that the summary is for.

SubjectID string

The ID of the subject that the summary is for.

Value string

The computed value of the pricing metric for the period. If the pricing metric does not have any usage events for the period, this will be null.

Create Pricing Metric Summary
package main

import (
  "context"
  "fmt"
  "time"

  "github.com/stainless-sdks/lark-go"
  "github.com/stainless-sdks/lark-go/option"
)

func main() {
  client := lark.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.PricingMetrics.NewSummary(
    context.TODO(),
    "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
    lark.PricingMetricNewSummaryParams{
      Period: lark.PeriodParam{
        Start: time.Now(),
        End: time.Now(),
      },
      SubjectID: "subj_VyX6Q96h5avMho8O7QWlKeXE",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
[
  {
    "id": "pmtr_sum_vqXWIKBYia15D5dNyCLLlsa4",
    "dimension_coordinates": {
      "foo": "string"
    },
    "period": {
      "end": "2025-11-01T00:00:00Z",
      "start": "2025-10-01T00:00:00Z",
      "inclusive_end": false,
      "inclusive_start": true
    },
    "pricing_metric_id": "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
    "subject_id": "subj_VyX6Q96h5avMho8O7QWlKeXE",
    "value": "22.5"
  }
]
Returns Examples
[
  {
    "id": "pmtr_sum_vqXWIKBYia15D5dNyCLLlsa4",
    "dimension_coordinates": {
      "foo": "string"
    },
    "period": {
      "end": "2025-11-01T00:00:00Z",
      "start": "2025-10-01T00:00:00Z",
      "inclusive_end": false,
      "inclusive_start": true
    },
    "pricing_metric_id": "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
    "subject_id": "subj_VyX6Q96h5avMho8O7QWlKeXE",
    "value": "22.5"
  }
]