GET /api/usage
Returns the authenticated user’s current subscription tier, plan limits, usage in the current billing cycle, and remaining allowances. Used by the dashboard to enforce quota limits in the UI and display usage indicators.Response
The user’s normalized subscription tier. One of:
starter, creator, pro, studio.Tier aliases are normalized: freemium → starter, elite → studio.Per-action limits for the current tier, sourced from
config/tier_rate_limits.json. A value of -1 means unlimited.Number of times each billable action has been performed in the current billing cycle. Read from the
user_usage_counts Directus collection.Remaining allowance per action (
limit - usage). Clamped to 0 when exhausted. -1 when unlimited.Tier limits
Limits are defined inconfig/tier_rate_limits.json and mapped to frontend-facing keys:
| Action key | Internal feature key | Description |
|---|---|---|
post_creations | caption_generator | AI-generated captions and post drafts |
taxonomy_tags | taxonomy_ai_calls | Taxonomy classification AI calls |
media_modifications | ai_clip_ops | AI-powered media operations (clip, watermark, etc.) |
| Tier | post_creations | taxonomy_tags | media_modifications |
|---|---|---|---|
| Starter | 3 / mo | 10 / mo | 5 / mo |
| Creator | 50 / mo | 100 / mo | 30 / mo |
| Pro | 200 / mo | 500 / mo | 150 / mo |
| Studio | Unlimited (-1) | Unlimited (-1) | Unlimited (-1) |
Billing cycle
Usage resets at the start of each billing cycle. The cycle start is calculated from the user’ssubscription_start and subscription_period fields in Directus:
- monthly — resets on the same day each month as
subscription_start - annual — resets annually
getCurrentBillingCycleStart() in server/utils/rateLimiter.js. Usage records with billing_cycle_start >= cycleStart are summed to produce the usage values.
If the
user_usage_counts Directus collection is inaccessible (e.g., collection not yet created), the endpoint fails open and returns usage: 0 for all actions rather than a 500 error.POST /api/usage/increment
Increments a usage counter for the authenticated user. Called server-side after a billable action completes successfully.Body
The action key to increment. Must be one of:
post_creations, taxonomy_tags, media_modifications.Response
true when the counter was incremented.Remaining allowance after the increment.
true if this increment brought the user to or past their tier limit.Dashboard integration
The React dashboard exposes usage data globally viaAuthContext:
TIER_FLAGS in the dashboard mirrors tier_rate_limits.json exactly. When updating tier limits, both files must be kept in sync.
Error responses
| Status | Body | Cause |
|---|---|---|
400 | { "error": "Invalid action. Must be one of: ..." } | Invalid action key in increment request |
401 | { "error": "Missing Bearer token" } | No Authorization header |
500 | { "error": "..." } | Directus unreachable or unexpected error |