# Quota
The Quota policy defines the number of request messages an application can submit to an API over a given period of time.
The period of time can be an hour, a day, or a month and so on. You can apply this policy on the context of request messages.
The Quota policy helps API Providers to restrict the number of calls made to an API. For example, you can restrict access to your applications by defining the number of API calls made as 20 per day or 20,000 over a period of one week.
API Management maintains a counter that keeps track of the number of calls made to the API. Once the counter reaches the Quota limit, all successive calls made to the API are rejected. API Management returns an error message to an API-call made after the Quota limit is exceeded. The Quota policy provides the capability to reset the counters automatically after the stipulated period of time, unless it is explicitly reset by using the Reset Quota policy.
During the policy execution, the following errors can occur:
|
Error Name
|
Cause
|
|
FailedToResolveQuotaIntervalReference
|
Occurs if the **** element is not defined within the **Quota** policy. This element is mandatory and used to specify the interval of time applicable to the quota. The time interval can be minutes, hours, days, weeks, or months as defined with the **** element.
|
|
FailedToResolveQuotaIntervalTimeUnitReference
|
Occurs if the **** element is not defined within the **Quota** policy. This element is mandatory and used to specify the unit of time applicable to the quota. The time interval can be in minutes, hours, days, weeks, or months.
|
|
InvalidMessageWeight
|
Occurs if the value of the **** element specified through a flow variable is invalid \(a non-integer value\).
|
|
QuotaViolation
|
The quota limit was exceeded.
|
**Deployment Errors**
|
Error Name
|
Cause
|
|
InvalidQuotaInterval
|
If the quota interval specified in the **** element is not an integer, then the deployment of the API proxy fails. For example, if the quota interval specified is 0.1 in the **** element, then the deployment of the API proxy fails.
|
|
InvalidQuotaTimeUnit
|
If the time unit specified in the **** element is unsupported, then the deployment of the API proxy fails. The supported time units are **minute**, **hour**, **day**, **week**, and **month**.
|
|
InvalidQuotaType
|
If the type of the quota specified by the type attribute in the **** element is invalid, then the deployment of the API proxy fails. The supported quota types are **default**, **calendar**, **flexi**, and **rollingwindow**.
|
|
InvalidStartTime
|
If the format of the time specified in the **** element is invalid, then the deployment of the API proxy fails. The valid format is **yyyy-MM-dd HH:mm:ss**, which is the ISO 8601 date and time format. For example, if the time specified in the **** element is **7-16-2017 12:00:00**, then the deployment of the API proxy fails.
|
|
StartTimeNotSupported
|
If the **** element is specified whose quota type is not **calendar** type, then the deployment of the API proxy fails. The **** element is supported only for the calendar quota type. For example, if the type attribute is set to **flexi** or **rolling window** in the **** element, then the deployment of the API proxy fails.
|
|
InvalidTimeUnitForDistributedQuota
|
If the **** element is set to **true** and the **** element is set to **second**, then the deployment of the API proxy fails. The timeunit **second** is invalid for a distributed quota.
|
|
InvalidSynchronizeIntervalForAsyncConfiguration
|
If the value specified for the **** element within the **** element in a **Quota** policy is less than zero, then the deployment of the API proxy fails.
|
|
InvalidAsynchronizeConfigurationForSynchronousQuota
|
If the value of the **** element is set to **true** in a **Quota** policy, which also has asynchronous configuration defined using the **** element, then the deployment of the API proxy fails.
|
Following fault variables are set when the policy triggers an error at runtime: