Skip to content
Join our SlackContact 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:
DataUnionMember0 = str
DataUnionMember1 = 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
from datetime import datetime
from lark import Lark

client = Lark(
    api_key="My API Key",
)
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="168fbd3a-4d39-4db3-a204-15e014857d10",
    subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
    timestamp=datetime.fromisoformat("2025-12-03T22:13:28.294419+00:00"),
)
print(usage_event)
{}
Returns Examples
{}