deltaTime is ingested to Macropay automatically.
Because Macropay is your Merchant of Record, those metered events flow straight into the meter → metered price pipeline. We invoice in the customer’s currency, remit any applicable sales tax or VAT on your behalf, and stay the seller of record on the statement — you just emit the duration.
What you’ll need
- A meter that aggregates an event named
execution-time(or whatever name you choose) into a metered price. - A
MACROPAY_ACCESS_TOKENavailable to your server. - The ingestion package installed.
Bring your own clock
Timing is only as good as the clock you read it from. Rather than lock you into one source, the strategy takes a now-resolver — a function returning the current time — so you can pick the precision your billing model requires:Meter an operation end-to-end
The strategy wraps your now-resolver and hands back astart() function. Calling start() opens a timer and returns a stop() function; calling stop() closes it and ingests the measured deltaTime.
Pass
customerId when you build the client so each event is attributed to the right customer. The X-Macropay-Customer-Id header is just one convenient place to read it from — use whatever your app already has (a session, a JWT claim, a path param).What gets ingested
Whenstop() fires, the strategy posts a single event. deltaTime is the elapsed value in whatever unit your now-resolver returns:
deltaTime across events and applies the metered price — so “0.05 per minute of agent runtime” is just a meter definition, not custom billing code.
Billing agents by runtime
Delta Time pairs naturally with agent billing. If you charge for an autonomous agent by how long it works, wrap the agent’s execution instart() / stop() and attribute the duration to the agent’s customer. The elapsed time becomes an activity signal you can meter directly, while value receipts certify the outcome — time saved or revenue generated — on top of raw runtime.
Related strategies
- Strategy introduction — when to reach for each one
- LLM Strategy — meter prompt and completion tokens
- Stream Strategy — meter bytes through a stream
- S3 Strategy — meter file uploads