Skip to main content
Charge customers based on how much they use your API. This recipe shows how to track usage with Unkey’s credits system and integrate with billing providers like Stripe.

The pattern

Full implementation

Setting up usage tracking

API route with usage tracking

Stripe integration for overages

Usage dashboard endpoint

Plan upgrades

When a customer upgrades, update their key:

Multi-resource tracking

Track different types of usage separately:

Best practices

Use refill wisely

Monthly refills keep usage tracking simple. For different billing cycles, adjust the interval.

Handle overages gracefully

Don’t just cut users off. Offer overage billing or soft limits with warnings.

Show usage prominently

Let users see their usage in your dashboard. Nobody likes surprise bills.

Sync with your billing provider

Use webhooks to keep Stripe/Paddle usage records in sync with Unkey.

Next steps

Tiered subscriptions

Complete Free/Pro/Enterprise implementation

Credits & refill

Deep dive into Unkey’s credit system
Last modified on May 6, 2026