Class: MetronomeSDK::Resources::V1::Alerts

Inherits:
Object
  • Object
show all
Defined in:
lib/metronome_sdk/resources/v1/alerts.rb,
sig/metronome_sdk/resources/v1/alerts.rbs

Overview

Alerts monitor customer spending, balances, and other billing factors. Use these endpoints to create, retrieve, and archive customer alerts. To view sample alert payloads by alert type, navigate here.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Alerts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Alerts.

Parameters:



166
167
168
# File 'lib/metronome_sdk/resources/v1/alerts.rb', line 166

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(id:, release_uniqueness_key: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::AlertArchiveResponse

Some parameter documentations has been truncated, see Models::V1::AlertArchiveParams for more details.

Permanently disable a threshold notification and remove it from active monitoring across all customers. Archived threshold notifications stop evaluating immediately and can optionally release their uniqueness key for reuse in future threshold notification configurations.

Use this endpoint to:

  • Decommission threshold notifications that are no longer needed
  • Clean up test or deprecated threshold notification configurations
  • Free up uniqueness keys for reuse with new threshold notifications
  • Stop threshold notification evaluations without losing historical configuration data
  • Disable outdated monitoring rules during pricing model transitions

Key response fields:

  • data: Object containing the archived threshold notification's ID

Usage guidelines:

  • Irreversible for evaluation: Archived threshold notifications cannot be re-enabled; create a new threshold notification to resume monitoring
  • Uniqueness key handling: Set release_uniqueness_key : true to reuse the key in future threshold notifications
  • Immediate effect: Threshold notification evaluation stops instantly across all customers
  • Historical preservation: Archive operation maintains threshold notification history and configuration for compliance and auditing

Parameters:

  • id (String)

    The Metronome ID of the threshold notification

  • release_uniqueness_key (Boolean)

    If true, resets the uniqueness key on this threshold notification so it can be r

  • request_options (MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



152
153
154
155
156
157
158
159
160
161
# File 'lib/metronome_sdk/resources/v1/alerts.rb', line 152

def archive(params)
  parsed, options = MetronomeSDK::V1::AlertArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/alerts/archive",
    body: parsed,
    model: MetronomeSDK::Models::V1::AlertArchiveResponse,
    options: options
  )
end

#create(alert_type:, name:, threshold:, alert_specifiers: nil, billable_metric_id: nil, credit_grant_type_filters: nil, credit_type_id: nil, custom_field_filters: nil, customer_id: nil, evaluate_on_create: nil, group_values: nil, invoice_types_filter: nil, plan_id: nil, seat_filter: nil, uniqueness_key: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::AlertCreateResponse

Some parameter documentations has been truncated, see Models::V1::AlertCreateParams for more details.

Create a new threshold notification to monitor customer spending, balances, and billing metrics in real-time. Metronome's notification system provides industry-leading speed with immediate evaluation capabilities, enabling you to proactively manage customer accounts and prevent revenue leakage.

This endpoint creates configurable threshold notifications that continuously monitor various billing thresholds including spend limits, credit balances, commitment utilization, and invoice totals. Threshold notifications can be configured globally for all customers or targeted to specific customer accounts.

Use this endpoint to:

  • Proactively monitor customer spending patterns to prevent unexpected overages or credit exhaustion
  • Automate notifications when customers approach commitment limits or credit thresholds
  • Enable real-time intervention for accounts at risk of churn or payment issues
  • Scale billing operations by automating threshold-based workflows and notifications

Key response fields:

A successful response returns a CustomerAlert object containing:

  • The threshold notification configuration with its unique ID and current status
  • The customer's evaluation status (ok, in_alarm, or evaluating)
  • Threshold notification metadata including type, threshold values, and update timestamps

Usage guidelines:

  • Immediate evaluation: Set evaluate_on_create : true (default) for instant evaluation against existing customers
  • Uniqueness constraints: Each threshold notification must have a unique uniqueness_key within your organization. Use release_uniqueness_key : true when archiving to reuse keys
  • Notification type requirements: Different threshold notification types require specific fields (e.g., billable_metric_id for usage notifications, credit_type_id for credit-based threshold notifications)
  • Webhook delivery: Threshold notifications trigger webhook notifications for real-time integration with your systems. Configure webhook endpoints before creating threshold notifications
  • Performance at scale: Metronome's event-driven architecture processes threshold notification evaluations in real-time as usage events stream in, unlike competitors who rely on periodic polling or batch evaluation cycles

Parameters:

  • alert_type (Symbol, MetronomeSDK::Models::V1::AlertCreateParams::AlertType)

    Type of the threshold notification

  • name (String)

    Name of the threshold notification

  • threshold (Float)

    Threshold value of the notification policy. Depending upon the notification typ

  • alert_specifiers (Array<MetronomeSDK::Models::V1::AlertCreateParams::AlertSpecifier>)

    Can be used with only low_remaining_contract_credit_and_commit_balance_reached

  • billable_metric_id (String)

    For threshold notifications of type usage_threshold_reached, specifies which b

  • credit_grant_type_filters (Array<String>)

    An array of strings, representing a way to filter the credit grant this threshol

  • credit_type_id (String)

    ID of the credit's currency, defaults to USD. If the specific notification type

  • custom_field_filters (Array<MetronomeSDK::Models::V1::AlertCreateParams::CustomFieldFilter>)

    A list of custom field filters for threshold notification types that support adv

  • customer_id (String)

    If provided, will create this threshold notification for this specific customer.

  • evaluate_on_create (Boolean)

    If true, the threshold notification will evaluate immediately on customers that

  • group_values (Array<MetronomeSDK::Models::V1::AlertCreateParams::GroupValue>)

    Only present for spend_threshold_reached notifications. Scope notification to

  • invoice_types_filter (Array<String>)

    Only supported for invoice_total_reached threshold notifications. A list of invo

  • plan_id (String)

    If provided, will create this threshold notification for this specific plan. To

  • seat_filter (MetronomeSDK::Models::V1::AlertCreateParams::SeatFilter)

    Required for low_remaining_seat_balance_reached notifications. The alert is sc

  • uniqueness_key (String)

    Prevents the creation of duplicates. If a request to create a record is made wit

  • request_options (MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



98
99
100
101
102
103
104
105
106
107
# File 'lib/metronome_sdk/resources/v1/alerts.rb', line 98

def create(params)
  parsed, options = MetronomeSDK::V1::AlertCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/alerts/create",
    body: parsed,
    model: MetronomeSDK::Models::V1::AlertCreateResponse,
    options: options
  )
end