# WebSocketApiKeySelectionExpression

Represents the currently available API Key Selection Expressions.

Obtainable from: WebSocketApiKeySelectionExpression.AUTHORIZER_USAGE_IDENTIFIER_KEY, WebSocketApiKeySelectionExpression.HEADER_X_API_KEY

- Source: [`aws-apigatewayv2/lib/websocket/api.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/websocket/api.ts#L38)
- Type last changed: v2.112.0 · 1 Dec 2023

## Example

TypeScript:

```ts
const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi',{
  apiKeySelectionExpression: apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY,
});
```

Python:

```python
web_socket_api = apigwv2.WebSocketApi(self, "mywsapi",
    api_key_selection_expression=apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY
)
```

Java:

```java
WebSocketApi webSocketApi = WebSocketApi.Builder.create(this, "mywsapi")
        .apiKeySelectionExpression(WebSocketApiKeySelectionExpression.HEADER_X_API_KEY)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var webSocketApi = new WebSocketApi(this, "mywsapi", new WebSocketApiProps {
    ApiKeySelectionExpression = WebSocketApiKeySelectionExpression.HEADER_X_API_KEY
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
webSocketApi := apigwv2.NewWebSocketApi(this, jsii.String("mywsapi"), &WebSocketApiProps{
	ApiKeySelectionExpression: apigwv2.WebSocketApiKeySelectionExpression_HEADER_X_API_KEY(),
})
```

## Initializer

TypeScript:

```ts
new WebSocketApiKeySelectionExpression(customApiKeySelector: string)
```

Python:

```python
WebSocketApiKeySelectionExpression(custom_api_key_selector: str)
```

Java:

```java
new WebSocketApiKeySelectionExpression(String customApiKeySelector)
```

C# / .NET:

```csharp
new WebSocketApiKeySelectionExpression(string customApiKeySelector)
```

Golang:

```go
NewWebSocketApiKeySelectionExpression(CustomApiKeySelector *string)
```

## Properties

- `AUTHORIZER_USAGE_IDENTIFIER_KEY`: [WebSocketApiKeySelectionExpression](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiKeySelectionExpression.html) (static) — The API will extract the key value from the `usageIdentifierKey` attribute in the `context` map, returned by the Lambda Authorizer.

  See https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html

- `customApiKeySelector`: string — The expression used by API Gateway.

- `HEADER_X_API_KEY`: [WebSocketApiKeySelectionExpression](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiKeySelectionExpression.html) (static) — The API will extract the key value from the `x-api-key` header in the user request.
