Skip to content
Book a demoContact usGet started

Create Pricing Metric Summary

pricing_metrics.create_summary(strpricing_metric_id, PricingMetricCreateSummaryParams**kwargs) -> PricingMetricCreateSummaryResponse
post/pricing-metrics/{pricing_metric_id}/summary

Create Pricing Metric Summary

ParametersExpand Collapse
pricing_metric_id: str
period: PeriodParam

The period that the summary should be computed over.

end: datetime
formatdate-time
start: datetime
formatdate-time
inclusive_end: Optional[bool]
inclusive_start: Optional[bool]
subject_id: str

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

dimensions: Optional[SequenceNotStr[str]]

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

period_granularity: Optional[Literal["hour", "day", "week"]]

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

Accepts one of the following:
"hour"
"day"
"week"
ReturnsExpand Collapse
List[PricingMetricCreateSummaryResponseItem]
id: str

The ID of the pricing metric summary.

dimension_coordinates: Optional[Dict[str, str]]

The dimension coordinates that the summary is for.

period: Period

The period that the summary is computed over.

end: datetime
formatdate-time
start: datetime
formatdate-time
inclusive_end: Optional[bool]
inclusive_start: Optional[bool]
pricing_metric_id: str

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

subject_id: str

The ID of the subject that the summary is for.

value: Optional[str]

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 os
from datetime import datetime
from lark import Lark

client = Lark(
    api_key=os.environ.get("LARK_API_KEY"),  # This is the default and can be omitted
)
response = client.pricing_metrics.create_summary(
    pricing_metric_id="pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
    period={
        "start": datetime.fromisoformat("2025-10-01T00:00:00"),
        "end": datetime.fromisoformat("2025-11-01T00:00:00"),
    },
    subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
)
print(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"
  }
]