Skip to content
Book a demoContact usGet started

Create Pricing Metric Summary

client.pricingMetrics.createSummary(stringpricingMetricID, PricingMetricCreateSummaryParams { period, subject_id, dimensions, period_granularity } body, RequestOptionsoptions?): PricingMetricCreateSummaryResponse { id, dimension_coordinates, period, 3 more }
post/pricing-metrics/{pricing_metric_id}/summary

Create Pricing Metric Summary

ParametersExpand Collapse
pricingMetricID: string
body: PricingMetricCreateSummaryParams { period, subject_id, dimensions, period_granularity }
period: Period { end, start, inclusive_end, inclusive_start }

The period that the summary should be computed over.

end: string
formatdate-time
start: string
formatdate-time
inclusive_end?: boolean
inclusive_start?: boolean
subject_id: string

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

dimensions?: Array<string> | null

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

period_granularity?: "hour" | "day" | "week" | null

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

Accepts one of the following:
"hour"
"day"
"week"
ReturnsExpand Collapse
PricingMetricCreateSummaryResponse = Array<PricingMetricCreateSummaryResponseItem>
id: string

The ID of the pricing metric summary.

dimension_coordinates: Record<string, string> | null

The dimension coordinates that the summary is for.

period: Period { end, start, inclusive_end, inclusive_start }

The period that the summary is computed over.

end: string
formatdate-time
start: string
formatdate-time
inclusive_end?: boolean
inclusive_start?: boolean
pricing_metric_id: string

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

subject_id: string

The ID of the subject that the summary is for.

value: string | null

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
import Lark from 'lark-billing';

const client = new Lark({
  apiKey: process.env['LARK_API_KEY'], // This is the default and can be omitted
});

const response = await client.pricingMetrics.createSummary('pmtr_GlX5Tcm2HOn00CoRTFxw2Amw', {
  period: { start: '2025-10-01T00:00:00Z', end: '2025-11-01T00:00:00Z' },
  subject_id: 'subj_VyX6Q96h5avMho8O7QWlKeXE',
});

console.log(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"
  }
]