Billing API ​
Endpoints for managing subscriptions via Lemon Squeezy.
Authentication ​
All endpoints require JWT authentication except webhooks.
Create Checkout URL ​
POST /api/billing/checkout
Creates a checkout URL for starting a subscription.
Request Body ​
json
{
"plan": "professional", // Plan name (mapped to variant)
"variantId": "123456", // OR direct Lemon Squeezy variant ID
"redirectUrl": "https://app.example.com/billing?success=true"
}Response ​
json
{
"url": "https://store.lemonsqueezy.com/checkout/..."
}Notes ​
- Provide either
planorvariantId, not both planis mapped to Lemon Squeezy variants via config
Get Subscription ​
GET /api/billing/subscription
Returns current subscription status for the company.
Response ​
json
{
"id": "sub_123",
"status": "active",
"planName": "Professional",
"currentPeriodEnd": "2025-02-01T00:00:00Z",
"cancelAtPeriodEnd": false
}Status Values ​
active- Subscription is activecancelled- Will expire at period endexpired- Subscription has endedpast_due- Payment failed
Get Customer Portal ​
POST /api/billing/portal
Returns URL to Lemon Squeezy customer portal.
Response ​
json
{
"url": "https://your-store.lemonsqueezy.com/billing"
}Webhook ​
POST /api/billing/webhook
Receives webhook events from Lemon Squeezy.
Headers ​
X-Signature: Webhook signature for verification
Events Handled ​
subscription_createdsubscription_updatedsubscription_cancelledsubscription_payment_failed
Response ​
json
{
"received": true
}Notes ​
- Verify signature using
LEMONSQUEEZY_WEBHOOK_SECRET - Update company subscription status based on event