Skip to main content

Set threshold notifications against Unbilled Usage

Zuora

Set threshold notifications against Unbilled Usage

You can set threshold notifications against the Rating Result data source for Unbilled Usage through the API and the Zuora UI.

Note that in order to set up an email threshold notification, the availability of email templates and email template IDs is a prerequisite for creating such a notification definition. For more information about how to create email templates and generate email template IDs, see Manage email templates.

To set up an email threshold notification, perform the following steps:

  1. Use the Custom Event Triggers API to define a custom event. Determine the following mandatory fields specific to the custom event:

Field name 

Type

Description

active

boolean

The status of the event trigger.

baseObject

string

The base object that the trigger rule is defined upon.

For Unbilled Usage, use RatingResult as the base object.

condition

string

The JEXL expression to be evaluated against object changes.

eventType

displayName

string

The display name for the event type.

name

string

The name of the event type.

You can use RatingResultUpdated as the name.

Sample API request: Create a custom event. 

Request

POST https://{endpoint}/v1/events/event-triggers

Request body

{

   "active": true,

   "baseObject": "RatingResult",

   "condition": "changeType == 'UPDATE'",

   "description": "Unbilled Usage Threshold Notification",

   "eventType": {

       "description": "Unbilled Usage Threshold Notification",

       "displayName": "Unbilled Usage Threshold Notification",

       "name": "RatingResultUpdated"

   }

}

  1. Use the Create a notification definition API operation to configure a notification definition. Determine the following mandatory fields specific to the notification:

Field name

Type

Description

eventTypeName

string

The name of the event type.

Note that the event type name here must be the same as it is in the preceding step.

filterRule

condition

string

The filter rule conditions, written in JEXL. The rule might contain event context merge fields and data source merge fields. Data source merge fields must be from the base object of the event or from the joined objects of the base object. Notifications with invalid merge fields will fail to evaluate, thus will not be invoked.

For Unbilled Usage, use Amount and Quantity fields from the RatingResult base object.

parameters

object (parameters)

The parameters of the filter rule and their name must match those in the filter rule. And all parameters must be defined in the event type payload. The name of parameters cannot be duplicated.

name

string

The name of the notification definition, unique per communication profile.

Sample API request: Create a notification definition.

Request

POST https://{endpoint}/v1/notifications/notification-definitions

Request body

{

   "active": true,

   "calloutActive": false,

   "description": "Unbilled Usage Threshold Notification",

   "emailActive": true,

   "emailTemplateId": "<your_email_template_ID>",

   "communicationProfileId": "<your_communication_profile_ID>",

   "eventTypeName": "RatingResultUpdated",

   "eventTypeNamespace":"user.notification",

   "filterRule": {

       "condition": "(_UNBILLED_USAGE_THRESHOLD_OPTIONS == \"amount\" && RatingResult.Amount > _UNBILLED_USAGE_THRESHOLD_VAL || (_UNBILLED_USAGE_THRESHOLD_OPTIONS == \"quantity\" && RatingResult.Quantity > _UNBILLED_USAGE_THRESHOLD_VAL))",

       "description": "Filter rule to test if rating result amount or quantity < predefined threshold",

       "parameters": {

           "_UNBILLED_USAGE_THRESHOLD_OPTIONS": {

           "description": "Notify when amount/quantity > threshold",

           "displayName": "Threshold by",

           "options": ["amount", "quantity"],

           "valueType": "STRING"

           },

           "_UNBILLED_USAGE_THRESHOLD_VAL": {

               "description": " ",

               "displayName": "Value",

               "options": null,

               "valueType": "BIG_DECIMAL"

           }

       }

   },

   "filterRuleParams": {

       "_UNBILLED_USAGE_THRESHOLD_OPTIONS": "amount",

       "_UNBILLED_USAGE_THRESHOLD_VAL": 50

   },

   "name": "Unbilled Usage Threshold Notification"

}

By performing this step, you have created a threshold notification with two event parameters available. You can make your own adjustments according to your needs.

  1. Navigate to Setting > Billing > Setup Profiles, Notifications and Email Templates, you can check and update value from the Edit Notification window in the Notification tab. Also, you can check the history of the email notifications sent in the Email History tab.