您目前查看的是 Apigee Edge 說明文件。
前往 Apigee X 說明文件。 info
如果開發人員購買的「依量計價」或「套裝組合」費率方案即將達到或已達到特定限制,您可以透過電子郵件通知他們。舉例來說,如果開發人員購買的方案包含 1,000 次呼叫,您可以在他們達到 800 次呼叫 (使用量達 80%),或 API 呼叫費用達到 $500 美元時通知他們。
如要使用 API 設定費率方案的用量上限通知,請按照下列步驟操作:
自訂通知範本
以下範例說明如何自訂用於通知開發人員的通知範本。詳情請參閱「使用 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
設定通知條件和動作
使用 API 設定通知條件和動作,詳情請參閱「使用 API 設定通知條件和動作」。
如要觸發費率方案限制的通知,請設定下列屬性:
RATEPLAN- 要傳送的通知類型。PUBLISHED- 將這項屬性設為 TRUE,即可在發布費率方案時觸發通知。
然後指定下列其中一個屬性:
Transactions- 交易次數。舉例來說,當開發人員達到 800 筆交易時,系統會通知他們。必須為整數值,且只能使用 > 和 = 運算子。FeeExposure- 交易累積的金額或點數。必須為整數值,且只能使用 > 和 = 運算子。FeeExposure不含設定費、週期性費用或終止費用。舉例來說,當開發人員的 API 交易費用達到 $500 美元時,系統會通知他們。FeeExposure的計算方式會因稅率而異。
當交易次數達到 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