• Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Updated March 2026

The Ultimate Guide to
Amazon API Gateway

Amazon API Gateway is a fully managed service for creating HTTP and WebSocket APIs. It connects your API endpoints to backend services like AWS Lambda, replacing traditional API servers with a serverless, auto-scaling solution.

Build a Serverless APIRead the Docs

API Gateway Key Features

API Gateway replaces your API server with a managed service that handles routing, auth, throttling, and monitoring out of the box.

Core

HTTP & WebSocket Routing

Define REST, HTTP, or WebSocket endpoints and map them to backend services. Supports path parameters, query strings, headers, and request/response transformations.

Compute

Lambda Integration

Trigger Lambda functions directly from HTTP requests. Lambda Proxy integration passes the full request payload to your function with zero configuration.

Security

Authentication & Authorization

Built-in support for Amazon Cognito, Lambda custom authorizers, IAM roles, and JWT-based auth. No need to build your own auth system.

Networking

Custom Domains & SSL

Map your own domain names with SSL certificates from AWS Certificate Manager. Use base path mappings to host multiple APIs on one domain.

Architecture

Microservice Composition

Different Lambda functions serve different API endpoints. Replace individual functions transparently without affecting the rest of the API.

Operations

Throttling & Usage Plans

Rate limiting, burst control, and API keys for consumer management. Create usage plans to meter and monetize your APIs.

How API Gateway Works

API Gateway sits between your API consumers and your backend services, handling the HTTP lifecycle so you don't have to run API servers.

1

Receive

A client sends an HTTP or WebSocket request. API Gateway validates the request, runs authorizers, and applies throttling rules.

2

Route

The request is matched to an endpoint definition and forwarded to the configured backend: a Lambda function, HTTP endpoint, or AWS service.

3

Respond

The backend returns a response. API Gateway transforms it if needed, applies CORS headers, and sends it back to the client.

AWS Service Integrations

API Gateway connects directly with many AWS services, not just Lambda:

AWS Lambda

Run functions to generate API responses. The most common integration for serverless applications.

Amazon SNS

Publish notifications when API endpoints are accessed. Useful for webhooks and event fanout.

Amazon Cognito

Fully managed authentication and authorization for your APIs without custom auth code.

AWS Step Functions

Start state machine workflows directly from API requests for complex, multi-step operations.

Amazon S3

Serve static content or proxy file uploads directly through API Gateway without Lambda.

Any HTTP endpoint

Proxy requests to any public or VPC-internal HTTP service, with or without VPC Link.

Using API Gateway with the Serverless Framework

The Serverless Framework uses Lambda Proxy integration to pass the full API Gateway request payload to your function. Define your API endpoints directly in serverless.yml:

serverless.yml
service: my-api

provider:
  name: aws
  runtime: nodejs22.x

functions:
  # REST API endpoint
  getUsers:
    handler: handler.getUsers
    events:
      - httpApi:
          path: /users
          method: get

  # With path parameters
  getUser:
    handler: handler.getUser
    events:
      - httpApi:
          path: /users/{id}
          method: get

  # WebSocket API
  connectHandler:
    handler: handler.connect
    events:
      - websocket: $connect

The framework handles all CloudFormation resource creation: API Gateway configuration, Lambda permissions, IAM roles, and deployment stages. It also supports custom authorizers, request validation, usage plans, and custom domain names.

REST API vs. HTTP API

AWS offers two types of API Gateway APIs. For most serverless applications, HTTP APIs are the better choice.

FeatureREST APIHTTP API
Cost$3.50 / 1M requests$1.00 / 1M requests
LatencyHigherUp to 60% lower
JWT authVia Lambda authorizerNative support
Request validationYesNo
WAF integrationYesNo
Usage plans / API keysYesNo
CachingYesNo
Private APIs (VPC)YesNo

See our Ultimate Guide to AWS HTTP APIs for a deeper comparison.

Benefits of API Gateway

Truly Serverless APIs

API Gateway eliminates the need for dedicated API servers entirely. Map HTTP requests directly to Lambda functions. Each endpoint is an independent, auto-scaling unit. Combined with other AWS services, you can build fully functional web applications without maintaining a single server.

Microservice Composition

Different Lambda functions can serve different parts of your API, encapsulating functionality cleanly. You can replace the function behind any endpoint transparently without consumers noticing. This enables independent deployment and scaling of each API segment.

Managed Auth & Monitoring

Authentication via Cognito or custom Lambda authorizers, without building your own auth system. Auto-generated developer portals from your API schema. CloudTrail for audit logging, CloudWatch for metrics and alarms, X-Ray for distributed tracing, all integrated out of the box.

WebSocket Support

Build real-time applications with WebSocket APIs. Map connection, disconnection, and message events to Lambda functions for in-app updates, notifications, chat, and live data streaming, all serverless and auto-scaling.

Trade-offs & Limitations

API Gateway is the right choice for most serverless APIs, but these constraints are worth understanding upfront.

Added latency

API Gateway adds milliseconds to response times. For most applications this is negligible, but if you're building ultra-low-latency APIs, this overhead matters. HTTP APIs are ~60% faster than REST APIs.

No performance tuning

As a fully managed service, AWS doesn't expose performance parameters. You can't tweak connection pooling, keep-alive settings, or buffer sizes.

29-second timeout

Backend integrations must respond within 29 seconds. For long-running operations, use an async pattern: accept the request, return a job ID, and let the client poll for results.

10 MB payload limit

Responses are capped at 10 MB (Lambda itself caps at 6 MB synchronously). For large payloads, use S3 presigned URLs.

600 regional APIs per account

Most teams won't hit this, but large organizations with many development teams may need multiple AWS accounts.

API Gateway Pricing

API Gateway pricing is based on the number of API calls, plus data transfer. HTTP APIs are significantly cheaper than REST APIs.

Free Tier (First 12 Months)

1M

REST API calls / month

1M

HTTP API calls / month

1M

WebSocket messages / month

ServicePrice
HTTP API calls$1.00 – $1.17 / 1M requests
REST API calls$1.51 – $3.50 / 1M requests
REST API caching$0.02 – $3.80 / hour (by cache size)
WebSocket messages$0.80 – $1.00 / 1M messages
WebSocket connection minutes$0.25 / 1M minutes

Example: 10,000 users, 10,000 requests/month each

100M requests × $1.00/1M (HTTP API) = $100/month

100M requests × $3.50/1M (REST API) = $350/month

Plus Lambda compute costs for generating responses. Most teams save 60–70% by using HTTP APIs.

See the official API Gateway pricing page for current regional rates.

When to Use API Gateway

Use API Gateway whenyou're building serverless HTTP or WebSocket APIs, need managed auth and throttling, want automatic scaling without maintaining API servers, or are composing microservices behind a unified API layer.

Consider alternatives when you need ultra-low-latency request routing (consider running your own reverse proxy), want fine-grained control over HTTP processing, or are building a GraphQL API (look at AWS AppSync instead). For simple Lambda HTTP endpoints without the full feature set, Lambda Function URLs are a free, simpler option.

Learn More

Documentation

  • API Gateway Event Docs
  • AWS HTTP APIs Guide
  • AWS Lambda Guide
  • AWS API Gateway Docs

Related Guides

  • Amazon CloudFront (CDN)
  • AWS AppSync (GraphQL)
  • Amazon DynamoDB
  • Browse all guides

API Gateway FAQ

Common questions about Amazon API Gateway.

What is Amazon API Gateway?
Amazon API Gateway is a fully managed AWS service that lets you create, publish, and manage REST, HTTP, and WebSocket APIs at any scale. It handles routing, authentication, throttling, and monitoring, replacing the need for dedicated API servers.
What is the difference between REST API and HTTP API in API Gateway?
HTTP APIs are the newer, simpler option: up to 71% cheaper and 60% lower latency than REST APIs. REST APIs offer more features like request validation, WAF integration, and usage plans. For most new serverless applications, HTTP APIs are the better choice.
How much does API Gateway cost?
REST APIs cost $1.51–$3.50 per million requests depending on region. HTTP APIs cost $1.00–$1.17 per million, significantly cheaper. The free tier includes 1 million REST API calls per month for the first 12 months. WebSocket APIs cost $0.80–$1.00 per million messages.
What is the maximum timeout for API Gateway?
The integration timeout ranges from 50ms to 29 seconds. This is a hard limit. If your backend takes longer than 29 seconds, the request will fail. For long-running operations, use asynchronous patterns (return immediately, process in background).
What is the maximum payload size?
API Gateway can return payloads up to 10 MB. For larger responses, store the data in S3 and return a signed URL. Lambda itself has a 6 MB synchronous payload limit, which is the practical ceiling when using Lambda as the backend.
Can I use a custom domain with API Gateway?
Yes. API Gateway supports custom domain names with SSL certificates from AWS Certificate Manager. You can map multiple APIs to the same domain using base path mappings. The Serverless Framework has built-in support for custom domains.
Do I need API Gateway to use Lambda?
No. Lambda can be triggered by many event sources without API Gateway, including S3, DynamoDB, SQS, SNS, and EventBridge. For HTTP endpoints specifically, you can also use Lambda Function URLs, which provide a simpler, free alternative for basic use cases.

Build Your First Serverless API

Deploy an API Gateway + Lambda endpoint in minutes with the Serverless Framework.

Get Started FreeView Documentation