Skip to content

Usage threshold alerts ​

Metered features (the ones your app reports through the runtime consume API) warn tenants before they hit a limit. When a tenant's usage of a metered feature reaches a threshold, TenancyEngine:

  1. records the alert (visible under the tenant's Usage tab, Threshold alerts),
  2. emails the tenant's administrators, branded with your application's name, logo and support address,
  3. sends a usage.threshold_reached webhook to your application's webhook endpoints.

Nothing is added to the consume call itself: a consume that does not reach a threshold costs no extra database work, and the email is sent in the background.

Thresholds ​

By default a feature alerts at 80% and 100% of the tenant's limit. Under Applications → Features → Edit (metered features only) you can:

  • change the thresholds: up to five whole percentages from 1 to 100, for example 50,80,100; leave it empty for the default,
  • turn alerts off for that feature (no email, no webhook, no alert log entry).

Existing features keep alerting at 80% and 100% until you change them. The same settings are available through the features admin API (usageAlertsEnabled, usageAlertThresholds).

When an alert fires ​

  • Counter meters (usage that resets monthly or daily) alert once per threshold per usage period. Replaying a consume with the same idempotency key, or lowering and raising usage again inside the period, never alerts twice. The next period starts fresh.
  • Gauge meters (seats, projects, anything that can fall again) alert every time usage rises back across a threshold.
  • If one consume jumps past several thresholds (for example 0 to 100%), only the highest threshold sends email and webhook; the lower ones are recorded as not sent.

Webhook: usage.threshold_reached ​

Subscribe under Applications → Webhooks. Delivered to the application that owns the tenant, signed like every other event.

json
{
  "tenantId": "0c1f6d0e-4b8e-4a5b-9d51-5e0f3f4a1a11",
  "tenantSlug": "acme-studio",
  "applicationId": "7a2d7e6c-0a52-4c0e-8b0e-2f4d9a3a9b22",
  "environment": "Production",
  "featureKey": "exports.monthly",
  "featureDisplayName": "Monthly exports",
  "currentValue": 80,
  "limitValue": 100,
  "thresholdPercent": 80,
  "periodStartUtc": "2026-10-01T00:00:00Z",
  "alertId": "5b7c2f1e-6a41-4c33-9a55-0d1e8b6f7c33"
}

usage.near_limit (thresholds from 80% to 99%) and usage.at_limit (100%) keep firing with the same payload for existing subscribers. Subscribe to one family, not both: usage.threshold_reached covers every threshold you configure.

Email ​

The email goes to every administrator of the tenant (tenant_admin and tenant_owner members). Platform operators can edit the wording under Email templates, category tenant.usage_alert.

TenancyEngine platform documentation