Lumen
API Reference

Plans API

Complete guide to managing subscription plans via the API

Plans API

The Plans API allows you to create, manage, and configure subscription plans for your application. Plans can include features, pricing, and integration with pricing tables.

Overview

Plans represent subscription tiers that customers can subscribe to. Each plan can have:

  • Features: Specific capabilities or limits
  • Pricing: Monthly/yearly pricing with usage-based components
  • Versioning: Plans support versioning for changes over time
  • Pricing Table Integration: Automatic display in pricing tables

Authentication

All API requests require authentication via merchant credentials.

Endpoints

Get All Plans

Get all plans for the authenticated merchant.

GET /api/plans

Query Parameters

ParameterTypeDescription
includeFeaturesbooleanInclude associated features in response
includePricesbooleanInclude pricing information in response

Response

{
  "plans": [
    {
      "id": "plan_123",
      "stablePlanId": "starter_plan",
      "versionNumber": 1,
      "planName": "Starter Plan",
      "planDescription": "Perfect for getting started",
      "merchantId": "merchant_123",
      "isVisibleInPricingTable": true,
      "isEnterprisePlan": false,
      "buttonText": "Get Started",
      "enterpriseRedirectUrl": null,
      "createdAt": "2024-01-01T00:00:00Z",
      "features": [
        {
          "id": "feature_123",
          "slug": "api_calls",
          "displayName": "API Calls",
          "featureType": "number",
          "featureValue": "1000"
        }
      ]
    }
  ]
}

Get Plan by ID

Get a specific plan by its ID or stable ID.

GET /api/plans/{id}

Parameters

ParameterTypeDescription
idstringPlan ID or stable plan ID

Query Parameters

ParameterTypeDescription
includeFeaturesbooleanInclude associated features
isStableIdbooleanTreat ID parameter as stable ID

Response

Same structure as the plans array above, but returns a single plan.

Create Plan

Create a new subscription plan with optional features and pricing.

POST /api/plans

Request Body

{
  "planName": "Professional Plan",
  "planDescription": "For growing businesses",
  "currency": "USD",
  "monthlyPrice": 2900,
  "yearlyPrice": 2400,
  "hasYearlyPrice": true,
  "showInPricingTable": true,
  "isEnterprisePlan": false,
  "newFeatures": [
    {
      "featureName": "API Calls",
      "slug": "api_calls",
      "eventName": "api_call",
      "isUsageBased": true,
      "usagePricePerUnit": 10,
      "hasCreditAllowance": true,
      "creditAllowanceAmount": 10000,
      "creditAllowanceRenewal": "monthly"
    },
    {
      "featureName": "Premium Support",
      "slug": "premium_support",
      "isUsageBased": false
    }
  ],
  "featureIds": ["existing_feature_id"],
  "commitMessage": "Added professional plan with enhanced features"
}

Request Fields

FieldTypeRequiredDescription
planNamestringDisplay name of the plan
planDescriptionstringPlan description
currencystringCurrency code (defaults to merchant default)
monthlyPricenumberMonthly price in cents
yearlyPricenumberYearly price in cents
hasYearlyPricebooleanWhether plan offers yearly pricing
showInPricingTablebooleanAdd to pricing table automatically
isEnterprisePlanbooleanMark as enterprise plan
enterpriseButtonTextstringCustom button text for enterprise
enterpriseRedirectUrlstringRedirect URL for enterprise plans
newFeaturesarrayFeatures to create and associate
featureIdsarrayExisting feature IDs to associate
commitMessagestringVersion commit message

New Features Schema

FieldTypeRequiredDescription
featureNamestringDisplay name
slugstringUnique identifier
eventNamestringEvent name for usage tracking
isUsageBasedbooleanWhether feature tracks usage
usagePricePerUnitnumberPrice per usage unit in cents
hasCreditAllowancebooleanInclude credit allowance
creditAllowanceAmountnumberCredit amount
creditAllowanceRenewalenummonthly, yearly, or none
existingFeatureIdstringID of existing feature to configure

Response

{
  "plans": [
    {
      "id": "plan_456",
      "stablePlanId": "professional_plan",
      "versionNumber": 1,
      "planName": "Professional Plan",
      "planDescription": "For growing businesses",
      "merchantId": "merchant_123",
      "isVisibleInPricingTable": true,
      "isEnterprisePlan": false,
      "buttonText": "Get Started",
      "features": [
        {
          "id": "feature_456",
          "slug": "api_calls",
          "displayName": "API Calls",
          "featureType": "number",
          "featureValue": "usage_based"
        }
      ],
      "createdAt": "2024-01-01T00:00:00Z"
    }
  ]
}

Update Plan

Create a new version of an existing plan with updated configuration.

POST /api/plans/{id}

Parameters

ParameterTypeDescription
idstringPlan ID or stable plan ID

Query Parameters

ParameterTypeDescription
isStableIdbooleanTreat ID as stable plan ID

Request Body

{
  "planName": "Professional Plan v2",
  "planDescription": "Updated professional plan",
  "priceIds": ["price_123", "price_456"],
  "featureIds": ["feature_123", "feature_456"],
  "commitMessage": "Updated plan with new pricing"
}

Request Fields

FieldTypeDescription
planNamestringUpdated plan name
planDescriptionstringUpdated description
priceIdsarrayPrice IDs to associate with new version
featureIdsarrayFeature IDs to associate with new version
commitMessagestringVersion commit message

Note: If priceIds or featureIds are not provided, the existing associations will be cloned to the new version.

Response

Returns the new plan version with the same structure as the create response.

Delete Plan

Soft delete a plan and its associations.

DELETE /api/plans/{id}

Parameters

ParameterTypeDescription
idstringPlan ID to delete

Response

{
  "success": true,
  "message": "Plan and associated features and pricing table associations deleted successfully"
}

Toggle Pricing Table Visibility

Add or remove a plan from pricing tables.

POST /api/plans/{id}/toggle-pricing-table-visibility

Parameters

ParameterTypeDescription
idstringPlan ID

Request Body

{
  "isVisible": true
}

Response

{
  "success": true,
  "message": "Plan added to pricing table successfully",
  "plan": {
    "id": "plan_123",
    "isVisibleInPricingTable": true
    // ... full plan object
  }
}

Examples

Creating a Basic Plan

curl -X POST /api/plans \
  -H "Content-Type: application/json" \
  -d '{
    "planName": "Basic Plan",
    "planDescription": "Essential features for small teams",
    "monthlyPrice": 999,
    "showInPricingTable": true
  }'

Creating a Plan with Usage-Based Features

curl -X POST /api/plans \
  -H "Content-Type: application/json" \
  -d '{
    "planName": "Professional Plan",
    "planDescription": "Advanced features with usage tracking",
    "monthlyPrice": 2900,
    "yearlyPrice": 2400,
    "hasYearlyPrice": true,
    "showInPricingTable": true,
    "newFeatures": [
      {
        "featureName": "API Calls",
        "slug": "api_calls",
        "eventName": "api_call",
        "isUsageBased": true,
        "usagePricePerUnit": 10,
        "hasCreditAllowance": true,
        "creditAllowanceAmount": 10000,
        "creditAllowanceRenewal": "monthly"
      }
    ]
  }'

Creating an Enterprise Plan

curl -X POST /api/plans \
  -H "Content-Type: application/json" \
  -d '{
    "planName": "Enterprise Plan",
    "planDescription": "Custom solutions for large organizations",
    "isEnterprisePlan": true,
    "enterpriseButtonText": "Contact Sales",
    "enterpriseRedirectUrl": "https://example.com/contact",
    "showInPricingTable": true,
    "featureIds": ["feature_1", "feature_2", "feature_3"]
  }'

Updating a Plan

curl -X POST /api/plans/plan_123 \
  -H "Content-Type: application/json" \
  -d '{
    "planName": "Updated Basic Plan",
    "planDescription": "Enhanced basic plan with more features",
    "featureIds": ["feature_1", "feature_2", "feature_3"],
    "commitMessage": "Added additional features to basic plan"
  }'

Error Responses

All endpoints may return these error responses:

400 Bad Request

{
  "error": "One or more feature IDs are invalid or do not belong to this merchant"
}

404 Not Found

{
  "error": "Plan not found or access denied"
}

500 Internal Server Error

{
  "error": "Failed to create plan"
}

Important Notes

Plan Versioning

  • Plans support versioning for tracking changes over time
  • Each update creates a new version with an incremented versionNumber
  • The stablePlanId remains constant across versions
  • Use commitMessage to document changes between versions

Pricing Integration

  • Plans can automatically integrate with pricing tables
  • Set showInPricingTable: true to add to the default pricing table
  • Plans are ordered by price (lowest to highest) in pricing tables
  • Enterprise plans appear last regardless of pricing

Feature Management

  • Features can be created inline with newFeatures or referenced by ID with featureIds
  • Usage-based features support automatic credit allowances
  • Credit allowances can renew monthly, yearly, or be one-time grants

Currency Handling

  • Prices are specified in cents (e.g., 2900 = $29.00)
  • Currency defaults to merchant's default currency if not specified
  • Both monthly and yearly pricing can be configured

Enterprise Plans

  • Enterprise plans don't require pricing configuration
  • They can have custom button text and redirect URLs
  • Useful for custom pricing or sales-driven processes