Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

x-amazon-apigateway-gateway-responses.responseTemplates object

Focus mode
x-amazon-apigateway-gateway-responses.responseTemplates object - Amazon API Gateway

Defines GatewayResponse mapping templates, as a string-to-string map of key-value pairs, for a given gateway response. For each key-value pair, the key is the content type. For example, "application/json" and the value is a stringified mapping template for simple variable substitutions. A GatewayResponse mapping template isn't processed by the Velocity Template Language (VTL) engine.

Property name Type Description
content-type string

A GatewayResponse body mapping template supporting only simple variable substitution to customize a gateway response body.

x-amazon-apigateway-gateway-responses.responseTemplates example

The following OpenAPI extensions example shows a GatewayResponse mapping template to customize an API Gateway–generated error response into an app-specific format.

"responseTemplates": { "application/json": "{ \"message\": $context.error.messageString, \"type\":$context.error.responseType, \"statusCode\": '488' }" }

The following OpenAPI extensions example shows a GatewayResponse mapping template to override an API Gateway–generated error response with a static error message.

"responseTemplates": { "application/json": "{ \"message\": 'API-specific errors' }" }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.