# ApiKeyProps

ApiKey Properties.

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

- Source: [`aws-apigateway/lib/api-key.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigateway/lib/api-key.ts#L64)
- Type last changed: v2.46.0 · 13 Oct 2022

## Example

TypeScript:

```ts
const stack = new Stack(app, 'my-stack', {
  propertyInjectors: [new ApiKeyPropsInjector()],
});
new api.ApiKey(stack, 'my-api-key', {});
```

Python:

```python
stack = Stack(app, "my-stack",
    property_injectors=[ApiKeyPropsInjector()]
)
api.ApiKey(stack, "my-api-key")
```

Java:

```java
Stack stack = Stack.Builder.create(app, "my-stack")
        .propertyInjectors(List.of(new ApiKeyPropsInjector()))
        .build();
ApiKey.Builder.create(stack, "my-api-key").build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var stack = new Stack(app, "my-stack", new StackProps {
    PropertyInjectors = new [] { new ApiKeyPropsInjector() }
});
new ApiKey(stack, "my-api-key", new ApiKeyProps { });
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
stack := awscdk.NewStack(app, jsii.String("my-stack"), &StackProps{
	PropertyInjectors: []IPropertyInjector{
		newApiKeyPropsInjector(),
	},
})
api.NewApiKey(stack, jsii.String("my-api-key"), &ApiKeyProps{
})
```

## Properties

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

  **Default:** automically 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.

- `defaultCorsPreflightOptions`: [CorsOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.CorsOptions.html) — Adds a CORS preflight OPTIONS method to this resource and all child resources.

  **Default:** CORS is disabled

  You can add CORS at the resource-level using `addCorsPreflight`.

- `defaultIntegration`: [Integration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.Integration.html) — An integration to use as a default for all methods created within this API unless an integration is specified.

  **Default:** Inherited from parent.

- `defaultMethodOptions`: [MethodOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.MethodOptions.html) — Method options to use as a default for all methods created within this API unless custom options are specified.

  **Default:** Inherited from parent.

- `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.

- `resources`: [IRestApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IRestApi.html)[] = none — - use `stages` instead

- `stages`: [IStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IStage.html)[] — A list of Stages this api key is associated with.

  **Default:** the api key is not associated with any stages

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

  Must be at least 20 characters long.
