Claude
Skills
Sign in
Back

api-gateway

Included with Lifetime
$97 forever

Build, manage, and operate APIs with Amazon API Gateway (REST, HTTP, and WebSocket). Triggers on phrases like: API Gateway, REST API, HTTP API, WebSocket API, custom domain, Lambda authorizer, usage plan, throttling, CORS, VPC link, private API. Also covers troubleshooting API Gateway errors (4xx, 5xx, timeout, CORS failures) and IaC templates containing API Gateway resources. For general REST API design unrelated to AWS, do not trigger.

Design

What this skill does


# Amazon API Gateway Development

Expert guidance for building, managing, governing, and operating APIs with Amazon API Gateway. Covers REST APIs (v1), HTTP APIs (v2), and WebSocket APIs.

## How to Use This Skill

When answering API Gateway questions:

1. Read the relevant reference file(s) before responding, do not rely solely on this summary
2. For tasks spanning multiple concerns (e.g., "private API with mTLS and custom domain"), read all relevant references
3. When the user needs IaC templates, consult `references/sam-cloudformation.md` or `references/sam-service-integrations.md` and provide complete, working SAM/CloudFormation YAML
4. Always mention relevant pitfalls and limits that affect the user's design

## Quick Decision: Which API Type?

Choose the right API type first. This decision affects every downstream choice.

**REST API** is the full-featured API management platform for enterprises. It provides the governance, security, monetization, and operational controls that organizations need to build, publish, and manage APIs at scale, including usage plans with per-consumer throttling and quotas, API keys, request validation, WAF integration, resource policies, caching, canary deployments, and private endpoints.

**HTTP API** is the lightweight, low-cost proxy optimized for simpler API workloads. It offers ~70% lower cost and lower latency but trades away the API management features. Choose HTTP API when you need a fast, lightweight proxy to Lambda or HTTP backends and don't require the enterprise controls above.

| Factor                    | REST API (v1)                          | HTTP API (v2)                                  | WebSocket API                  |
| ------------------------- | -------------------------------------- | ---------------------------------------------- | ------------------------------ |
| **Positioning**           | **Full API management**                | **Low-cost proxy**                             | **Real-time bidirectional**    |
| Cost                      | Higher                                 | ~70% cheaper                                   | Per-message pricing            |
| Latency                   | Higher                                 | Lower                                          | Persistent connection          |
| Max timeout               | 50ms-29s (up to 300s Regional/Private) | 30s hard limit                                 | 29s                            |
| Payload                   | 10 MB                                  | 10 MB                                          | 128 KB message / 32 KB frame   |
| **API Management**        |                                        |                                                |                                |
| Usage plans/API keys      | Yes                                    | No                                             | No                             |
| Request validation        | Yes (JSON Schema draft 4)              | No                                             | No                             |
| Caching                   | Yes (0.5-237 GB)                       | No                                             | No                             |
| Custom gateway responses  | Yes                                    | No                                             | No                             |
| VTL mapping templates     | Yes                                    | No (parameter mapping only)                    | Yes                            |
| **Security & Governance** |                                        |                                                |                                |
| WAF                       | Yes                                    | No (use CloudFront + WAF)                      | No                             |
| Resource policies         | Yes                                    | No                                             | No                             |
| Private endpoints         | Yes                                    | No                                             | No                             |
| mTLS                      | Yes (Regional custom domain only)      | Yes (Regional custom domain only)              | Via CloudFront viewer mTLS     |
| **Auth**                  |                                        |                                                |                                |
| Lambda authorizer         | Yes (TOKEN + REQUEST)                  | Yes (REQUEST only, simple + IAM policy format) | Yes (REQUEST on $connect only) |
| JWT authorizer            | No (use Cognito authorizer)            | Yes (native)                                   | No                             |
| Cognito authorizer        | Yes (native)                           | Use JWT authorizer                             | No                             |
| **Operations**            |                                        |                                                |                                |
| Canary deployments        | Yes                                    | No                                             | No                             |
| Response streaming        | Yes                                    | No                                             | No                             |
| X-Ray tracing             | Yes                                    | No                                             | No                             |
| Execution logging         | Yes                                    | No                                             | Yes                            |
| Custom domain sharing     | Not with WebSocket                     | Not with WebSocket                             | Not with REST/HTTP             |

**Use REST API when**: you are building APIs for external consumers, partners, or multi-tenant platforms; need to enforce per-consumer rate limits and quotas; require request validation, caching, or WAF at the API layer; need private endpoints, resource policies, or canary deployments; or are building an API product with monetization and governance requirements.

**Use HTTP API when**: you are building lightweight APIs or simple backend proxies; cost and latency are the primary concerns; you don't need per-consumer throttling, request validation, caching, or WAF at the API layer; and native JWT authorization with OIDC/OAuth 2.0 meets your auth needs. Accept the hard 30s timeout and lack of API management features. For WAF, edge caching, or edge compute, place a CloudFront distribution in front of the HTTP API.

**Use WebSocket API when you need**: persistent bidirectional connections for real-time use cases (chat, notifications, live dashboards).

## Instructions

### Step 1: Design the API

Before implementation, gather requirements systematically. Consult `references/requirements-gathering.md` for the full requirements workflow covering endpoints, auth, data models, performance, security, and deployment needs.

Key design decisions:

1. **API type**: Use the decision table above
2. **Endpoint type**: Edge-optimized (default for global clients; optimizes TCP connections via CloudFront POPs but does not cache at the edge), Regional (same-region clients, or global clients needing their own CloudFront distribution for edge caching, edge compute, granular WAF control, or geo-based routing), Private (VPC-only access, REST API only)
3. **Topology**: Centralized (single domain, path-based routing) vs Distributed (subdomains per service)
4. **Authentication**: See `references/authentication.md` for the decision tree

### Step 2: Implement the API

Consult these references based on what you're building:

- **Architecture patterns**: `references/architecture-patterns.md`: topology, multi-tenant SaaS, hybrid workloads, private APIs, multi-region, streaming
- **WebSocket API**: `references/websocket.md`: route selection, @connections ma

Related in Design