Subscriptions
Assign plans to users, gate features by tier, and manage trials — all through custom claims on the access token. No separate billing database needed.
How it works
Subscriptions are powered by custom claims — key-value pairs attached to each end user. Set a plan claim, and it shows up in every access token your app verifies.
Set claims via API or dashboard
Claims appear in the JWT automatically
Check claims in your app to unlock features
Assign a plan via dashboard
The easiest way: go to your project's user list in the dashboard, click a user, and set their claims directly.
Assign a plan from your backend
Use the server-to-server claims API to set plans programmatically — for example, after a Stripe webhook confirms payment.
// After Stripe confirms payment, update the user's plan
await fetch("https://astapa.com/api/platform/claims", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
email: customer.email,
claims: { plan: "pro" },
}),
});Gate features in your app
After verifying the access token, check the claims object to decide what the user can access.
const user = verifyToken(access_token);
if (user.claims.plan === "pro") {
// Show pro features
} else if (user.claims.plan === "starter") {
// Show starter features
} else {
// Free tier — show upgrade prompt
}Common claim patterns
| Key | Example value | Use case |
|---|---|---|
plan | "pro" | Feature gating by subscription tier |
role | "admin" | Role-based access control |
trial_ends | "2026-04-15" | Time-limited trial access |
seats | "5" | Seat-based licensing |
API reference
Two ways to manage claims: via session cookie (dashboard/browser) or via client credentials (server-to-server).