You're viewing Apigee Edge documentation.
Go to the
Apigee X documentation. info
Overview
The MonetizationLimitsCheck policy lets you enforce monetization limits on your API calls made by the app developer.
Some of the cases when the policy is triggered are:
- If an app developer accessing the monetized API has not purchased a subscription to the associated API product
- The developer's account has insufficient balance.
- The developer has exceeded the transaction volume limit.
For information about how to attach the policy to your API proxy, see Enforce monetization limits on API proxies.
<MonetizationLimitsCheck>
element
Specifies MonetizationLimitsCheck policy.
Default Value | N/A |
Required? | Required |
Type | Complex type |
Parent Element | N/A |
Child Elements |
<DisplayName> <FaultResponse> <IgnoreUnresolvedVariables> <Variables> |
The following table provides a high-level description of the child elements of <MonetizationLimitsCheck>
:
Child Element | Required? | Description |
---|---|---|
<DisplayName> |
Optional | A custom name for the policy. |
<FaultResponse> |
Optional | Specifies the response message returned to the requesting client when the fault is raised. |
<IgnoreUnresolvedVariables> |
Optional | Determines whether processing stops when an unresolved variable is encountered. |
<Variables> |
Optional | Specifies the flow variables to check for the monetization limits. |
The <MonetizationLimitsCheck>
element uses the following syntax:
Syntax
<?xml version="1.0" encoding="UTF-8"?> <MonetizationLimitsCheck async="false" continueOnError="false" enabled="true" name="POLICY_NAME"> <DisplayName>DISPLAY_NAME</DisplayName> <IgnoreUnresolvedVariables>[true|false]</IgnoreUnresolvedVariables> <Variables> <Product>VARIABLE_NAME</Product> </Variables> <FaultResponse> <Set> <Payload contentType="text/xml"> <error> <messages> <message>MESSAGE_TEXT</message> <message>MESSAGE_TEXT</message> </messages> </error> </Payload> <StatusCode>HTTP_STATUS</StatusCode> <ReasonPhrase>REASON_TEXT</ReasonPhrase> </Set> </FaultResponse> </MonetizationLimitsCheck>
Example
The following example shows the MonetizationLimitsCheck policy definition:
<?xml version="1.0" encoding="UTF-8"?> <MonetizationLimitsCheck async="false" continueOnError="false" enabled="true" name="Monetization-Limits-Check"> <DisplayName>Monetization Limits Check</DisplayName> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <Variables> <Product>myproductvar.name</Product> </Variables> <FaultResponse> <Set> <Payload contentType="text/xml"> <error> <messages> <message>Developer has reached usage quota</message> <message>Is Developer Suspended - {monetizationLimits.isDeveloperSuspended} </message> </messages> </error> </Payload> <StatusCode>403</StatusCode> <ReasonPhrase>Forbidden</ReasonPhrase> </Set> </FaultResponse> </MonetizationLimitsCheck>
This element has the following attributes that are common to all policies:
Attribute | Default | Required? | Description |
---|---|---|---|
name |
N/A | Required |
The internal name of the policy. The value of the Optionally, use the |
continueOnError |
false | Optional | Set to "false" to return an error when a policy fails. This is expected behavior for most policies. Set to "true" to have flow execution continue even after a policy fails. |
enabled |
true | Optional | Set to "true" to enforce the policy. Set to "false" to "turn off" the policy. The policy will not be enforced even if it remains attached to a flow. |
async |
false | Deprecated | This attribute is deprecated. |
Child element reference
This section describes the child elements of<MonetizationLimitsCheck>
.
<DisplayName>
Use in addition to the name
attribute to label the policy in the
management UI proxy editor with a different, more natural-sounding name.
The <DisplayName>
element is common to all policies.
Default Value | n/a |
Required? | Optional. If you omit <DisplayName> , the value of the
policy's name attribute is used |
Type | String |
Parent Element | <PolicyElement> |
Child Elements | None |
The <DisplayName>
element uses the following syntax:
Syntax
<PolicyElement> <DisplayName>policy_display_name</DisplayName> ... </PolicyElement>
Example
<PolicyElement> <DisplayName>My Validation Policy</DisplayName> </PolicyElement>
The <DisplayName>
element has no attributes or child elements.
<IgnoreUnresolvedVariables>
Determines whether processing of the policy should stop when Apigee encounters an unresolved variable.
Default Value | True |
Required? | Optional |
Type | Boolean |
Parent Element |
<MonetizationLimitsCheck> |
Child Elements | None |
To ignore unresolved variables and continue processing, set the value to true
;
otherwise false
. The default value is true
.
Setting <IgnoreUnresolvedVariables>
to true
is different from setting the <MonetizationLimitsCheck>
element's
continueOnError
to true
. If you set continueOnError
to true
, Apigee ignores not
only the variable errors but all the errors.
The <IgnoreUnresolvedVariables>
element uses the following syntax:
Syntax
<IgnoreUnresolvedVariables>[true|false]</IgnoreUnresolvedVariables>
Example
The following example sets <IgnoreUnresolvedVariables>
to false
:
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Variables>
Specifies the flow variables from which you want to fetch the entity or resource names during policy execution.
You can specify only the <Product>
element within the <Variables>
element. Apigee gets
the API product name from the flow variable specified in the <Product>
element. If you
don't specify the <Variables>
element, Apigee by default gets the API product name from the
apiproduct.name
context variable. By using the API product name, Apigee gets the
corresponding rate plan for the product and performs the monetization limits check.
Default Value | N/A |
Required? | Optional |
Type | Complex type |
Parent Element |
<MonetizationLimitsCheck> |
Child Elements |
<Product> |
The <Variables>
element uses the following syntax:
Syntax
<Variables> <Product>VARIABLE_NAME</Product> </Variables>
Example
The following example gets the API product name from the myproductvar.name
custom flow variable
present in your API proxy flow.
<Variables> <Product>myproductvar.name</Product> </Variables>
You can set custom flow variables by using policies such as AssignMessage or JavaScript.
<Product>
Specifies the variable having API product name.
Default Value | N/A |
Required? | Optional |
Type | String |
Parent Element |
<Variables> |
Child Elements | None |
The <Product>
element uses the following syntax:
Syntax
<Product>VARIABLE_NAME</Product>
Example
The following example gets the API product name from the myproductvar.name
custom flow variable
present in your API proxy flow.
<Product>myproductvar.name</Product>
You can set custom flow variables by using policies such as AssignMessage or JavaScript.
<FaultResponse>
Defines the response message returned to the requesting client if a fault is raised. You can customize the response messages based on your requirements. For more information about the element and all its child elements, see FaultResponse.
Flow variables
If you set the <MonetizationLimitsCheck>
element's
ContinueOnError
attribute to true, no fault is raised. In this case, the
flow variables, mint.limitsViolated
, mint.isDeveloperSuspended
, and
mint.limitsPolicyError
are automatically set. These variables can be used to
perform further exception handling if required.