Skip to content
  • Auto
  • Light
  • Dark
Talk to an expert

Create

Create an alert
client.V1.Alerts.New(ctx, body) (*DataIDV1AlertNewResponse, error)
post/v1/alerts/create

Create a new alert

Parameters
bodyAlertTypefieldNamefieldThresholdfieldBillableMetricIDfieldCreditGrantTypeFiltersfieldCreditTypeIDfieldCustomFieldFiltersfieldCustomerIDfieldEvaluateOnCreatefieldGroupValuesfieldInvoiceTypesFilterfieldPlanIDfieldUniquenessKeyfieldV1AlertNewParams
Hide ParametersShow Parameters
AlertTypefield

Type of the alert

Hide ParametersShow Parameters
V1AlertNewParamsAlertTypeLowCreditBalanceReachedconst
"low_credit_balance_reached"
V1AlertNewParamsAlertTypeSpendThresholdReachedconst
"spend_threshold_reached"
V1AlertNewParamsAlertTypeMonthlyInvoiceTotalSpendThresholdReachedconst
"monthly_invoice_total_spend_threshold_reached"
V1AlertNewParamsAlertTypeLowRemainingDaysInPlanReachedconst
"low_remaining_days_in_plan_reached"
V1AlertNewParamsAlertTypeLowRemainingCreditPercentageReachedconst
"low_remaining_credit_percentage_reached"
V1AlertNewParamsAlertTypeUsageThresholdReachedconst
"usage_threshold_reached"
V1AlertNewParamsAlertTypeLowRemainingDaysForCommitSegmentReachedconst
"low_remaining_days_for_commit_segment_reached"
V1AlertNewParamsAlertTypeLowRemainingCommitBalanceReachedconst
"low_remaining_commit_balance_reached"
V1AlertNewParamsAlertTypeLowRemainingCommitPercentageReachedconst
"low_remaining_commit_percentage_reached"
V1AlertNewParamsAlertTypeLowRemainingDaysForContractCreditSegmentReachedconst
"low_remaining_days_for_contract_credit_segment_reached"
V1AlertNewParamsAlertTypeLowRemainingContractCreditBalanceReachedconst
"low_remaining_contract_credit_balance_reached"
V1AlertNewParamsAlertTypeLowRemainingContractCreditPercentageReachedconst
"low_remaining_contract_credit_percentage_reached"
V1AlertNewParamsAlertTypeLowRemainingContractCreditAndCommitBalanceReachedconst
"low_remaining_contract_credit_and_commit_balance_reached"
V1AlertNewParamsAlertTypeInvoiceTotalReachedconst
"invoice_total_reached"
Namefield
param.Field[string]

Name of the alert

Thresholdfield
param.Field[float64]

Threshold value of the alert policy. Depending upon the alert type, this number may represent a financial amount, the days remaining, or a percentage reached.

BillableMetricIDfield
optional
param.Field[string]

For alerts of type usage_threshold_reached, specifies which billable metric to track the usage for.

formatuuid
CreditGrantTypeFiltersfield
optional
param.Field[[]string]

An array of strings, representing a way to filter the credit grant this alert applies to, by looking at the credit_grant_type field on the credit grant. This field is only defined for CreditPercentage and CreditBalance alerts

CreditTypeIDfield
optional
param.Field[string]

ID of the credit's currency, defaults to USD. If the specific alert type requires a pricing unit/currency, find the ID in the Metronome app.

formatuuid
CustomFieldFiltersfield
optional

A list of custom field filters for alert types that support advanced filtering. Only present for contract invoices.

Hide ParametersShow Parameters
EntityV1AlertNewParamsCustomFieldFiltersEntityContractV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityCommitV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityContractCreditV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntity
Hide ParametersShow Parameters
V1AlertNewParamsCustomFieldFiltersEntityContractconst
V1AlertNewParamsCustomFieldFiltersEntityContractV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityCommitV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityContractCreditV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntity
"Contract"
V1AlertNewParamsCustomFieldFiltersEntityCommitconst
V1AlertNewParamsCustomFieldFiltersEntityContractV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityCommitV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityContractCreditV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntity
"Commit"
V1AlertNewParamsCustomFieldFiltersEntityContractCreditconst
V1AlertNewParamsCustomFieldFiltersEntityContractV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityCommitV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntityContractCreditV1AlertNewParamsCustomFieldFiltersEntityV1AlertNewParamsCustomFieldFiltersEntity
"ContractCredit"
Keystring
Valuestring
CustomerIDfield
optional
param.Field[string]

If provided, will create this alert for this specific customer. To create an alert for all customers, do not specify a customer_id.

formatuuid
EvaluateOnCreatefield
optional
param.Field[bool]

If true, the alert will evaluate immediately on customers that already meet the alert threshold. If false, it will only evaluate on future customers that trigger the alert threshold. Defaults to true.

GroupValuesfield
optional

Only present for spend_threshold_reached alerts. Scope alert to a specific group key on individual line items.

Hide ParametersShow Parameters
Keystring
Valuestring
InvoiceTypesFilterfield
optional
param.Field[[]string]

Only supported for invoice_total_reached alerts. A list of invoice types to evaluate.

PlanIDfield
optional
param.Field[string]

If provided, will create this alert for this specific plan. To create an alert for all customers, do not specify a plan_id.

formatuuid
UniquenessKeyfield
optional
param.Field[string]

Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.

minLength1
maxLength128
Returns
V1AlertNewResponsestruct
Hide ParametersShow Parameters
DataIDstringID
package main

import (
  "context"
  "fmt"

  "github.com/Metronome-Industries/metronome-go"
  "github.com/Metronome-Industries/metronome-go/option"
)

func main() {
  client := metronome.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  alert, err := client.V1.Alerts.New(context.TODO(), metronome.V1AlertNewParams{
    AlertType: metronome.F(metronome.V1AlertNewParamsAlertTypeSpendThresholdReached),
    Name: metronome.F("$100 spend threshold reached"),
    Threshold: metronome.F(10000.000000),
    CreditGrantTypeFilters: metronome.F([]string{"enterprise"}),
    CreditTypeID: metronome.F("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),
    CustomerID: metronome.F("4db51251-61de-4bfe-b9ce-495e244f3491"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", alert.Data)
}
200 Example
{
  "data": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
  }
}