What Is an API Key?
An API key is an alphanumeric string provided to application developers or users to authenticate, control, and monitor access to your API. By including the API key in API requests, you can track the source of each request and enforce security measures. The typical method is to include the key in the header, such as:X-API-Key is commonly used and is expected by API Gateway to authenticate requests.
Introduction to Usage Plans
A usage plan in AWS API Gateway establishes rules for who can access one or more deployed APIs. It defines parameters like:- The maximum number of requests allowed.
- The rate at which users can call the API.
- The burst capacity to handle short-term spikes in traffic.
- Up to 100 requests per second with occasional bursts to 20 requests over short periods.
- A total monthly quota of 10 requests.

API Keys and Usage Plans Together
When you create an API key, you associate it with a specific usage plan. This linkage means that every request made with that API key will adhere to the defined throttling and rate limits. API Gateways use these limits to regulate traffic to the backend services. For instance, if a usage plan allows 100 requests per minute, any client remaining within that limit will experience normal operation. However, if requests exceed 100 per minute, the API Gateway issues an HTTP 429 error—indicating too many requests—and throttles the client.
Remember that coupling API keys with usage plans not only secures your API but also allows you to monitor and manage traffic effectively.
Handling Request Throttling
When a user exceeds the allowed rate limit, the API Gateway responds with a 429 error. An example of such a response is:
Example of Multiple Usage Plans
Organizations often implement different usage plans for varied levels of user access. Consider the following tiers:| Tier | Allowed Requests per Second | Description |
|---|---|---|
| Free Tier | 100 | Suitable for basic access with limited throughput. |
| Gold Tier | 500 | Increased capacity for high-demand applications. |

Different plans offer tailored access levels. Ensure that your users understand their plan limits to avoid unexpected throttling.