Example - Notification Setup for Commitment Updated Event

This topic provides a worked example of how to use API calls to set up a Notification Rule for triggering a Notification only if the specific conditions defined in the Notification Rule are satisfied:

  • Any Commitment updated Event where the Commitment amount drops below 10% of the original amount.

When an Event of this type occurs in the system and which satisfies this condition, a Notification will be sent to the configured Destination.

You can follow the set up in three steps:

Tip: Setting Up Notifications for Events in Console? You can also set up Notification Rules that reference a specific system Event and then link these Rules to webhook integration Destinations you've created to complete the Notification configuration. See the Linking Notification Rules to Destinations section in the Creating, Managing, and Reviewing Notifications topic.

Step 1: Create a Notification Rule

POST at https://api.m3ter.com/organizations/{orgId}/notifications/configurations/

In this example, we’ve set up a rule for triggering a Notification based on a configuration.commitment.updated Event, which includes a calculation referencing Event Fields to define the precise conditions for triggering the Notification. The calculation means the Notification will be triggered when the amount spent from the commitment drops below 10% of the total amount.

1
{
2
"name": "Commitment has under 10% remaining",
3
"description": "Commitment amount fell below 10%",
4
"eventName": "configuration.commitment.updated",
5
"calculation": "(new.amountSpent >= ((new.amount*100)/90))
6
AND ((old.amountSpent <= ((old.amount*100)/90)) OR (old.amountSpent == null))",
7
"code" : "under_10_percent_",
8
"active": true
9
}

Note: The response schema for this call returns a unique “id” for the notification rule we’ve set up

Step 2: Create Integration Destination

POST at: https://api.m3ter.com/organizations/{orgId}/integrationdestinations/webhooks

1
{
2
"url":"https://xbmnbkwece.execute-api.eu-west-2.amazonaws.com/dev/send_email"
3
"version": 1,
4
"credentials": {
5
"version": 1,
6
"type": "M3TER_SIGNED_REQUEST",
7
"apiKey": "apiKey",
8
"secret": "some secret"
9
}
10
}

With this call, credentials are done in the same call as the Destination. In the response schema, the unique “id” for Integration Destination is returned.

Step 3: Create Integration Configuration for Notification

POST at: https://api.m3ter.com/organizations/{orgId}/integrationconfigs

1
{
2
"entityType": "Notification",
3
"entityId": "id of the notification rule",
4
"destination": "Webhook",
5
"destinationId": "id of the destination",
6
"configData": {},
7
"credentials": {
8
"type" : "M3TER_SIGNED_REQUEST"
9
}
10
}

For this call:

  • We use the “id” of the Notification Rule returned for the POST call we sent in Step 1 as the value for the “entityId”.

  • We use the Integration Destination “id” returned for the POST call at Step 2 as the value for the “destinationId”.

Next: Working with Scheduled Events



Additional Support

Login to the Support portal for additional help and to send questions to our Support team.