

# AWS::Serverless::WebSocketApi
<a name="sam-resource-websocketapi"></a>

Creates an Amazon API Gateway WebSocket API, which enables you to create two-way interactive communication applications. WebSocket APIs allow the server to send messages to clients without the client having to request them. For more information, see [Working with WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html) in the *API Gateway Developer Guide*.

We recommend that you use CloudFormation hooks or IAM policies to verify that API Gateway resources have authorizers attached to them to control access to them.

For more information about using CloudFormation hooks, see [Registering hooks](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/registering-hook-python.html) in the *CloudFormation CLI user guide* and the [apigw-enforce-authorizer](https://github.com/aws-cloudformation/aws-cloudformation-samples/tree/main/hooks/python-hooks/apigw-enforce-authorizer/) GitHub repository.

For more information about using IAM policies, see [Require that API routes have authorization](https://docs.aws.amazon.com/apigateway/latest/developerguide/security_iam_id-based-policy-examples.html#security_iam_id-based-policy-examples-require-authorization) in the *API Gateway Developer Guide*.

**Note**  
When you deploy to AWS CloudFormation, AWS SAM transforms your AWS SAM resources into CloudFormation resources. For more information, see [Generated CloudFormation resources for AWS SAM](sam-specification-generated-resources.md).

## Syntax
<a name="sam-resource-websocketapi-syntax"></a>

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

### YAML
<a name="sam-resource-websocketapi-syntax.yaml"></a>

```
Type: AWS::Serverless::WebSocketApi
Properties:
  [ApiKeySelectionExpression](#sam-websocketapi-apikeyselectionexpression): String
  [AccessLogSettings](#sam-websocketapi-accesslogsettings): [AccessLogSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings)
  [Auth](#sam-websocketapi-auth): WebSocketApiAuth
  [DefaultRouteSettings](#sam-websocketapi-defaultroutesettings): [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)
  [Description](#sam-websocketapi-description): String
  [DisableExecuteApiEndpoint](#sam-websocketapi-disableexecuteapiendpoint): Boolean
  [DisableSchemaValidation](#sam-websocketapi-disableschemavalidation): Boolean
  [Domain](#sam-websocketapi-domain): WebSocketApiDomainConfiguration
  [IpAddressType](#sam-websocketapi-ipaddresstype): String
  [Name](#sam-websocketapi-name): String
  [PropagateTags](#sam-websocketapi-propagatetags): Boolean
  [Routes](#sam-websocketapi-routes): RouteConfiguration
  [RouteSelectionExpression](#sam-websocketapi-routeselectionexpression): String
  [RouteSettings](#sam-websocketapi-routesettings): [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)
  [StageName](#sam-websocketapi-stagename): String
  [StageVariables](#sam-websocketapi-stagevariables): [Json](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables)
  [Tags](#sam-websocketapi-tags): Map
```

## Properties
<a name="sam-resource-websocketapi-properties"></a>

 `ApiKeySelectionExpression`   <a name="sam-websocketapi-apikeyselectionexpression"></a>
An API key selection expression. For more information, see [API Key Selection Expressions](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions) in the *API Gateway Developer Guide*.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[ApiKeySelectionExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-apikeyselectionexpression)` property of an `AWS::ApiGatewayV2::Api` resource.

 `AccessLogSettings`   <a name="sam-websocketapi-accesslogsettings"></a>
The settings for access logging in a stage.  
*Type*: [AccessLogSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings)  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[AccessLogSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings)` property of an `AWS::ApiGatewayV2::Stage` resource.

 `Auth`   <a name="sam-websocketapi-auth"></a>
Configures authorization for controlling access to your WebSocket API. Authorization is applied to the `$connect` route.  
For more information, see [Controlling access to WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-control-access.html) in the *API Gateway Developer Guide*.  
*Type*: [WebSocketApiAuth](sam-property-websocketapi-websocketapiauth.md)  
*Required*: No  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `DefaultRouteSettings`   <a name="sam-websocketapi-defaultroutesettings"></a>
The default route settings for this WebSocket API. These settings apply to all routes unless overridden by the `RouteSettings` property for certain routes.  
*Type*: [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[DefaultRouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-defaultroutesettings)` property of an `AWS::ApiGatewayV2::Stage` resource.

 `Description`   <a name="sam-websocketapi-description"></a>
A description of the WebSocket API.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-description)` property of an `AWS::ApiGatewayV2::Api` resource.

 `DisableExecuteApiEndpoint`   <a name="sam-websocketapi-disableexecuteapiendpoint"></a>
Specifies whether clients can invoke your API by using the default `execute-api` endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint.  
*Type*: Boolean  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[DisableExecuteApiEndpoint](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-disableexecuteapiendpoint)` property of an `AWS::ApiGatewayV2::Api` resource.

 `DisableSchemaValidation`   <a name="sam-websocketapi-disableschemavalidation"></a>
Avoid validating models when creating a deployment.  
*Type*: Boolean  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[DisableSchemaValidation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-disableschemavalidation)` property of an `AWS::ApiGatewayV2::Api` resource.

 `Domain`   <a name="sam-websocketapi-domain"></a>
Configures a custom domain for this WebSocket API.  
WebSocket APIs do not support mutual TLS authentication (MTLS). If you specify `MutualTlsAuthentication` or `OwnershipVerificationCertificateArn`, AWS SAM will return an error.
*Type*: [WebSocketApiDomainConfiguration](sam-property-websocketapi-websocketapidomainconfiguration.md)  
*Required*: No  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `IpAddressType`   <a name="sam-websocketapi-ipaddresstype"></a>
The IP address type for the API. Valid values are `ipv4` for IPv4 only and `dualstack` for IPv4 and IPv6.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[IpAddressType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-ipaddresstype)` property of an `AWS::ApiGatewayV2::Api` resource.

 `Name`   <a name="sam-websocketapi-name"></a>
A name for the WebSocket API. If you don't specify a name, AWS SAM generates a name for you.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-name)` property of an `AWS::ApiGatewayV2::Api` resource.

 `PropagateTags`   <a name="sam-websocketapi-propagatetags"></a>
If `true`, AWS SAM adds the `Tags` property to the `AWS::ApiGatewayV2::Stage` and `AWS::ApiGatewayV2::DomainName` resources that AWS SAM generates.  
*Type*: Boolean  
*Required*: No  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `Routes`   <a name="sam-websocketapi-routes"></a>
The route configurations for this WebSocket API. Routes define how messages are routed to Lambda functions. Each route consists of a route key and a Lambda function ARN.  
WebSocket APIs support three predefined routes: `$connect`, `$disconnect`, and `$default`. You can also define custom routes.  
*Type*: [RouteConfiguration](sam-property-websocketapi-routeconfiguration.md)  
*Required*: Yes  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `RouteSelectionExpression`   <a name="sam-websocketapi-routeselectionexpression"></a>
The route selection expression for the WebSocket API. For more information, see [Route Selection Expressions](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-route-selection-expressions) in the *API Gateway Developer Guide*.  
A common value is `$request.body.action`, which routes messages based on an `action` field in the message body.  
*Type*: String  
*Required*: Yes  
*CloudFormation compatibility*: This property is passed directly to the `[RouteSelectionExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-routeselectionexpression)` property of an `AWS::ApiGatewayV2::Api` resource.

 `RouteSettings`   <a name="sam-websocketapi-routesettings"></a>
The route settings for this WebSocket API. These settings override the `DefaultRouteSettings` for specific routes.  
*Type*: [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)` property of an `AWS::ApiGatewayV2::Stage` resource.

 `StageName`   <a name="sam-websocketapi-stagename"></a>
The name of the API stage. If you don't specify a name, AWS SAM uses `default` as the stage name.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[StageName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagename)` property of an `AWS::ApiGatewayV2::Stage` resource.

 `StageVariables`   <a name="sam-websocketapi-stagevariables"></a>
A map that defines the stage variables. Variable names can have alphanumeric and underscore characters, and the values must match `[A-Za-z0-9-._~:/?#&=,]+`.  
*Type*: [Json](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables)  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[StageVariables](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables)` property of an `AWS::ApiGatewayV2::Stage` resource.

 `Tags`   <a name="sam-websocketapi-tags"></a>
A map (string to string) that specifies the tags to be added to this WebSocket API. For details about valid keys and values for tags, see [Resource tag](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html) in the *CloudFormation User Guide*.  
*Type*: Map  
*Required*: No  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

## Examples
<a name="sam-resource-websocketapi-examples"></a>

### Simple WebSocket API
<a name="sam-resource-websocketapi-examples-simple"></a>

The following example creates a WebSocket API with three routes.

```
Resources:
  MyWebSocketApi:
    Type: AWS::Serverless::WebSocketApi
    Properties:
      RouteSelectionExpression: $request.body.action
      Routes:
        $connect:
          FunctionArn: !GetAtt ConnectFunction.Arn
        $disconnect:
          FunctionArn: !GetAtt DisconnectFunction.Arn
        sendMessage:
          FunctionArn: !GetAtt SendMessageFunction.Arn

  ConnectFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.connect
      Runtime: nodejs20.x
      CodeUri: ./src

  DisconnectFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.disconnect
      Runtime: nodejs20.x
      CodeUri: ./src

  SendMessageFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.sendMessage
      Runtime: nodejs20.x
      CodeUri: ./src
```

### WebSocket API with Lambda Authorizer
<a name="sam-resource-websocketapi-examples-auth"></a>

The following example creates a WebSocket API with a Lambda authorizer.

```
Resources:
  MyWebSocketApi:
    Type: AWS::Serverless::WebSocketApi
    Properties:
      RouteSelectionExpression: $request.body.action
      Auth:
        AuthType: CUSTOM
        AuthArn: !GetAtt AuthorizerFunction.Arn
        IdentitySource:
          - route.request.header.Authorization
      Routes:
        $connect:
          FunctionArn: !GetAtt ConnectFunction.Arn
        sendMessage:
          FunctionArn: !GetAtt SendMessageFunction.Arn

  AuthorizerFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.authorize
      Runtime: nodejs20.x
      CodeUri: ./src

  ConnectFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.connect
      Runtime: nodejs20.x
      CodeUri: ./src

  SendMessageFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.sendMessage
      Runtime: nodejs20.x
      CodeUri: ./src
```

# WebSocketApiAuth
<a name="sam-property-websocketapi-websocketapiauth"></a>

Configure authorization to control access to your Amazon API Gateway WebSocket API.

For more information about configuring access to WebSocket APIs, see [Controlling access to WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-control-access.html) in the *API Gateway Developer Guide*.

## Syntax
<a name="sam-property-websocketapi-websocketapiauth-syntax"></a>

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

### YAML
<a name="sam-property-websocketapi-websocketapiauth-syntax.yaml"></a>

```
[AuthArn](#sam-websocketapiauth-autharn): String
[AuthType](#sam-websocketapiauth-authtype): String
[IdentitySource](#sam-websocketapiauth-identitysource): List
[InvokeRole](#sam-websocketapiauth-invokerole): String
[Name](#sam-websocketapiauth-name): String
```

## Properties
<a name="sam-property-websocketapi-websocketapiauth-properties"></a>

 `AuthArn`   <a name="sam-websocketapiauth-autharn"></a>
The ARN of the Lambda function to use for authorization. Required when `AuthType` is `CUSTOM`.  
*Type*: String  
*Required*: Conditional  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `AuthType`   <a name="sam-websocketapiauth-authtype"></a>
The type of authorization. Valid values are `NONE`, `AWS_IAM`, or `CUSTOM`.  
+ `NONE` - No authorization
+ `AWS_IAM` - IAM authorization
+ `CUSTOM` - Lambda authorizer
*Type*: String  
*Required*: Yes  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `IdentitySource`   <a name="sam-websocketapiauth-identitysource"></a>
The identity source for which authorization is requested. For example, `route.request.header.Authorization`.  
*Type*: List  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[IdentitySource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource)` property of an `AWS::ApiGatewayV2::Authorizer` resource.

 `InvokeRole`   <a name="sam-websocketapiauth-invokerole"></a>
The ARN of the IAM role that API Gateway assumes when invoking the authorizer function. If not specified, AWS SAM automatically creates a resource-based permission that allows API Gateway to invoke the authorizer function.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[AuthorizerCredentialsArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizercredentialsarn)` property of an `AWS::ApiGatewayV2::Authorizer` resource.

 `Name`   <a name="sam-websocketapiauth-name"></a>
The name of the authorizer.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-name)` property of an `AWS::ApiGatewayV2::Authorizer` resource.

## Examples
<a name="sam-property-websocketapi-websocketapiauth-examples"></a>

### Lambda Authorizer
<a name="sam-property-websocketapi-websocketapiauth-examples-lambda"></a>

The following example configures a Lambda authorizer for a WebSocket API.

```
Auth:
  AuthType: CUSTOM
  AuthArn: !GetAtt AuthorizerFunction.Arn
  IdentitySource:
    - route.request.header.Authorization
```

### IAM Authorization
<a name="sam-property-websocketapi-websocketapiauth-examples-iam"></a>

The following example configures IAM authorization for a WebSocket API.

```
Auth:
  AuthType: AWS_IAM
```

# WebSocketApiDomainConfiguration
<a name="sam-property-websocketapi-websocketapidomainconfiguration"></a>

Configures a custom domain for a WebSocket API.

## Syntax
<a name="sam-property-websocketapi-websocketapidomainconfiguration-syntax"></a>

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

### YAML
<a name="sam-property-websocketapi-websocketapidomainconfiguration-syntax.yaml"></a>

```
  [BasePath](#sam-websocketapi-websocketapidomainconfiguration-basepath): List
  [CertificateArn](#sam-websocketapi-websocketapidomainconfiguration-certificatearn): String
  [DomainName](#sam-websocketapi-websocketapidomainconfiguration-domainname): String
  [EndpointConfiguration](#sam-websocketapi-websocketapidomainconfiguration-endpointconfiguration): String
  [Route53](#sam-websocketapi-websocketapidomainconfiguration-route53): Route53Configuration
  [SecurityPolicy](#sam-websocketapi-websocketapidomainconfiguration-securitypolicy): String
```

## Properties
<a name="sam-property-websocketapi-websocketapidomainconfiguration-properties"></a>

 `BasePath`   <a name="sam-websocketapi-websocketapidomainconfiguration-basepath"></a>
A list of the basepaths to configure with the Amazon API Gateway domain name.  
*Type*: List  
*Required*: No  
*Default*: /  
*CloudFormation compatibility*: This property is similar to the `[ApiMappingKey](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-apimappingkey)` property of an `AWS::ApiGatewayV2::ApiMapping` resource. AWS SAM creates multiple `AWS::ApiGatewayV2::ApiMapping` resources, one per value specified in this property.

 `CertificateArn`   <a name="sam-websocketapi-websocketapidomainconfiguration-certificatearn"></a>
The Amazon Resource Name (ARN) of an AWS managed certificate for this domain name's endpoint. AWS Certificate Manager is the only supported source.  
*Type*: String  
*Required*: Yes  
*CloudFormation compatibility*: This property is passed directly to the `[CertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-certificatearn)` property of an `AWS::ApiGatewayV2::DomainName DomainNameConfiguration` resource.

 `DomainName`   <a name="sam-websocketapi-websocketapidomainconfiguration-domainname"></a>
The custom domain name for your API Gateway WebSocket API. Uppercase letters are not supported.  
AWS SAM generates an `AWS::ApiGatewayV2::DomainName` resource when this property is set. For information about generated CloudFormation resources, see [Generated CloudFormation resources for AWS SAM](sam-specification-generated-resources.md).  
*Type*: String  
*Required*: Yes  
*CloudFormation compatibility*: This property is passed directly to the `[DomainName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-domainname)` property of an `AWS::ApiGatewayV2::DomainName` resource.

 `EndpointConfiguration`   <a name="sam-websocketapi-websocketapidomainconfiguration-endpointconfiguration"></a>
Defines the type of API Gateway endpoint to map to the custom domain. The value of this property determines how the `CertificateArn` property is mapped in CloudFormation.  
The only valid value for WebSocket APIs is `REGIONAL`.  
*Type*: String  
*Required*: No  
*Default*: `REGIONAL`  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `Route53`   <a name="sam-websocketapi-websocketapidomainconfiguration-route53"></a>
Defines an Route 53 configuration.  
*Type*: [Route53Configuration](sam-property-websocketapi-route53configuration.md)  
*Required*: No  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `SecurityPolicy`   <a name="sam-websocketapi-websocketapidomainconfiguration-securitypolicy"></a>
The TLS version of the security policy for this domain name.  
The only valid value for WebSocket APIs is `TLS_1_2`.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[SecurityPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-securitypolicy)` property of the `AWS::ApiGatewayV2::DomainName` `DomainNameConfiguration` data type.

## Examples
<a name="sam-property-websocketapi-websocketapidomainconfiguration--examples"></a>

### DomainName
<a name="sam-property-websocketapi-websocketapidomainconfiguration--examples--domainname"></a>

DomainName example

#### YAML
<a name="sam-property-websocketapi-websocketapidomainconfiguration--examples--domainname--yaml"></a>

```
Domain:
  DomainName: ws.example.com
  CertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/example
  EndpointConfiguration: REGIONAL
  Route53:
    HostedZoneId: Z1PA6795UKMFR9
  BasePath:
    - v1
    - v2
```

# Route53Configuration
<a name="sam-property-websocketapi-route53configuration"></a>

Configures the Route53 record sets for an API.

## Syntax
<a name="sam-property-websocketapi-route53configuration-syntax"></a>

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

### YAML
<a name="sam-property-websocketapi-route53configuration-syntax.yaml"></a>

```
  [EvaluateTargetHealth](#sam-websocketapi-route53configuration-evaluatetargethealth): Boolean
  [HostedZoneId](#sam-websocketapi-route53configuration-hostedzoneid): String
  [HostedZoneName](#sam-websocketapi-route53configuration-hostedzonename): String
  [IpV6](#sam-websocketapi-route53configuration-ipv6): Boolean
  [Region](#sam-websocketapi-route53configuration-region): String
  [SetIdentifier](#sam-websocketapi-route53configuration-setidentifier): String
```

## Properties
<a name="sam-property-websocketapi-route53configuration-properties"></a>

 `EvaluateTargetHealth`   <a name="sam-websocketapi-route53configuration-evaluatetargethealth"></a>
When EvaluateTargetHealth is true, an alias record inherits the health of the referenced AWS resource, such as an Elastic Load Balancing load balancer or another record in the hosted zone.  
*Type*: Boolean  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[EvaluateTargetHealth](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget.html#cfn-route53-aliastarget-evaluatetargethealth)` property of an `AWS::Route53::RecordSetGroup AliasTarget` resource.  
*Additional notes*: You can't set EvaluateTargetHealth to true when the alias target is a CloudFront distribution.

 `HostedZoneId`   <a name="sam-websocketapi-route53configuration-hostedzoneid"></a>
The ID of the hosted zone that you want to create records in.  
Specify either `HostedZoneName` or `HostedZoneId`, but not both. If you have multiple hosted zones with the same domain name, you must specify the hosted zone using `HostedZoneId`.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[HostedZoneId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-hostedzoneid)` property of an `AWS::Route53::RecordSetGroup RecordSet` resource.

 `HostedZoneName`   <a name="sam-websocketapi-route53configuration-hostedzonename"></a>
The name of the hosted zone that you want to create records in. You must include a trailing dot (for example, `www.example.com.`) as part of the `HostedZoneName`.  
Specify either `HostedZoneName` or `HostedZoneId`, but not both. If you have multiple hosted zones with the same domain name, you must specify the hosted zone using `HostedZoneId`.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[HostedZoneName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-hostedzonename)` property of an `AWS::Route53::RecordSetGroup RecordSet` resource.

 `IpV6`   <a name="sam-websocketapi-route53configuration-ipv6"></a>
When this property is set, AWS SAM creates a `AWS::Route53::RecordSet` resource and sets [Type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset.html#cfn-route53-recordset-type) to `AAAA` for the provided HostedZone.  
*Type*: Boolean  
*Required*: No  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

`Region`  <a name="sam-websocketapi-route53configuration-region"></a>
*Latency-based resource record sets only:* The Amazon EC2 Region where you created the resource that this resource record set refers to. The resource typically is an AWS resource, such as an EC2 instance or an ELB load balancer, and is referred to by an IP address or a DNS domain name, depending on the record type.  
When Amazon Route 53 receives a DNS query for a domain name and type for which you have created latency resource record sets, Route 53 selects the latency resource record set that has the lowest latency between the end user and the associated Amazon EC2 Region. Route 53 then returns the value that is associated with the selected resource record set.  
Note the following:  
+ You can only specify one `ResourceRecord` per latency resource record set.
+ You can only create one latency resource record set for each Amazon EC2 Region.
+ You aren't required to create latency resource record sets for all Amazon EC2 Regions. Route 53 will choose the region with the best latency from among the regions that you create latency resource record sets for.
+ You can't create non-latency resource record sets that have the same values for the `Name` and `Type` elements as latency resource record sets.
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[ Region](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-region)` property of an `AWS::Route53::RecordSetGroup` `RecordSet` data type.

`SetIdentifier`  <a name="sam-websocketapi-route53configuration-setidentifier"></a>
*Resource record sets that have a routing policy other than simple:* An identifier that differentiates among multiple resource record sets that have the same combination of name and type, such as multiple weighted resource record sets named acme.example.com that have a type of A. In a group of resource record sets that have the same name and type, the value of `SetIdentifier` must be unique for each resource record set.  
For information about routing policies, see [Choosing a routing policy](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html) in the *Amazon Route 53 Developer Guide*.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[ SetIdentifier](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-setidentifier)` property of an `AWS::Route53::RecordSetGroup` `RecordSet` data type.

## Examples
<a name="sam-property-websocketapi-route53configuration--examples"></a>

### Route 53 Configuration Example
<a name="sam-property-websocketapi-route53configuration--examples--route-53-configuration-example"></a>

This example shows how to configure Route 53.

#### YAML
<a name="sam-property-websocketapi-route53configuration--examples--route-53-configuration-example--yaml"></a>

```
Domain:
  DomainName: www.example.com
  CertificateArn: arn-example
  EndpointConfiguration: REGIONAL
  Route53:
    HostedZoneId: Z1PA6795UKMFR9
    EvaluateTargetHealth: true
```

# RouteConfiguration
<a name="sam-property-websocketapi-routeconfiguration"></a>

## Syntax
<a name="sam-property-websocketapi-routeconfiguration-syntax"></a>

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

### YAML
<a name="sam-property-websocketapi-routeconfiguration-syntax.yaml"></a>

```
[ApiKeyRequired](#sam-routeconfiguration-apikeyrequired): Boolean
[FunctionArn](#sam-routeconfiguration-functionarn): String
[IntegrationTimeout](#sam-routeconfiguration-integrationtimeout): Integer
[ModelSelectionExpression](#sam-routeconfiguration-modelselectionexpression): String
[OperationName](#sam-routeconfiguration-operationname): String
[RequestModels](#sam-routeconfiguration-requestmodels): Json
[RequestParameters](#sam-routeconfiguration-requestparameters): Json
[RouteResponseSelectionExpression](#sam-routeconfiguration-routeresponseselectionexpression): String
```

## Properties
<a name="sam-property-websocketapi-routeconfiguration-properties"></a>

 `ApiKeyRequired`   <a name="sam-routeconfiguration-apikeyrequired"></a>
Specifies whether an API key is required for this route.  
*Type*: Boolean  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[ApiKeyRequired](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-apikeyrequired)` property of an `AWS::ApiGatewayV2::Route` resource.

 `FunctionArn`   <a name="sam-routeconfiguration-functionarn"></a>
The ARN of the Lambda function that handles this route. AWS SAM creates an integration and the necessary permissions for API Gateway to invoke the function.  
*Type*: String  
*Required*: Yes  
*CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

 `IntegrationTimeout`   <a name="sam-routeconfiguration-integrationtimeout"></a>
The timeout for the integration, in milliseconds. The maximum value is 29,000 milliseconds (29 seconds).  
*Type*: Integer  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[TimeoutInMillis](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-timeoutinmillis)` property of an `AWS::ApiGatewayV2::Integration` resource.

 `ModelSelectionExpression`   <a name="sam-routeconfiguration-modelselectionexpression"></a>
The model selection expression for the route.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[ModelSelectionExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-modelselectionexpression)` property of an `AWS::ApiGatewayV2::Route` resource.

 `OperationName`   <a name="sam-routeconfiguration-operationname"></a>
The operation name for the route.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[OperationName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-operationname)` property of an `AWS::ApiGatewayV2::Route` resource.

 `RequestModels`   <a name="sam-routeconfiguration-requestmodels"></a>
The request models for the route.  
*Type*: Json  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[RequestModels](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-requestmodels)` property of an `AWS::ApiGatewayV2::Route` resource.

 `RequestParameters`   <a name="sam-routeconfiguration-requestparameters"></a>
The request parameters for the route.  
*Type*: Json  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[RequestParameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-requestparameters)` property of an `AWS::ApiGatewayV2::Route` resource.

 `RouteResponseSelectionExpression`   <a name="sam-routeconfiguration-routeresponseselectionexpression"></a>
The route response selection expression for the route.  
*Type*: String  
*Required*: No  
*CloudFormation compatibility*: This property is passed directly to the `[RouteResponseSelectionExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-routeresponseselectionexpression)` property of an `AWS::ApiGatewayV2::Route` resource.

## Examples
<a name="sam-property-websocketapi-routeconfiguration-examples"></a>

### Simple Route
<a name="sam-property-websocketapi-routeconfiguration-examples-simple"></a>

The following example configures a simple route.

```
Routes:
  $connect:
    FunctionArn: !GetAtt ConnectFunction.Arn
  sendMessage:
    FunctionArn: !GetAtt SendMessageFunction.Arn
    OperationName: SendMessage
```