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

ProviderUse case
LemonSqueezyPrimary — subscriptions, token packs, vouchers
StripeEnterprise — custom plans, invoices
PaddleGlobal — VAT-inclusive pricing
PayPalAlternative payment method
MercadoPagoLatin 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

MethodEndpointDescription
GET/billing/statusCurrent plan, token usage, and renewal date
GET/billing/invoicesInvoice history
GET/billing/payment-methodsStored payment methods
GET/billing/plansAvailable subscription plans with pricing
GET/billing/analyticsBilling and usage analytics
POST/billing/checkoutCreate LemonSqueezy checkout for plan upgrade
POST/billing/recharge-tokensCreate checkout to purchase token packs
POST/billing/voucher/validateValidate a discount voucher code
POST/billing/syncSync usage data to BillingService
POST/billing/check-overageCheck if usage exceeds plan limits
POST/billing/webhook/upgradeInternal: plan upgrade webhook from BillingService
POST/billing/webhook/cancelInternal: subscription cancellation webhook
POST/billing/webhook/token-rechargeInternal: token recharge webhook
POST/billing/webhook/lemonsqueezyDirect LemonSqueezy webhook (public)
Billing — CognitionDesk Docs