Search⌘ K

Customising Responses

Explore how to customize HTTP responses in AWS Lambda with API Gateway by formatting JSON objects correctly and sending HTML pages. Understand how to set response headers and troubleshoot gateway integrations. This lesson helps you build interactive web forms using Lambda functions while learning best practices and deployment tips for serverless applications.

API Gateway expects responses in a specific format from Lambda Proxy integrations. The response needs to be a JSON object containing these fields:

  • statusCode should be a number containing the numeric HTTP response code. The number 200 means OK.
  • body should be a string representing the response contents.
  • headers is an optional argument​ and can contain a map of HTTP response headers.

SAM assumes that you’ll use API Gateway to create JSON APIs, so unless the response provides a content type, it assumes that you’ll be sending back a serialised JSON ...