Platform
Billing
CognitionDesk's billing is handled by a dedicated BillingService that supports multiple payment providers. Token usage is tracked in real time and enforced at the API level.
Payment Providers
| Provider | Use case |
|---|---|
| LemonSqueezy | Primary — subscriptions, token packs, vouchers |
| Stripe | Enterprise — custom plans, invoices |
| Paddle | Global — VAT-inclusive pricing |
| PayPal | Alternative payment method |
| MercadoPago | Latin America markets |
Check billing status
JSON
GET /billing/status
Authorization: Bearer <token>
// Response
{
"plan": "pro",
"status": "active",
"tokensUsed": 125000,
"tokensLimit": 500000,
"tokensRemaining": 375000,
"renewsAt": "2026-04-15T00:00:00Z",
"provider": "lemonsqueezy"
}Create a checkout
Redirect users to a LemonSqueezy checkout to upgrade their plan:
JSON
POST /billing/checkout
Authorization: Bearer <token>
{
"planId": "plan_pro",
"successUrl": "https://app.cognitiondesk.com/billing?success=true",
"cancelUrl": "https://app.cognitiondesk.com/billing"
}
// Response: redirect user to checkout URL
{
"checkoutUrl": "https://checkout.lemonsqueezy.com/checkout/buy/...",
"sessionId": "sess_abc123"
}Recharge tokens
Users can purchase additional token packs without changing their plan:
JSON
POST /billing/recharge-tokens
Authorization: Bearer <token>
{
"pack": "tokens_500k", // token pack ID
"successUrl": "https://app.cognitiondesk.com/billing"
}Validate vouchers
JSON
POST /billing/voucher/validate
Authorization: Bearer <token>
{
"code": "LAUNCH25"
}
// Response
{
"valid": true,
"discount": { "type": "percent", "value": 25 },
"description": "25% off for launch week"
}Token usage
Every AI request consumes tokens. The backend enforces limits via the quotaMiddleware — requests that exceed the plan limit return 402 Payment Required.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /billing/status | Current plan, token usage, and renewal date |
| GET | /billing/invoices | Invoice history |
| GET | /billing/payment-methods | Stored payment methods |
| GET | /billing/plans | Available subscription plans with pricing |
| GET | /billing/analytics | Billing and usage analytics |
| POST | /billing/checkout | Create LemonSqueezy checkout for plan upgrade |
| POST | /billing/recharge-tokens | Create checkout to purchase token packs |
| POST | /billing/voucher/validate | Validate a discount voucher code |
| POST | /billing/sync | Sync usage data to BillingService |
| POST | /billing/check-overage | Check if usage exceeds plan limits |
| POST | /billing/webhook/upgrade | Internal: plan upgrade webhook from BillingService |
| POST | /billing/webhook/cancel | Internal: subscription cancellation webhook |
| POST | /billing/webhook/token-recharge | Internal: token recharge webhook |
| POST | /billing/webhook/lemonsqueezy | Direct LemonSqueezy webhook (public) |