Alert
Source:
src/Stripe/Alert.ts
A Stripe Billing Alert — notifies you when a usage threshold on a
Billing Meter is crossed.
title, alertType, and usageThreshold are immutable; changing them
replaces the alert. status is changed with Stripe’s activate/deactivate
endpoints.
Billing alerts have no metadata field and cannot be hard-deleted. Destroying this resource archives the alert (irreversible). Archived alerts leave the list API and cannot be reactivated.
Creating an Alert
Section titled “Creating an Alert”Usage threshold on a meter
const apiCalls = yield* Stripe.BillingMeter("api-calls", { displayName: "API Calls", eventName: "api_call", defaultAggregation: { formula: "sum" },});const highUsage = yield* Stripe.Alert("high-usage", { title: "API Request usage alert", usageThreshold: { gte: 10000, meter: apiCalls.id, recurrence: "one_time", },});Limit the alert to one customer
const highUsage = yield* Stripe.Alert("high-usage", { title: "Customer API usage alert", usageThreshold: { gte: 1000, meter: apiCalls.id, recurrence: "one_time", filters: [{ type: "customer", customer: customer.id }], },});Updating an Alert
Section titled “Updating an Alert”const highUsage = yield* Stripe.Alert("high-usage", { title: "API Request usage alert", usageThreshold: { gte: 10000, meter: apiCalls.id, recurrence: "one_time", }, status: "inactive",});Archiving an Alert
Section titled “Archiving an Alert”// stack.destroy() / resource removal archives the alertconst highUsage = yield* Stripe.Alert("high-usage", { title: "API Request usage alert", usageThreshold: { gte: 10000, meter: apiCalls.id, recurrence: "one_time", },});