What you’ll build
- Usage events flowing from your application into a meter
- A subscription product with a base fee, metered usage and included credits
- A checkout that links each purchase to the user in your application
- A webhook handler that keeps your application in sync with each customer’s access
Prerequisites
- A sandbox organization. Sign up at sandbox.polar.sh. The sandbox is fully isolated from production, so nothing here moves real money.
- An organization access token from the sandbox, created under Settings → Access Tokens. See Organization access tokens.
- The TypeScript SDK, the Python SDK or any HTTP client. Every example has a tab for each.
Use your own user IDs. Every Polar customer can carry an
external_id, set to the user’s ID in your application. The quickstart uses user_123 this way throughout, so you never store Polar’s customer IDs or map them back to your users. See External IDs.The path
1
Track usage
Send events from your application and aggregate them with a meter. Start here, even before you’ve decided on pricing.
Track usage →
2
Set up your catalog
Create a product that bills a base fee and metered usage, and includes credits.
Set up your catalog →
3
Integrate checkout & customers
Link Polar customers to your users and send them to checkout.
Integrate checkout →
4
Sync customer state
Listen to webhooks and read the customer state to grant access in your application.
Sync customer state →
Why usage comes first
Events are raw facts about what customers do in your product. Polar stores every event and computes usage from them when you ask, so:- You can start sending events before you’ve settled on pricing, and decide later what to charge for, if anything.
- Events sent with your own user ID are linked to the customer as soon as a customer with that external ID exists, even if the events came first.
- New meters work on events you’ve already sent, so you see real usage the moment you create them.
Manage your Pricing as Code Beta
Every step that creates part of your catalog has a Pricing as Code tab. We recommend it: your meters, benefits and products live in a billing config in your repository, change through a pull request and ship as a new catalog version, while existing customers keep the version they bought. See Pricing as Code. With Pricing as Code, your code refers to products, benefits and meters by external ID, such aspro or ai_tokens, and never by Polar ID, which changes when you publish a new version. Looking them up by external ID needs API version 2027-01, so the checkout and customer state steps show a 2027-01 example for it.
Read Before you adopt first. The config becomes the only way to change your catalog, it can’t be turned off once a publish has replaced your live catalog, and some benefit types and prices aren’t supported yet.
Start with usage
Send your first event and create a meter.

