# 413 Request Entity Too Large: Request size exceeds the maximum allowed limit for the API Gateway.

- **ID:** `api/api-gateway-request-too-large`
- **Domain:** api
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

HTTP request body or headers exceed the size limit configured on the API gateway (e.g., AWS API Gateway 10MB, NGINX 1MB).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| AWS API Gateway REST API | active | — | — |
| NGINX 1.24 | active | — | — |
| Azure API Management | active | — | — |

## Workarounds

1. **Increase the maximum request size on the gateway. For NGINX: add 'client_max_body_size 20M;' in the http or server block. For AWS API Gateway, increase the payload limit to 10MB (maximum) or use binary media types.** (90% success)
   ```
   Increase the maximum request size on the gateway. For NGINX: add 'client_max_body_size 20M;' in the http or server block. For AWS API Gateway, increase the payload limit to 10MB (maximum) or use binary media types.
   ```
2. **Split large payloads into chunks using multipart upload or paginated API calls. Example: POST /upload with 'Content-Range: bytes 0-1048575/5242880' header.** (80% success)
   ```
   Split large payloads into chunks using multipart upload or paginated API calls. Example: POST /upload with 'Content-Range: bytes 0-1048575/5242880' header.
   ```
3. **Use a direct upload to cloud storage (e.g., S3 presigned URL) and pass only the reference (URL) in the API request.** (85% success)
   ```
   Use a direct upload to cloud storage (e.g., S3 presigned URL) and pass only the reference (URL) in the API request.
   ```

## Dead Ends

- **** — Increasing client-side timeout without reducing payload size does not resolve the 413 error, as the gateway rejects the request before it reaches the backend. (85% fail)
- **** — Adding compression headers (e.g., gzip) but sending uncompressed large payload still triggers the limit because the gateway checks raw size before decompression. (70% fail)
