Course contentsShow
← Cloud and Infrastructure
Lesson 540 of 2,98910. API Gateway and Event-Driven PatternsFree lesson

API Keys and Usage Plans

Manage API access through API keys and associate them with usage plans for tiered access control.

API Keys and Usage Plans

You'll learn how to manage API access by issuing keys and grouping them into usage plans that enforce different access tiers.

What Are API Keys?

An API key is a unique string that identifies who's calling your API. Think of it like a membership card — each client gets their own, and you can track who's making requests. Unlike authentication tokens, API keys don't prove identity but serve as a simple identifier for tracking and basic access control.

When a client calls your API Gateway, they include the key in the request header (like x-api-key). The gateway checks if it's valid before forwarding the request.

What Are Usage Plans?

A usage plan bundles API keys together with access rules:

  • Rate limits: How many requests per second a client can make (e.g., 100 requests/second)
  • Quota limits: Total requests allowed over a time period (e.g., 10,000 requests/day)
  • API stages: Which deployment stages (like "dev" or "prod") this plan can access

The Relationship

You create a usage plan, then associate one or more API keys with it. This creates tiered access:

  • Free tier: 1,000 requests/day, 10 requests/second
  • Premium tier: 100,000 requests/day, 100 requests/second
  • Enterprise tier: Unlimited requests, 1,000 requests/second

Each tier has its own usage plan. When clients exceed their limits, they receive 429 Too Many Requests errors.

Why Use Them?

Usage plans let you monetize APIs, prevent abuse, and manage resources efficiently. They work alongside throttling (from earlier lessons) but provide per-customer granularity instead of blanket limits.

Key Takeaway: API keys identify callers, while usage plans enforce tiered rate/quota limits — together they enable controlled, measurable API access across different customer segments.