Skip to content
Book a demoContact usGet started

Create Usage Event

usage_events.create(UsageEventCreateParams**kwargs) -> object
post/usage-events

Create Usage Event

ParametersExpand Collapse
data: Dict[str, Union[str, int]]

The data of the usage event. This should contain any data that is needed to aggregate the usage event.

Accepts one of the following:
str
int
event_name: str

The name of the event. This is used by pricing metrics to aggregate usage events.

idempotency_key: str

The idempotency key for the usage event. This ensures that the same event is not processed multiple times.

subject_id: str

The ID or external ID of the subject that the usage event is for.

timestamp: Optional[Union[str, datetime, null]]

The timestamp of the usage event. It is highly recommended to provide a timestamp. If not provided, the current timestamp will be used.

formatdate-time
ReturnsExpand Collapse
object
Create Usage Event
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
)
usage_event = client.usage_events.create(
    data={
        "compute_hours": "100.5",
        "instance_type": "t2.micro",
        "region": "us-east-1",
    },
    event_name="job_completed",
    idempotency_key="1c3da957-f772-45ef-9bae-4c6b19b7f93f",
    subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
    timestamp=datetime.fromisoformat("2026-01-19T20:11:18.030407+00:00"),
)
print(usage_event)
{}
Returns Examples
{}