2026-10.
Sending events is API only. It isn’t available from the dashboard, CLI or MCP server. Use the SDK or the Ingest Events API.
Send an event
Each event has aname, the customer it belongs to, and metadata with the numbers and labels you want to measure. With the SDK, call track():
track() doesn’t wait for Polar. It adds the event to a queue and returns, and the SDK sends it in the background. flush() waits until queued events are sent. In Python, leaving the async with block does the same. See Send events in batches.
To check it arrived, open Analytics → Events in the dashboard.
Send one event per thing that happened, like the tokens used by one request, not running totals. Meters do the counting, so the same events can feed several of them: one that sums total_tokens, another that counts requests per model.
In Python,
track() is only on PolarAsync. With the synchronous Polar client, call polar.events.ingest(events=[...]) instead.Identify the customer
Every event needs exactly one ofexternal_customer_id, your own user ID, or customer_id, Polar’s customer ID. Most integrations use external_customer_id.
You don’t need to create the customer first. Polar stores an event for an external_customer_id that has no customer yet. Once a customer with that external_id exists, the event is linked to that customer.
When the customer is a team, you can attribute the usage to one of its members with external_member_id (alongside external_customer_id) or member_id (alongside customer_id). The usage still counts toward the team’s meters. See Customers.
Avoid duplicates
Setexternal_id to an idempotency key: an ID that stays the same every time you send the same usage, like the ID of the request or job that produced it. If Polar already has an event with that external_id, it skips the new one and counts it in duplicates. An external_id is unique per organization.
This makes retries safe: if a request times out, send the same events again. Set it on every event, because events are immutable. Once ingested, an event can’t be changed or deleted, so a duplicate can only be offset by granting credits.
track() generates an external_id when you leave it out. That covers the SDK’s own retries, but not your code tracking the same thing twice, so prefer an ID from your application.
Send events in batches
Withtrack(), the SDK collects events in a queue and sends them to Polar in batches in the background. Your own requests don’t wait on Polar, and you don’t need to build a queue yourself.
Send queued events before your process stops
Queued events wait in memory until their batch goes out, so make sure the SDK sends them before your process stops:- On a server, create one client when your application starts and share it between requests. On shutdown, call
await polar.close()in TypeScript. In Python, keep oneasync with PolarAsync(...)block open for the application’s lifetime. - In a serverless function, call
await polar.flush()before you return. The function can freeze as soon as it returns, with events still in the queue.
flush() and close() throw a MeteringDeliveryError that lists them.
Keep events through a crash
By default, the queue lives in your process’s memory, so events still in it are lost if the process is killed. To keep them, store the queue in Redis instead:Without the SDK
Send a list of events to the Ingest Events API. Each call is one HTTP request, so in a busy request path collect events and send them together:{ "inserted": 2, "duplicates": 0 }. If a request fails, retry it with the same events. Polar skips the ones it already stored, thanks to their external_id.
If any event in a request is invalid, Polar rejects the whole request with a 422 and stores none of them. Validate events against the event fields before you send them.
Event fields
metadata holds everything a meter might filter or sum on:
- Values are a string (1 to 500 characters), a number or a boolean. Numbers must be within ±2^53−1.
- No nested objects, except two keys Polar reads specially:
_costfor what the event cost you, and_llmfor LLM token usage. See Cost insights.
Timestamps and billing periods
You can settimestamp to any point in the past, for example when you replay events from your own queue. It doesn’t need to fall in the current billing cycle.
Polar attributes events to billing periods by when Polar received them, not by timestamp. An event ingested today with a timestamp from a closed period is billed on the current cycle. Polar never reissues a closed invoice or credits it for late events.
The timestamp places the event on the time series in the dashboard and the Customer Portal, and sets the date range shown on the metered line item of the next invoice.
Group events with a parent
Setparent_id to the Polar ID or external_id of another event to make it a child, for example one event per LLM call under one event for the agent run. The parent can arrive in a later request. Until it does, the child is held back and isn’t processed. See Cost insights for how traces roll up costs.
View events
Analytics → Events lists every event, with filters for time range, event name, source (user for events you send, system for events Polar writes), cost and LLM events. On a customer’s page, the Events tab shows that customer’s events.
To give an event name a readable label in the dashboard, set it on its event type:
- Dashboard
- CLI
- Prompt
- Open Analytics → Costs
- Select the event type under Breakdown
- Click Edit and set the label

