.agents/features/ee-platform.md
The EE Platform module manages billing, quota enforcement, AI credits, license keys, and cloud admin operations for the Activepieces platform. It provides the PlatformPlan entity that gates every enterprise feature flag, enforces active-flow limits, and integrates with Stripe for cloud subscriptions and OpenRouter for AI credit accounting. Self-hosted Enterprise installs use license keys instead of Stripe to unlock features.
packages/server/api/src/app/ee/platform/ — backend service and controllerpackages/server/api/src/app/ee/billing/ — Stripe webhook, checkout, billing controllerpackages/shared/src/lib/ee/billing/index.ts — shared plan constants, Zod schemas, STANDARD_CLOUD_PLAN, OPEN_SOURCE_PLANpackages/shared/src/lib/management/platform/ — PlatformPlan type and all feature-flag fieldspackages/web/src/features/billing/api/billing-plans-api.ts — platformBillingApi (portal, checkout, AI credits, auto top-up)packages/web/src/features/billing/hooks/billing-hooks.ts — billingQueries, billingMutationspackages/web/src/features/billing/components/ — SubscriptionInfo, ActiveFlowAddon, AICreditUsage, LicenseKey, PurchaseAICreditsDialog, AutoTopUpConfigDialogpackages/web/src/app/routes/platform/billing/index.tsx — Billing page (gated by edition, uses LockedFeatureGuard)OPEN_SOURCE_PLAN applied — unlimited flows, 0 AI credits, no team projects. All feature flags off.downgradeToFreePlan reverts on expiry.STANDARD_CLOUD_PLAN is the default; paid addons unlock higher active-flow limits and AI credits. Cloud Enterprise has all flags enabled.activeFlowsLimit quota.tryResetPlanIncludedCredits().Billing: plan (name), stripeCustomerId, stripeSubscriptionId, stripeSubscriptionStatus, stripeSubscriptionStartDate, stripeSubscriptionEndDate, stripeSubscriptionCancelDate.
AI Credits: includedAiCredits, lastFreeAiCreditsRenewalDate, aiCreditsAutoTopUpState (ENABLED/DISABLED), aiCreditsAutoTopUpCreditsToAdd, aiCreditsAutoTopUpThreshold, maxAutoTopUpCreditsMonthly.
Feature Flags (boolean): tablesEnabled, eventStreamingEnabled, environmentsEnabled, analyticsEnabled, showPoweredBy, auditLogEnabled, embeddingEnabled, agentsEnabled, managePiecesEnabled, manageTemplatesEnabled, customAppearanceEnabled, projectRolesEnabled, customDomainsEnabled, globalConnectionsEnabled, customRolesEnabled, apiKeysEnabled, ssoEnabled, scimEnabled, secretManagersEnabled.
Limits: activeFlowsLimit (nullable), projectsLimit (nullable), teamProjectsLimit (NONE/ONE/UNLIMITED).
License: licenseKey, licenseExpiresAt.
Workers: dedicatedWorkers (JSONB: trustedEnvironment).
platformPlanService.getUsage(platformId) returns: { activeFlows, aiCreditsLimit, aiCreditsRemaining, totalAiCreditsUsed, totalAiCreditsUsedThisMonth }
checkActiveFlowsExceededLimit() — called when enabling/publishing flows. Throws QUOTA_EXCEEDED (402) if activeFlows >= activeFlowsLimit. Skipped in CE edition.
CREDIT_PER_DOLLAR = 1000)tryResetPlanIncludedCredits() adds includedAiCredits / 1000 to OpenRouter key limittryAutoTopUpPlan() checks threshold → creates Stripe invoice → charges payment methodmaxAutoTopUpCreditsMonthlyAI_CREDIT_UPDATE_CHECK — fires on provider creation, runs both reset + topup checkscreateCustomer() — on platform creationcreatePortalSessionUrl() — self-service billing portalcheckout.session.completed, invoice.paid, customer.subscription.*requestTrial(email, companyName, goal) — request from licensing serververifyKeyOrReturnNull(platformId, license) — validate + mark activatedapplyLimits(platformId, key) — maps license features to PlatformPlan flagsdowngradeToFreePlan(platformId) — disables all EE featuresPOST /v1/admin/pieces — register piece metadataPOST /v1/admin/platforms/runs/retry — batch retry failed runsPOST /v1/admin/platforms/apply-license-key — activate license by emailPOST /v1/admin/platforms/increase-ai-credits — manually add creditsPOST /v1/admin/platforms/dedicated-workers — enable/disable dedicated workers/v1/platform-billing/info — GET, returns PlatformBillingInformation (plan details + usage).
/v1/platform-billing/portal — POST, returns Stripe portal URL (opens in new tab).
/v1/platform-billing/create-checkout-session — POST, creates subscription checkout → navigates to Stripe.
/v1/platform-billing/update-active-flows-addon — POST, changes active-flow limit addon.
/v1/platform-billing/ai-credits/create-checkout-session — POST, one-time AI credit purchase.
/v1/platform-billing/ai-credits/auto-topup — POST, configure or disable auto top-up; may return stripeCheckoutUrl for first-time payment method setup.
STANDARD_CLOUD_PLAN: 10 active flows, 200 AI credits, 1 team projectOPEN_SOURCE_PLAN: unlimited flows, 0 AI credits, no team projects