- A customer consumed AI LLM tokens
- A customer streamed minutes of video
- A customer uploaded a file to your application
- A
name, which is a string that can be used to identify the type of event. For example,ai_usage,video_streamedorfile_uploaded. - A
customer_idorexternal_customer_id, which is Macropay’s customer ID or your user’s ID. This is used to identify the customer that triggered the event. - A
metadataobject, which is a JSON object that can contain any additional information about the event. This is useful for storing information that can be used to filter the events or compute the actual usage. For example, you can store the duration of the video streamed or the size of the file uploaded.
From event to invoice
Ingestion is the first hop in the usage-based pipeline. Once an event lands, a meter aggregates it, a metered price turns the aggregate into an amount, and Macropay bills the customer — handling sales tax and VAT as the merchant of record, so you never touch a tax return. Your only job is to emit clean events. A few rules shape how you should design that emission:Ingestion never blocks. Every event you send is accepted and recorded, even when a customer is over their plan limit or out of credits. Enforcing balance — pausing an agent, rate-limiting a request, downgrading quality — is your application’s responsibility, not the meter’s.
Send events with the SDK
The fastest path is one of our official SDKs (TypeScript, Python, PHP, Go). Pass an array — batching cuts round trips and is the recommended pattern for high-volume sources.metadata object is free-form JSON. Store whatever you may want to meter or filter on later — a model name, byte count, region, or the agent that produced the work — because you can’t add it after the fact.
Built for AI and agent billing
Usage events are how you charge for AI in any shape:- By usage — token counts, generated images, transcription minutes.
- By activity — calls made, documents processed, rows enriched.
- By outcome — tickets resolved, leads qualified, revenue attributed.
POST /ai/v1/chat/completions) and Macropay captures token cost as cost events automatically — no manual ingestion required. For autonomous agents, the Signals API (POST /v1/signals) ingests activity and outcome signals attributed to a specific agent, so you can bill on results and read your agentic margin (billed revenue versus AI cost) per agent.
Pick an ingestion strategy
Calling the SDK directly is ideal for discrete, in-app actions. When events live elsewhere — a Kafka stream, an S3 export, or a meter that depends on elapsed time — a managed strategy does the plumbing for you.
See ingestion strategies for setup details on each.