aws-cdk-lib.aws_apigateway.ResponseType

class ResponseType

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.ResponseType
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#ResponseType
Javasoftware.amazon.awscdk.services.apigateway.ResponseType
Pythonaws_cdk.aws_apigateway.ResponseType
TypeScript (source)aws-cdk-lib » aws_apigateway » ResponseType

Supported types of gateway responses.

See also: https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html

Example

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

NameTypeDescription
responseTypestringValid value of response type.
static ACCESS_DENIEDResponseTypeThe gateway response for authorization failure.
static API_CONFIGURATION_ERRORResponseTypeThe gateway response for an invalid API configuration.
static AUTHORIZER_CONFIGURATION_ERRORResponseTypeThe gateway response for failing to connect to a custom or Amazon Cognito authorizer.
static AUTHORIZER_FAILUREResponseTypeThe gateway response when a custom or Amazon Cognito authorizer failed to authenticate the caller.
static BAD_REQUEST_BODYResponseTypeThe gateway response when the request body cannot be validated according to an enabled request validator.
static BAD_REQUEST_PARAMETERSResponseTypeThe gateway response when the request parameter cannot be validated according to an enabled request validator.
static DEFAULT_4XXResponseTypeThe default gateway response for an unspecified response type with the status code of 4XX.
static DEFAULT_5XXResponseTypeThe default gateway response for an unspecified response type with a status code of 5XX.
static EXPIRED_TOKENResponseTypeThe gateway response for an AWS authentication token expired error.
static INTEGRATION_FAILUREResponseTypeThe gateway response for an integration failed error.
static INTEGRATION_TIMEOUTResponseTypeThe gateway response for an integration timed out error.
static INVALID_API_KEYResponseTypeThe gateway response for an invalid API key submitted for a method requiring an API key.
static INVALID_SIGNATUREResponseTypeThe gateway response for an invalid AWS signature error.
static MISSING_AUTHENTICATION_TOKENResponseTypeThe gateway response for a missing authentication token error, including the cases when the client attempts to invoke an unsupported API method or resource.
static QUOTA_EXCEEDEDResponseTypeThe gateway response for the usage plan quota exceeded error.
static REQUEST_TOO_LARGEResponseTypeThe gateway response for the request too large error.
static RESOURCE_NOT_FOUNDResponseTypeThe gateway response when API Gateway cannot find the specified resource after an API request passes authentication and authorization.
static THROTTLEDResponseTypeThe gateway response when usage plan, method, stage, or account level throttling limits exceeded.
static UNAUTHORIZEDResponseTypeThe gateway response when the custom or Amazon Cognito authorizer failed to authenticate the caller.
static UNSUPPORTED_MEDIA_TYPEResponseTypeThe gateway response when a payload is of an unsupported media type, if strict passthrough behavior is enabled.
static WAF_FILTEREDResponseTypeThe gateway response when a request is blocked by AWS WAF.

responseType

Type: string

Valid value of response type.


static ACCESS_DENIED

Type: ResponseType

The gateway response for authorization failure.


static API_CONFIGURATION_ERROR

Type: ResponseType

The gateway response for an invalid API configuration.


static AUTHORIZER_CONFIGURATION_ERROR

Type: ResponseType

The gateway response for failing to connect to a custom or Amazon Cognito authorizer.


static AUTHORIZER_FAILURE

Type: ResponseType

The gateway response when a custom or Amazon Cognito authorizer failed to authenticate the caller.


static BAD_REQUEST_BODY

Type: ResponseType

The gateway response when the request body cannot be validated according to an enabled request validator.


static BAD_REQUEST_PARAMETERS

Type: ResponseType

The gateway response when the request parameter cannot be validated according to an enabled request validator.


static DEFAULT_4XX

Type: ResponseType

The default gateway response for an unspecified response type with the status code of 4XX.


static DEFAULT_5XX

Type: ResponseType

The default gateway response for an unspecified response type with a status code of 5XX.


static EXPIRED_TOKEN

Type: ResponseType

The gateway response for an AWS authentication token expired error.


static INTEGRATION_FAILURE

Type: ResponseType

The gateway response for an integration failed error.


static INTEGRATION_TIMEOUT

Type: ResponseType

The gateway response for an integration timed out error.


static INVALID_API_KEY

Type: ResponseType

The gateway response for an invalid API key submitted for a method requiring an API key.


static INVALID_SIGNATURE

Type: ResponseType

The gateway response for an invalid AWS signature error.


static MISSING_AUTHENTICATION_TOKEN

Type: ResponseType

The gateway response for a missing authentication token error, including the cases when the client attempts to invoke an unsupported API method or resource.


static QUOTA_EXCEEDED

Type: ResponseType

The gateway response for the usage plan quota exceeded error.


static REQUEST_TOO_LARGE

Type: ResponseType

The gateway response for the request too large error.


static RESOURCE_NOT_FOUND

Type: ResponseType

The gateway response when API Gateway cannot find the specified resource after an API request passes authentication and authorization.


static THROTTLED

Type: ResponseType

The gateway response when usage plan, method, stage, or account level throttling limits exceeded.


static UNAUTHORIZED

Type: ResponseType

The gateway response when the custom or Amazon Cognito authorizer failed to authenticate the caller.


static UNSUPPORTED_MEDIA_TYPE

Type: ResponseType

The gateway response when a payload is of an unsupported media type, if strict passthrough behavior is enabled.


static WAF_FILTERED

Type: ResponseType

The gateway response when a request is blocked by AWS WAF.

Methods

NameDescription
static of(type)A custom response type to support future cases.

static of(type)

public static of(type: string): ResponseType

Parameters

  • type string

Returns

  • ResponseType

A custom response type to support future cases.