Skip to main content
Why start here? Events are the raw record of what customers do. Send them early and you’ll have real usage data, whether you charge for it or not. See Usage.
In this step you’ll send events for an AI feature and create a meter that sums the tokens each customer uses. The examples use the sandbox client from the quickstart overview, on API version 2026-10.

Send your first event

Send an event whenever a customer does something you want to measure, whether you’ll bill for it, limit it or just track it. Identify the customer with your own user ID as external_customer_id (see External IDs):
You don’t need to create the customer first. Polar accepts the event now, and links it to the customer once one exists with external_id set to user_123. You’ll do that in step 3.
Send raw facts, like the tokens used by one request, not running totals. Polar does the aggregation, so the same events can feed several meters later.
For LLM calls, streams and S3 uploads, an ingestion strategy can send these events for you.

Create a meter

A meter selects events with a filter and aggregates them into usage. Create one that sums total_tokens across ai_usage events:
  • Open Products → Meters
  • Click Create Meter
  • Set Name to “AI tokens”
  • Under Filters, add a condition: Name equals ai_usage
  • Set Aggregation to Sum over the property total_tokens
  • Click Create Meter
From your code:
Metadata keys are used directly as properties, without a metadata. prefix. Polar backfills a new meter from events you’ve already sent, so your first event counts. Keep the meter’s id. You’ll use it in the next step. The CLI and cURL examples save it as METER_ID.

Verify it works

Read the meter’s usage for user_123. It includes the 77 tokens from your event.
  • Open Products → Meters
  • Select AI tokens
  • Open the Customers tab to see usage per customer, or Events to see the event you sent

Learn more

Next: Set up your catalog

Turn this meter into a price, and include credits in a plan.