# ChannelNamespaceProps

Additional property for an AppSync channel namespace for an Event API reference.

Extends: [BaseChannelNamespaceProps](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.BaseChannelNamespaceProps.html)
Used as props by: [ChannelNamespace](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.ChannelNamespace.html)

- Source: [`aws-appsync/lib/channel-namespace.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-appsync/lib/channel-namespace.ts#L132)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

TypeScript:

```ts
declare const api: appsync.EventApi;

new appsync.ChannelNamespace(this, 'Namespace', {
  api,
  authorizationConfig: {
    // Override publishing authorization to API Key
    publishAuthModeTypes: [appsync.AppSyncAuthorizationType.API_KEY],
    // Override subscribing authorization to Lambda
    subscribeAuthModeTypes: [appsync.AppSyncAuthorizationType.LAMBDA],
  },
});
```

Python:

```python
# api: appsync.EventApi

appsync.ChannelNamespace(self, "Namespace",
    api=api,
    authorization_config=appsync.NamespaceAuthConfig(
        # Override publishing authorization to API Key
        publish_auth_mode_types=[appsync.AppSyncAuthorizationType.API_KEY],
        # Override subscribing authorization to Lambda
        subscribe_auth_mode_types=[appsync.AppSyncAuthorizationType.LAMBDA]
    )
)
```

Java:

```java
EventApi api;

ChannelNamespace.Builder.create(this, "Namespace")
        .api(api)
        .authorizationConfig(NamespaceAuthConfig.builder()
                // Override publishing authorization to API Key
                .publishAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
                // Override subscribing authorization to Lambda
                .subscribeAuthModeTypes(List.of(AppSyncAuthorizationType.LAMBDA))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
EventApi api;

new ChannelNamespace(this, "Namespace", new ChannelNamespaceProps {
    Api = api,
    AuthorizationConfig = new NamespaceAuthConfig {
        // Override publishing authorization to API Key
        PublishAuthModeTypes = new [] { AppSyncAuthorizationType.API_KEY },
        // Override subscribing authorization to Lambda
        SubscribeAuthModeTypes = new [] { AppSyncAuthorizationType.LAMBDA }
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var api EventApi

appsync.NewChannelNamespace(this, jsii.String("Namespace"), &ChannelNamespaceProps{
	Api: Api,
	AuthorizationConfig: &NamespaceAuthConfig{
		// Override publishing authorization to API Key
		PublishAuthModeTypes: []AppSyncAuthorizationType{
			appsync.AppSyncAuthorizationType_API_KEY,
		},
		// Override subscribing authorization to Lambda
		SubscribeAuthModeTypes: []AppSyncAuthorizationType{
			appsync.AppSyncAuthorizationType_LAMBDA,
		},
	},
})
```

## Properties

- `api`: [IEventApi](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.IEventApi.html) (required) — The API this channel namespace is associated with.

- `authorizationConfig`: [NamespaceAuthConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.NamespaceAuthConfig.html) — Authorization config for channel namespace.

  **Default:** defaults to Event API default auth config

- `channelNamespaceName`: string — the name of the channel namespace.

  **Default:** the construct's id will be used

- `code`: [Code](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.Code.html) — The Event Handler code.

  **Default:** no code is used

- `publishHandlerConfig`: [HandlerConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.HandlerConfig.html) — onPublish handler config.

  **Default:** no handler config

- `subscribeHandlerConfig`: [HandlerConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.HandlerConfig.html) — onSubscribe handler config.

  **Default:** no handler config
