# ApiKeyProps

ApiKey Properties.

Extends: [ApiKeyOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiKeyOptions.html)
Used as props by: [ApiKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiKey.html)

- Source: [`aws-apigatewayv2/lib/websocket/api-key.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/websocket/api-key.ts#L62)
- Type last changed: v2.212.0 · 20 Aug 2025

## Example

TypeScript:

```ts
// Auto-generated name and value
const autoKey = new apigwv2.ApiKey(this, 'AutoKey');

// Explicit name and value
const explicitKey = new apigwv2.ApiKey(this, 'ExplicitKey', {
  apiKeyName: 'MyWebSocketApiKey',
  value: 'MyApiKeyThatIsAtLeast20Characters',
});
```

Python:

```python
# Auto-generated name and value
auto_key = apigwv2.ApiKey(self, "AutoKey")

# Explicit name and value
explicit_key = apigwv2.ApiKey(self, "ExplicitKey",
    api_key_name="MyWebSocketApiKey",
    value="MyApiKeyThatIsAtLeast20Characters"
)
```

Java:

```java
// Auto-generated name and value
ApiKey autoKey = new ApiKey(this, "AutoKey");

// Explicit name and value
ApiKey explicitKey = ApiKey.Builder.create(this, "ExplicitKey")
        .apiKeyName("MyWebSocketApiKey")
        .value("MyApiKeyThatIsAtLeast20Characters")
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Auto-generated name and value
var autoKey = new ApiKey(this, "AutoKey");

// Explicit name and value
var explicitKey = new ApiKey(this, "ExplicitKey", new ApiKeyProps {
    ApiKeyName = "MyWebSocketApiKey",
    Value = "MyApiKeyThatIsAtLeast20Characters"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Auto-generated name and value
autoKey := apigwv2.NewApiKey(this, jsii.String("AutoKey"))

// Explicit name and value
explicitKey := apigwv2.NewApiKey(this, jsii.String("ExplicitKey"), &ApiKeyProps{
	ApiKeyName: jsii.String("MyWebSocketApiKey"),
	Value: jsii.String("MyApiKeyThatIsAtLeast20Characters"),
})
```

## Properties

- `apiKeyName`: string — A name for the API key.

  **Default:** automatically generated name

  If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the API key name.

- `customerId`: string = none — An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.

- `description`: string = none — A description of the purpose of the API key.

- `enabled`: boolean = true — Indicates whether the API key can be used by clients.

- `generateDistinctId`: boolean = false — Specifies whether the key identifier is distinct from the created API key value.

- `value`: string = none — The value of the API key.

  Must be at least 20 characters long.
