Of all the choices in a billing implementation, the schema made on day one is the hardest to undo. A new field means a migration. Dropping one means tracing every consumer downstream. Redefining an existing field—deciding that quantity now means "weighted units" rather than "raw call count"—means recomputing historical aggregates or accepting that events before and after the change are measured on different scales. In practice the early schema locks in faster than engineers expect, since billing retention rules keep you on the original design for years.

What follows are the fields that look optional at launch, start appearing in support tickets within six months, and are miserable to backfill. Put them in the schema before production traffic arrives.

The Baseline Every Schema Carries

A core set shows up in every billing event schema, because an event missing any of them cannot be billed at all:

  • event_id or idempotency_key: a value that marks this specific occurrence as distinct
  • customer_id: the account the event belongs to
  • event_type: the kind of operation, used for pricing rule matching
  • quantity: how much of the event type occurred (normally 1 for discrete events, a count for batched ones)
  • timestamp: when it happened, which decides the billing period

These are present because billing cannot run without them. The trickier set is the fields the system can technically run without—but that turn out to matter for correct operation, customer trust, and resolving disputes.

Metadata Is Where Verification Lives

A freeform metadata object, or named fields inside a metadata block, is how context survives on every billing event. It is the difference between a count and a record someone can check. Without it, events answer how many and stop there.

For AI products the metadata that earns its place is the model identifier, input and output token counts, a prompt or input hash (not the content, just enough to identify the call), and any version or variant tag for the AI feature responsible. When a customer asks why their token usage climbed this month, the answer has to be specific. "Your upgrade from GPT-4 Turbo to GPT-4o raised average input tokens by roughly 18 percent over the period" can be checked. "We recorded more usage this month" cannot.

Treat metadata as part of an append-only audit log, not a general-purpose property bag. Decide the fields for version one, keep them stable, and add new ones alongside the old rather than replacing them.

Attribution Needs workflow_id and trace_id

As the multi-agent attribution article covers, workflow_id and trace_id are what let you rebuild which pipeline execution produced which events. Launching with a single-agent product, both read as debugging conveniences. The first workflow with sub-agents makes them mandatory, because nothing else lets you split a customer's bill by the features or workflows they used.

Adding them later costs more than a migration. Every event recorded before the change lacks workflow attribution, so historical data has coarser granularity than data after it. Add multi-agent features in month four and workflow attribution in month six, and two months of events cannot be analyzed by workflow at all. Customer reporting requirements may force you to disclose that gap.

Include both fields in the first schema with optional values. Where the scenario is single-agent, send null or an empty string. Multi-agent workflows can populate them later. The queries that use the fields can grow incrementally; the fields themselves have to exist from the start, or the retroactive gap is permanent.

Two Timestamps, Not One

Distributed systems deliver events out of order. Something that happened at 11:58 PM can reach the metering endpoint at 12:02 AM. Use arrival time as the timestamp and a midnight billing close puts the event in the wrong period. Use the client's reported time and you inherit whatever its clock says, which may be wrong.

The workable arrangement uses both. occurred_at is when the client says the event happened. ingested_at is when the server received it. Period assignment follows occurred_at with a grace window: an event arriving within N minutes of close whose occurred_at falls in the prior period counts toward that period. Anything later lands in the arrival period.

The grace window is only implementable if both timestamps are stored. Keep only ingested_at and the window cannot be added retroactively, because the actual occurrence time is gone. Record both from day one, even if the first boundary logic is simpler than this.

An environment Field Keeps Test Traffic Out

Every AI application emits billing events in development and staging, not just production. Without an environment field, separating test events from real billing means either separate API keys—added operational complexity—or post-hoc guessing from other fields, which is brittle.

A small enum with production, staging, and development lets the billing layer drop non-production events at ingest, keep them for debugging, and leave them out of the ledger with no extra machinery. Skip the field and the filter has to go through API keys or a pattern in customer_id that marks test accounts. Those work, but only as long as every person writing events follows the convention. An explicit field needs no convention.

event_version Records the Shape

Event types get added and pricing evolves, so the schema will change. An event_version field records which version produced a given event. Historical events can then be processed through the code path that matches how they were generated.

Without it, schema version has to be inferred from which fields are present, and that inference breaks as schemas evolve. The field costs almost nothing up front and spares you the debugging session spent working out why events from six months ago fail to parse under the current schema.

The Whole Event, Assembled

A model completion event under a schema that includes all of the above:

{
  "idempotency_key": "evt_wf_3301_step_2_c001",
  "customer_id":    "cust_northshore_ai",
  "event_type":     "model.completion",
  "event_version":  "v2",
  "environment":    "production",
  "quantity":       1,
  "occurred_at":    "2026-03-22T14:23:11.042Z",
  "workflow_id":    "wf_invoice_extract_20260322",
  "trace_id":       "trc_3301",
  "agent_id":       "agt_extraction_01",
  "parent_agent_id": null,
  "metadata": {
    "model":         "claude-3-5-sonnet",
    "input_tokens":  2100,
    "output_tokens": 340,
    "feature":       "invoice_extraction"
  }
}

Not a large payload: under 400 bytes of billing overhead per event. The fields that look redundant while building a single-agent MVP are the ones that make the system verifiable, attributable, and hard to dispute once real customers are reviewing real bills at production scale.

Get the full event schema reference

The docs carry a fully annotated schema with guidance on every field. Our emails cover billing engineering; they go out about monthly.