This guide walks you through going from an unmonetized API to a fully metered, quota-enforced, Stripe-billed API with a self-serve Developer Portal. By the end, your customers will be able to browse plans, subscribe via Stripe Checkout, get API keys scoped to their plan, and hit real quota limits.
Prerequisites
- A Zuplo account with an existing API project (routes configured and working)
- A Stripe account (test mode is fine for setup)
- The Developer Portal enabled on your project (uses Auth0 or custom auth)
Step 1: Create a meter
Meters define what you're counting. Start with the most common meter: request counting.
Navigate to Settings → Monetization → Meters in the Zuplo Portal, or use the API:
Code
Key fields:
| Field | Description |
|---|---|
slug | Unique identifier used in policy configuration and API calls |
eventType | The type of event this meter watches for |
aggregation | COUNT (count each event) or SUM (sum a numeric value from the event payload) |
valueProperty | JSONPath to the numeric value when using SUM (e.g., $.tokens for AI token metering) |
Finding your
bucketId: Go to Settings → Project Information in the Zuplo Portal. ThebucketIdis listed under your project details.
Step 2: Create a feature
Features connect meters to your product catalog. Create a metered feature for your API requests meter:
Code
You can also create static features (boolean on/off toggles) that don't link to a meter:
Code
Step 3: Create a plan
Plans define your pricing tiers. Here's a typical two-tier setup with a free tier and a paid Pro tier:
Free plan
Code
This gives free-tier users 1,000 API calls per month with a hard limit — once
they hit 1,000, they get 403 Forbidden until the next billing period.
Pro plan
Code
This creates a Pro plan at $99/month with 50,000 API calls included. The soft limit means customers can exceed 50,000 requests — they are billed $0.50 per additional request as overage. Pro users also get the Priority Support static feature.
Publish the plans
Plans are created in draft status. Publish them to make them available:
Code
Step 4: Connect Stripe
- Go to your Stripe Dashboard and make sure you're in sandbox mode
- Go to Developers > API keys and copy your Secret key (starts with
sk_test_) - In the Zuplo Portal, navigate to Services → Monetization Service → Payment Provider
- Click Configure on the Stripe card
- Enter a Name and paste your Stripe API Key, then click Save
- When you publish plans, Stripe Products and Prices are created automatically
When a customer subscribes through your Developer Portal, Zuplo:
- Creates a Stripe Customer (or links to an existing one)
- Creates a Stripe Subscription matching the plan
- Generates an API key scoped to the subscription's entitlements
- Keeps subscription and payment state synchronized automatically
Step 5: Add the Monetization policy to your routes
The MonetizationInboundPolicy handles authentication, subscription validation,
quota enforcement, and metering. Add it to every route you want to meter and
protect.
In your routes.oas.json, add the policy to the route's x-zuplo-route
configuration:
Code
Then define the policy in policies.json:
Code
The MonetizationInboundPolicy handles API key authentication internally. You
do not need a separate api-key-auth policy on monetized routes — the
monetization policy replaces it.
Step 6: Configure the Developer Portal
The Developer Portal provides the self-serve experience for your customers: browsing plans, subscribing, managing API keys, and viewing usage.
Add the monetization plugin to your Developer Portal. Open
docs/zudoku.config.tsx in your project and add:
Code
Save and deploy. Your Developer Portal now shows:
- A Pricing page displaying your published plans with feature comparisons
- A Subscribe button that launches Stripe Checkout
- A Subscriptions page where customers see their active plans, usage, and API keys
- A Usage dashboard showing quota consumption for the current billing period
Step 7: Test the flow
- Open your Developer Portal in a browser
- Sign up or log in as a test customer
- Navigate to the Pricing page and subscribe to the Free plan
- Copy the generated API key from the Subscriptions page
- Make API requests using the key:
Code
- Upgrade to the Pro plan via the Developer Portal to verify the plan change flows through Stripe and updates the customer's quota in real time.
Next steps
- Meters, Features, Plans, Rate Cards — Understand the core monetization primitives in depth
- Billing Models Guide — Choose the right pricing strategy for your API
- Monetization Policy Reference — Advanced policy configuration (multi-meter, selective metering, dynamic metering)
- Subscription Lifecycle — Manage trials, upgrades, downgrades, and cancellations