Skip to navigation

write_metering

Ingest usage events. Create, update and delete meter config

Live server: test server (test.mcp.solvimon.com) only.

Ingests usage events and creates, updates and deletes meter configuration.

Actions: create, update, delete (meter config), ingest, batch_ingest (events)

Resource types: meters, meter_values, meter_value_calculations, meter_properties, meter_data, events

Send one event per discrete unit of activity. Do not pre-aggregate. Each event needs a unique reference (its idempotency key), meter_reference or meter_id, customer_id or customer_reference, and the measured amounts under meter_values[] as {reference, number} pairs. There is no flat value field.

Ingest a usage event
{
"action": "ingest",
"resource_type": "events",
"body": {
"reference": "evt-0001",
"meter_reference": "api-calls",
"customer_id": "cust_AbD3DqausjOYiMNDZY11F",
"meter_values": [{"reference": "api-calls-count", "number": "1"}]
}
}
  • A meter property is NUMBER, STRING or ENUM (with enum_values). Pass meter_id to attach it to a meter; on an ACTIVE meter it is created ACTIVE.
  • Updating a meter’s properties or values replaces its list. An update that would drop an existing entry is refused unless the body has "allow_detach": true.
  • On a calculation only name and description can change. Anything that defines what is measured needs a new calculation. The result lists the product items that use it.

Delete in dependency order: meter properties, then meter value calculations, then meter values, then meters. Product items that reference a meter must first be removed from active plan versions. The calculate action is deprecated; use get_metering calculate_cost.

Example prompts

  • “Add a region property (eu, us) to the API requests meter so we can price per region.”
  • “Send a test event: one API call for Acme Inc.”
  • “Upload these 500 usage events for our customers in one batch.”
  • “Rename the token calculation to ‘Tokens per month’.”
  • “Make the model property required on the tokens meter.”

Example output

Prompt: “Add a region property (eu, us) to the API requests meter so we can price per region.”

Tool call:

{
"action": "create",
"resource_type": "meter_properties",
"body": {
"reference": "docs-example-region",
"name": "Docs example region",
"type": "ENUM",
"enum_values": ["eu", "us"],
"meter_id": "metr_mwDpzo0vA1bBsSCc7r1i",
"required": false
}
}

Response (trimmed):

{
"meter_property": {
"id": "metp_mwDpzo0vA1bDLuCL7o1L",
"reference": "docs-example-region",
"status": "ACTIVE",
"type": "ENUM",
"enum_values": ["eu", "us"]
},
"attached_to_meter_id": "metr_mwDpzo0vA1bBsSCc7r1i",
"required": false
}

Claude’s answer: The region property is attached to the API requests meter and is ACTIVE, so you can use it in pricing conditions now. It is optional, so existing integrations that don’t send a region keep working; add a default config in the plan for events without one.