Skip to content

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 plan or variantId, not both
  • plan is 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 active
  • cancelled - Will expire at period end
  • expired - Subscription has ended
  • past_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_created
  • subscription_updated
  • subscription_cancelled
  • subscription_payment_failed

Response ​

json
{
  "received": true
}

Notes ​

  • Verify signature using LEMONSQUEEZY_WEBHOOK_SECRET
  • Update company subscription status based on event

TendSocial Documentation