How to make a conditional flow based on Quota Policy results?

The case is, there is a requirement to make a service callout when a certain user has called the API for 50 times.

The way that i am thinking is to make a quota policy, and when the quota policy fail, it will trigger a conditional flow.

My question is:

How to make a conditional flow that is triggered when the previous quota policy failed/reach its limit?

thanks for your answer

Regards,

Lightning

Solved Solved
0 4 341
1 ACCEPTED SOLUTION

Hi @Lightning , what is the functionality of Service Callout? Is it for logging/notifying/anything else?

Generally, when a policy fails, the proxy will enter error flow. Based on error condition we can make use of Fault Rules.

Within Fault Rules we can use the Service Callout policy.

View solution in original post

4 REPLIES 4

Hi @Lightning , what is the functionality of Service Callout? Is it for logging/notifying/anything else?

Generally, when a policy fails, the proxy will enter error flow. Based on error condition we can make use of Fault Rules.

Within Fault Rules we can use the Service Callout policy.

Hi @Siddharth Barahalikar,

Thanks for answering 🙂

The service callout is used to check to an external source, whether the user has still valid subscription plan. The validity of the subscription plan is checked every 50th call of the API per user. If the plan is still valid then the flow will continue to the target server. I've managed to handle the service callout part. However, i'm still struggling on how to do the service callout only on every 50th call of the API.

Based on your answer, is it possible to exit the error flow and return to the normal flow after doing the service callout?

Regards,

Lightning

Well, once the flow enters error.flow you cannot come out of it. Are you using Quota Policy for any other usecase?

Maybe we can use the Quota flow variable from Trace session and use them as a Condition for Service Callout Policy.

Use this ratelimit.{policy_name}.used.count variable to get the quota value and set a condition

<Condition>ratelimit.{policy_name}.used.count = 50</Condition>

Also check, ratelimit.{policy_name}.class.used.count

https://docs.apigee.com/api-platform/reference/policies/quota-policy#variables

thanks buddy, your answer worked 🙂

Regards,

Lightning