Set up a limit notification for a rate plan

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

You can notify developers through email when they're nearing or have reached a certain limit of a Volume Banded or Bundle rate card plan they've purchased. For example, if developers purchase a volume-banded plan with 1,000 calls in a bundle, you can notify them when they reach 800 calls (80% usage) or when they've spent $500 on API calls.

To set up a limit notification for a rate plan using the API, perform the following steps:

  1. Customize the notification template that will be used to notify the developer.
  2. Configure the notification condition and action.

Customizing the notification template

The following provides an example of how to customize the notification template that will be used to notify the developer. For more information, see Managing notification templates using the API.

$ curl -H "Content-Type: application/json " -X POST -d \    
'{
    "name": "RATE_PLAN_LIMIT_TEMPLATE",
    "subject": "Nearing your rate plan limit",
    "htmlImage": "<p>Hi ${developer.name} - Wanted to let you know that you have used 800 API calls from your ${ratePlan.displayName} rate plan, which started on ${ratePlan.startDate} under the ${ratePlan.monetizationPackage.displayName} package and ${ratePlan.monetizationPackage.products.displayName} product. Just a friendly reminder that your API calls will be charged double after you cross 1000 calls. Thanks for using the API!</p>",
    "source": "Postman API call"
    }' \
"https://api.enterprise.apigee.com/v1/mint/organizations/myorg/notification-email-templates" \
    -u email:password

Configuring the notification condition and action

Configure a notification condition and action using the API, as described in Configuring notification conditions and actions using the API.

To trigger the notification for a rate plan limit, set the following attributes:

  • RATEPLAN - Type of notification to send.
  • PUBLISHED - Set this attribute to TRUE in order to trigger notifications on published rate plans.

Then, specify one of the following attributes:

  • Transactions - Number of transactions. For example, notify developers when they reach 800 transactions. Must be an integer value and only > and = operators are allowed.
  • FeeExposure - Amount of dollars or points accumulated on transactions. Must be an integer value and only > and = operators are allowed. FeeExposure doesn't include setup, recurring, or termination fee amounts. For example, notify developers when the cost of their API transactions reaches $500. FeeExposure calculations vary depending on the tax rate.

The following payload triggers an email notification when the number of transactions reaches 800:

$ curl -H "Content-Type:application/json" -X POST -d \
    '{
    "notificationCondition": [
      {
        "attribute": "RATEPLAN",
        "value": "{RATE_PLAN_ID}"
      },
      {
        "attribute": "PUBLISHED",
        "value": "TRUE"
      },
      {
        "attribute": "Transactions",
        "value": "= 800"
      }     
    ],
   "actions": [{
          "actionAttribute": "DEV_ID",
          "value": "ANY",
          "templateId": "{EMAIL_TEMPLATE_ID}"
        }]
  }' \
"https://api.enterprise.apigee.com/v1/mint/organizations/{org_name}/notification-conditions" \
    -u email:password