ResponseType Class
Supported types of gateway responses.
Example
ts
const api = new apigateway.RestApi(this, 'books-api');
api.addGatewayResponse('test-response', {
type: apigateway.ResponseType.ACCESS_DENIED,
statusCode: '500',
responseHeaders: {
// Note that values must be enclosed within a pair of single quotes
'Access-Control-Allow-Origin': "'test.com'",
'test-key': "'test-value'",
},
templates: {
'application/json': '{ "message": $context.error.messageString, "statusCode": "488", "type": "$context.error.responseType" }'
}
});
Properties
ACCESS_DENIEDResponseTypeaccess_deniedResponseTypeACCESS_DENIEDResponseTypeACCESS_DENIEDResponseTypeACCESS_DENIEDResponseTypestatic#The gateway response for authorization failure.
API_CONFIGURATION_ERRORResponseTypeapi_configuration_errorResponseTypeAPI_CONFIGURATION_ERRORResponseTypeAPI_CONFIGURATION_ERRORResponseTypeAPI_CONFIGURATION_ERRORResponseTypestatic#The gateway response for an invalid API configuration.
AUTHORIZER_CONFIGURATION_ERRORResponseTypeauthorizer_configuration_errorResponseTypeAUTHORIZER_CONFIGURATION_ERRORResponseTypeAUTHORIZER_CONFIGURATION_ERRORResponseTypeAUTHORIZER_CONFIGURATION_ERRORResponseTypestatic#The gateway response for failing to connect to a custom or Amazon Cognito authorizer.
AUTHORIZER_FAILUREResponseTypeauthorizer_failureResponseTypeAUTHORIZER_FAILUREResponseTypeAUTHORIZER_FAILUREResponseTypeAUTHORIZER_FAILUREResponseTypestatic#The gateway response when a custom or Amazon Cognito authorizer failed to authenticate the caller.
BAD_REQUEST_BODYResponseTypebad_request_bodyResponseTypeBAD_REQUEST_BODYResponseTypeBAD_REQUEST_BODYResponseTypeBAD_REQUEST_BODYResponseTypestatic#The gateway response when the request body cannot be validated according to an enabled request validator.
BAD_REQUEST_PARAMETERSResponseTypebad_request_parametersResponseTypeBAD_REQUEST_PARAMETERSResponseTypeBAD_REQUEST_PARAMETERSResponseTypeBAD_REQUEST_PARAMETERSResponseTypestatic#The gateway response when the request parameter cannot be validated according to an enabled request validator.
DEFAULT_4XXResponseTypedefault_4_xxResponseTypeDEFAULT_4XXResponseTypeDEFAULT_4XXResponseTypeDEFAULT_4XXResponseTypestatic#The default gateway response for an unspecified response type with the status code of 4XX.
DEFAULT_5XXResponseTypedefault_5_xxResponseTypeDEFAULT_5XXResponseTypeDEFAULT_5XXResponseTypeDEFAULT_5XXResponseTypestatic#The default gateway response for an unspecified response type with a status code of 5XX.
EXPIRED_TOKENResponseTypeexpired_tokenResponseTypeEXPIRED_TOKENResponseTypeEXPIRED_TOKENResponseTypeEXPIRED_TOKENResponseTypestatic#The gateway response for an AWS authentication token expired error.
INTEGRATION_FAILUREResponseTypeintegration_failureResponseTypeINTEGRATION_FAILUREResponseTypeINTEGRATION_FAILUREResponseTypeINTEGRATION_FAILUREResponseTypestatic#The gateway response for an integration failed error.
INTEGRATION_TIMEOUTResponseTypeintegration_timeoutResponseTypeINTEGRATION_TIMEOUTResponseTypeINTEGRATION_TIMEOUTResponseTypeINTEGRATION_TIMEOUTResponseTypestatic#The gateway response for an integration timed out error.
INVALID_API_KEYResponseTypeinvalid_api_keyResponseTypeINVALID_API_KEYResponseTypeINVALID_API_KEYResponseTypeINVALID_API_KEYResponseTypestatic#The gateway response for an invalid API key submitted for a method requiring an API key.
INVALID_SIGNATUREResponseTypeinvalid_signatureResponseTypeINVALID_SIGNATUREResponseTypeINVALID_SIGNATUREResponseTypeINVALID_SIGNATUREResponseTypestatic#The gateway response for an invalid AWS signature error.
MISSING_AUTHENTICATION_TOKENResponseTypemissing_authentication_tokenResponseTypeMISSING_AUTHENTICATION_TOKENResponseTypeMISSING_AUTHENTICATION_TOKENResponseTypeMISSING_AUTHENTICATION_TOKENResponseTypestatic#The gateway response for a missing authentication token error, including the cases when the client attempts to invoke an unsupported API method or resource.
QUOTA_EXCEEDEDResponseTypequota_exceededResponseTypeQUOTA_EXCEEDEDResponseTypeQUOTA_EXCEEDEDResponseTypeQUOTA_EXCEEDEDResponseTypestatic#The gateway response for the usage plan quota exceeded error.
REQUEST_TOO_LARGEResponseTyperequest_too_largeResponseTypeREQUEST_TOO_LARGEResponseTypeREQUEST_TOO_LARGEResponseTypeREQUEST_TOO_LARGEResponseTypestatic#The gateway response for the request too large error.
RESOURCE_NOT_FOUNDResponseTyperesource_not_foundResponseTypeRESOURCE_NOT_FOUNDResponseTypeRESOURCE_NOT_FOUNDResponseTypeRESOURCE_NOT_FOUNDResponseTypestatic#The gateway response when API Gateway cannot find the specified resource after an API request passes authentication and authorization.
Valid value of response type.
THROTTLEDResponseTypethrottledResponseTypeTHROTTLEDResponseTypeTHROTTLEDResponseTypeTHROTTLEDResponseTypestatic#The gateway response when usage plan, method, stage, or account level throttling limits exceeded.
UNAUTHORIZEDResponseTypeunauthorizedResponseTypeUNAUTHORIZEDResponseTypeUNAUTHORIZEDResponseTypeUNAUTHORIZEDResponseTypestatic#The gateway response when the custom or Amazon Cognito authorizer failed to authenticate the caller.
UNSUPPORTED_MEDIA_TYPEResponseTypeunsupported_media_typeResponseTypeUNSUPPORTED_MEDIA_TYPEResponseTypeUNSUPPORTED_MEDIA_TYPEResponseTypeUNSUPPORTED_MEDIA_TYPEResponseTypestatic#The gateway response when a payload is of an unsupported media type, if strict passthrough behavior is enabled.
WAF_FILTEREDResponseTypewaf_filteredResponseTypeWAF_FILTEREDResponseTypeWAF_FILTEREDResponseTypeWAF_FILTEREDResponseTypestatic#The gateway response when a request is blocked by AWS WAF.
Methods
of(type: string): ResponseType // chainable@staticmethod def of(type: str) -> ResponseTypepublic static ResponseType of(String type)public static ResponseType Of(string type)func Of(Type *string) ResponseTypestatic#A custom response type to support future cases.