Skip to main content

Package-based Usage Quotas (Plan Limits)

Overview

Plan Limits is the mechanism that caps how many resources each organization may create — audiences, concurrently active workflows, templates, custom attributes, and the right to use audience auto-refresh. The defaults are platform-wide values that can be overridden per organization through the organization.plan_limits JSONB column.

This module has no routes of its own: RegisterRoutes is intentionally a no-op. It is a provider-only module that other modules call at creation time to check whether a quota has already been reached.

Business Flow

  1. A user attempts to create a new audience, workflow, or template.
  2. That module's service asks planlimits for the organization's effective limits:
    • Read organization.plan_limits (JSONB); if the key is present, use that value.
    • Otherwise fall back to DefaultPlanLimits.
    • maxChannels is a special case: it always comes from the legacy organization.max_channel column (a varchar) and has no entry in the default constant.
    • A value of -1 means unlimited.
  3. The current count, taken from that module's own table, is compared against the limit.
  4. If the quota is exceeded, an error is returned so cms-web can tell the user they have hit their package ceiling.
  5. Platform admins adjust limits through PUT /api/org-module-setting/:orgId/limits.

Defaults in DefaultPlanLimits

KeyDefaultMeaning
maxSegments5Maximum number of audiences/segments
maxActiveWorkflows3Workflows that may be active at once
maxTemplates20Number of message templates
maxAttributes30Number of custom attributes
autoRefreshfalseWhether audience auto-refresh is permitted
maxChannelsFrom organization.max_channelNumber of LINE OAs that may be created

Key Files & Functions

The code lives in internal/modules/planlimits/, consisting of service.go, constant.go, and controller.go.

  • controller.goRegisterRoutes is a deliberate no-op, since this is a provider-only module, matching the original NestJS implementation which had no controller.
  • constant.go — defines DefaultPlanLimits.
  • service.goGetEffectiveLimits plus per-resource quota-check helpers.

According to the doc comments in the code, the modules that consume planlimits are lineoa, audience, audiencefilter, workflow, templatemessage, attributemaster, and orgmodulesetting.

Connections to Other Services

  • Permissions — no routes, therefore no guards; authorization is enforced by the calling module.
  • Tablesorganization, specifically the plan_limits (JSONB) and max_channel (varchar) columns
  • CLS — reads organizationId for scoping
  • Configured by — the per-organization module and quota settings console
  • Consumed by — audience management, workflows, message templates, attribute master, and LINE OA management