How to config quota policy to reset every 1st day of month

If I config quota policy below

<Quota name="QuotaPolicy" type="calendar">
<StartTime>2024-07-1 05:00:00</StartTime>
<Interval>1</Interval>
<TimeUnit>month</TimeUnit>
<Allow count="100"/>
</Quota>

Can apigee detect amount of day in the month? like September has 30 days, October has 31 days.

The quota will reset every 1st day of next month or not?

5 Likes

Hey @pimonnat ,

It seems there’s a bit of a mismatch between what the Apigee documentation states and the actual behavior we observe when using calendar-based quotas.

According to the Apigee docs, the calendar-based quota resets for the month time unit are described as resetting every 28 days. However, the actual behavior follows real calendar months.

When you configure a calendar-based quota with a custom StartTime (as in your case), Apigee calculates the quota period based on the actual calendar month plus the interval from the exact start time. This means:

  • The quota will not reset at midnight on the 1st of the month if a StartTime is defined.
  • The quota will not reset after 28 days are elapsed.

Instead, it will reset exactly one month after the specified StartTime. For example, in your configuration the quota will reset on August 1, 2024, at 5:00 AM, then September 1, 2024, at 5:00 AM, and so on. The start and end times are calculated as one full month after the start.

I hope this clears things up! Let me know if you need any further clarification.

P.S. You may also want to check out how CodeSent can help detect potential misconfigurations in your Quota policy settings. For example, using user-controlled identifiers in Quota policies can lead to bypassing rate limits, unauthorized access, and overuse of resources. CodeSent scans your policy for such misconfigurations and flags them to keep your API secure.

Check out more about insecure quota configuration detection here.

Best,
Nikita

1 Like