RELAY_SHARED_SECRET.
Checkout
POST /api/create-checkout
Creates a Dodo checkout session and returns the hosted-checkout URL.
- Auth: Clerk bearer (required)
- Body:
- Response:
{ "checkoutUrl": "https://checkout.dodopayments.com/..." } - returnUrl is validated against an allowlist on the Convex side.
POST /api/customer-portal
Creates a Dodo customer-portal session for an existing subscriber (update card, cancel, view invoices).
- Auth: Clerk bearer + active entitlement
- Response:
{ "portalUrl": "..." }
Product catalog
GET /api/product-catalog
Returns the tier view-model used by the /pro pricing page. Cached in Redis under product-catalog:v2 for 1 hour; on cache miss, fetches live prices from Dodo Payments and falls back to _product-fallback-prices.js if Dodo is unreachable. Response carries an X-Product-Catalog-Source header so probes can tell cache hits from live fetches.
Response (tiers ordered free, pro, api_starter, enterprise):
- Price fields are flat on the tier. Paid tiers expose
monthlyPrice/monthlyProductIdandannualPrice/annualProductId. Free usesprice: 0, period: "forever"; Enterprise usesprice: null. - Prices are dollars (Dodo returns cents; the handler divides by 100). Currency is implicit USD for the published catalog.
DELETE /api/product-catalog
Purges the cached catalog. Requires Authorization: Bearer $RELAY_SHARED_SECRET. Internal.
Referrals
GET /api/referral/me
Returns the caller’s deterministic referral code (an 8-char HMAC of the Clerk userId, stable for the life of the account) and a pre-built share URL. Clerk bearer required. The handler also fires a best-effort ctx.waitUntil Convex binding so future /pro?ref=<code> signups can attribute — this never blocks the response.
401 UNAUTHENTICATED— missing or invalid Clerk JWT.503 service_unavailable—BRIEF_URL_SIGNING_SECRETnot configured (the referral-code HMAC reuses that secret).
referrals count or rewardMonths is returned today — Dodo’s affonso_referral attribution doesn’t yet flow into Convex, and exposing only the waitlist-side count would mislead.
