Why this matters: Subscriptions renew, payments fail, customers upgrade and credits run out, often while the customer isn’t in your app. One webhook and one object tell you everything that changed. See Customer state.
2026-10.
Forward webhooks to your machine
Use the Polar CLI to receive your sandbox organization’s webhooks on your local server:Terminal
POLAR_WEBHOOK_SECRET.
Handle customer.state_changed
Polar sends customer.state_changed whenever a customer’s subscriptions, benefits or details change. The payload is the full customer state, so you don’t need to fetch anything else.
validateEvent (validate_event in Python) throws if the signature is invalid, and the handler answers 403. Event types your SDK version doesn’t know yet get a 202, so Polar doesn’t retry them. Without an SDK, verify the signature with a Standard Webhooks library. See Webhook delivery for error handling and retries. If you use Next.js, Nuxt or Better Auth, an adapter gives you this handler in a few lines.
Guard usage with the customer state
Before running an expensive action, read the customer state by your user ID and check thebalance of the AI tokens meter in active_meters:
Verify it works
Withpolar webhook listen running, cancel Jane’s subscription immediately. From the CLI or API, its ID is in active_subscriptions of her customer state. The CLI logs a customer.state_changed delivery, and your handler records that Jane no longer has Pro.
- Dashboard
- CLI
- Prompt
- Open Sales → Subscriptions
- Open Jane’s Pro subscription
- In the actions menu, click Cancel Subscription
- Set Cancellation Date to Immediately
- Click Cancel Subscription
You’re done
You’ve built the full loop: usage flows into a meter, a plan bills and credits that usage, customers buy through checkout, and your application stays in sync.Next: Go live
Set up production, add a webhook endpoint and pass the account review.
Customer portal
Let customers change plans, update payment methods and download invoices.
Webhook events
Every event Polar sends, and when.
How Polar works
The concepts behind everything you just built.

