Introducing the Chargebee CLI

Setting up Alerts

This guide walks you through creating Usages, Spends, and Credits alerts, and managing them over time. If you haven't already, read Usage Alerts to understand the key concepts before proceeding.

Usage alerts and spend alerts are in beta and are available when Usage-Based Billing is enabled. Credit alerts are in early access and require Prepaid Credits to be enabled.

Prerequisites

Before you create an alert, configure a webhook endpoint and include the alert_status_changed event. Alert notifications are delivered through that event. When an endpoint sends only selected events, include alert_status_changed in that selection. Go to Settings > Configure Chargebee > API Keys and Webhooks, then open the Webhooks tab. See Webhooks settings.

The other prerequisites depend on the alert type:

  • Usages: This alert type is in beta and is available when Usage-Based Billing is enabled. Define at least one metered feature, and ingest usage events for the feature you plan to monitor. Chargebee Billing evaluates a Usages alert as those events are processed.
  • Spends: This alert type is in beta and is available when Usage-Based Billing is enabled. It watches accrued usage charges in the currency you select on the alert.
  • Credits: This alert type is in early access. Prepaid Credits must be enabled on the site before you can create a credit alert. Choose the credit unit you want to watch. Each credit alert applies to a subscription and one credit unit.

During development, you can use tools like webhook.site to inspect alert webhook payloads before integrating them into your application.

Create an alert

Open Usages > Alerts and click Create Alert. Enter an Alert name and an Alert description, select an Alert Type, set the criteria, choose who the alert applies to, select a delivery channel, and click Save Alert. The alert is active after you save it.

Use the procedure that matches the type you need.

Create a Usages alert

A Usages alert triggers when a subscription's usage reaches a specified threshold.

  1. Go to Usages > Alerts and click Create Alert.
  2. Enter an Alert name and an Alert description.
  3. Under Alert Type, select Usages.
  4. In Set criteria for sending alert, select the metered feature.
  5. Enter the percentage of included usage. The form shows exceeds and of included usage. For example, enter 80 to trigger the alert at 80 percent of included usage.
  6. Under Apply Alert to, select All Subscriptions or Subscriptions containing specific items.
  7. Under Alert delivery channel, click Manage connected webhooks to choose or add an endpoint. Chargebee Billing opens API Keys and Webhooks.
  8. Click Save Alert.

Chargebee Billing evaluates the alert against incoming usage events. When usage exceeds the percentage for a subscription, Chargebee Billing shows a warning banner on that subscription.

Create a Spends alert

Spends is in beta and is available when Usage-Based Billing is enabled. Chargebee Billing evaluates usage charges from metered addons against the amount you enter, counting only usage beyond the included entitlement. Other charges on the subscription are outside this threshold.

  1. Go to Usages > Alerts and click Create Alert.
  2. Enter an Alert name and an Alert description.
  3. Under Alert Type, select Spends.
  4. In Set criteria for sending alert, select the currency. The list shows the currency name and symbol, such as USD - $ US Dollars.
  5. Enter the amount. The form shows exceeds and the currency symbol after the amount.
  6. Under Apply Alert to, select All Subscriptions or Subscriptions containing specific items.
  7. Under Alert delivery channel, click Manage connected webhooks.
  8. Click Save Alert.

Create a Credits alert

Credits is in early access. Prepaid Credits must be enabled before you can create this alert. The form describes this type as triggering when a customer's available credit balance falls below or exceeds a certain amount. The criteria operator on the form is drops to. The alert fires when the prepaid credit balance for the selected unit drops to or below the amount you enter. Each credit alert applies to a subscription and one credit unit.

  1. Go to Usages > Alerts and click Create Alert.
  2. Enter an Alert name and an Alert description.
  3. Under Alert Type, select Credits.
  4. In Set criteria for sending alert, select the credit unit.
  5. Enter the balance. The form shows drops to and the unit name after the amount.
  6. Under Apply Alert to, leave All Subscriptions selected. Subscriptions containing specific items is unavailable for Credits.
  7. Under Alert delivery channel, click Manage connected webhooks.
  8. Click Save Alert.

When the balance drops to or below the threshold, the alert status changes to in_alarm.

Edit an alert

To modify an existing alert:

  1. Navigate to Usages > Alerts.
  2. Select the alert you want to update.
  3. Click Edit Alert under Actions.
  4. Make the required changes and click Save Alert.

Disabling an alert

Disabling an alert allows you to temporarily stop notifications without deleting the alert configuration. This is useful when you want to pause monitoring or make changes without triggering alerts.

To disable an alert:

  1. Navigate to Usages > Alerts.
  2. Select the alert you want to disable.
  3. Click Disable Alert under Actions.

Once disabled:

  • Chargebee Billing stops evaluating the alert.
  • No webhook notifications are sent for the alert.

You can re-enable the alert at any time by selecting Enable Alert from the same menu.

Deleting an alert

Deleting an alert permanently removes it from your Chargebee site. This action cannot be undone.

To delete an alert:

  1. Navigate to Usages > Alerts.
  2. Select the alert you want to delete.
  3. Click Delete Alert under Actions.
  4. Click Delete to confirm the deletion when prompted.

After deletion:

  • The alert configuration is permanently removed.
  • No further evaluations or notifications will occur for that alert.