Skip to content

create_channel async

create_channel(
    app_instance_arn: ChimeArn,
    name: NonEmptyResourceName,
    client_request_token: ClientRequestToken,
    chime_bearer: ChimeArn,
    *,
    config_overrides: Optional[AsyncChimeSDKMessagingClientConfig] = None,
    mode: Optional[ChannelMode] = None,
    privacy: Optional[ChannelPrivacy] = None,
    metadata: Optional[Metadata] = None,
    tags: Optional[TagList] = None,
    channel_id: Optional[ChannelId] = None,
    member_arns: Optional[ChannelMemberArns] = None,
    moderator_arns: Optional[ChannelModeratorArns] = None,
    elastic_channel_configuration: Optional[ElasticChannelConfiguration] = None,
    expiration_settings: Optional[ExpirationSettings] = None,
) -> CreateChannelResponse

Creates a channel to which you can add users and send messages.

Restriction: You can't change a channel's privacy.

The x-amz-chime-bearer request header is mandatory. Use the ARN of the AppInstanceUser or AppInstanceBot that makes the API call as the value in the header.

Parameters:

  • app_instance_arn (ChimeArn) –

    The ARN of the channel request.

  • name (NonEmptyResourceName) –

    The name of the channel.

  • mode (Optional[ChannelMode], default: None ) –

    The channel mode: UNRESTRICTED or RESTRICTED. Administrators, moderators, and channel members can add themselves and other members to unrestricted channels. Only administrators and moderators can add members to restricted channels.

  • privacy (Optional[ChannelPrivacy], default: None ) –

    The channel's privacy level: PUBLIC or PRIVATE. Private channels aren't discoverable by users outside the channel. Public channels are discoverable by anyone in the AppInstance.

  • metadata (Optional[Metadata], default: None ) –

    The metadata of the creation request. Limited to 1KB and UTF-8.

  • client_request_token (ClientRequestToken) –

    The client token for the request. An Idempotency token.

  • tags (Optional[TagList], default: None ) –

    The tags for the creation request.

  • chime_bearer (ChimeArn) –

    The ARN of the AppInstanceUser or AppInstanceBot that makes the API call.

  • channel_id (Optional[ChannelId], default: None ) –

    An ID for the channel being created. If you do not specify an ID, a UUID will be created for the channel.

  • member_arns (Optional[ChannelMemberArns], default: None ) –

    The ARNs of the channel members in the request.

  • moderator_arns (Optional[ChannelModeratorArns], default: None ) –

    The ARNs of the channel moderators in the request.

  • elastic_channel_configuration (Optional[ElasticChannelConfiguration], default: None ) –

    The attributes required to configure and create an elastic channel. An elastic channel can support a maximum of 1-million users, excluding moderators.

  • expiration_settings (Optional[ExpirationSettings], default: None ) –

    Settings that control the interval after which the channel is automatically deleted.

Raises:

Source code in docs_src/capo_chime_sdk_messaging/_services/async_chime_sdk_messaging.py
async def create_channel(
    self,
    app_instance_arn: "capo_chime_sdk_messaging.types.chime_arn.ChimeArn",
    name: "capo_chime_sdk_messaging.types.non_empty_resource_name.NonEmptyResourceName",
    client_request_token: "capo_chime_sdk_messaging.types.client_request_token.ClientRequestToken",
    chime_bearer: "capo_chime_sdk_messaging.types.chime_arn.ChimeArn",
    *,
    config_overrides: Optional[AsyncChimeSDKMessagingClientConfig] = None,
    mode: Optional[
        "capo_chime_sdk_messaging.types.channel_mode.ChannelMode"
    ] = None,
    privacy: Optional[
        "capo_chime_sdk_messaging.types.channel_privacy.ChannelPrivacy"
    ] = None,
    metadata: Optional["capo_chime_sdk_messaging.types.metadata.Metadata"] = None,
    tags: Optional["capo_chime_sdk_messaging.types.tag_list.TagList"] = None,
    channel_id: Optional[
        "capo_chime_sdk_messaging.types.channel_id.ChannelId"
    ] = None,
    member_arns: Optional[
        "capo_chime_sdk_messaging.types.channel_member_arns.ChannelMemberArns"
    ] = None,
    moderator_arns: Optional[
        "capo_chime_sdk_messaging.types.channel_moderator_arns.ChannelModeratorArns"
    ] = None,
    elastic_channel_configuration: Optional[
        "capo_chime_sdk_messaging.types.elastic_channel_configuration.ElasticChannelConfiguration"
    ] = None,
    expiration_settings: Optional[
        "capo_chime_sdk_messaging.types.expiration_settings.ExpirationSettings"
    ] = None,
) -> "capo_chime_sdk_messaging.types.create_channel_response.CreateChannelResponse":
    """<p>Creates a channel to which you can add users and send messages.</p> <p> <b>Restriction</b>: You can't change a channel's privacy.</p> <note> <p>The <code>x-amz-chime-bearer</code> request header is mandatory. Use the ARN of the <code>AppInstanceUser</code> or <code>AppInstanceBot</code> that makes the API call as the value in the header.</p> </note>

    Args:
        app_instance_arn: <p>The ARN of the channel request.</p>
        name: <p>The name of the channel.</p>
        mode: <p>The channel mode: <code>UNRESTRICTED</code> or <code>RESTRICTED</code>. Administrators, moderators, and channel members can add themselves and other members to unrestricted channels. Only administrators and moderators can add members to restricted channels.</p>
        privacy: <p>The channel's privacy level: <code>PUBLIC</code> or <code>PRIVATE</code>. Private channels aren't discoverable by users outside the channel. Public channels are discoverable by anyone in the <code>AppInstance</code>.</p>
        metadata: <p>The metadata of the creation request. Limited to 1KB and UTF-8.</p>
        client_request_token: <p>The client token for the request. An <code>Idempotency</code> token.</p>
        tags: <p>The tags for the creation request.</p>
        chime_bearer: <p>The ARN of the <code>AppInstanceUser</code> or <code>AppInstanceBot</code> that makes the API call.</p>
        channel_id: <p>An ID for the channel being created. If you do not specify an ID, a UUID will be created for the channel.</p>
        member_arns: <p>The ARNs of the channel members in the request.</p>
        moderator_arns: <p>The ARNs of the channel moderators in the request.</p>
        elastic_channel_configuration: <p>The attributes required to configure and create an elastic channel. An elastic channel can support a maximum of 1-million users, excluding moderators.</p>
        expiration_settings: <p>Settings that control the interval after which the channel is automatically deleted.</p>

    Raises:
        capo_chime_sdk_messaging.errors.bad_request_exception.BadRequestException: <p>The input parameters don't match the service's restrictions.</p>
        capo_chime_sdk_messaging.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource.</p>
        capo_chime_sdk_messaging.errors.forbidden_exception.ForbiddenException: <p>The client is permanently forbidden from making the request.</p>
        capo_chime_sdk_messaging.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>The request exceeds the resource limit.</p>
        capo_chime_sdk_messaging.errors.service_failure_exception.ServiceFailureException: <p>The service encountered an unexpected error.</p>
        capo_chime_sdk_messaging.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is currently unavailable.</p>
        capo_chime_sdk_messaging.errors.throttled_client_exception.ThrottledClientException: <p>The client exceeded its request rate limit.</p>
        capo_chime_sdk_messaging.errors.unauthorized_client_exception.UnauthorizedClientException: <p>The client is not currently authorized to make the request.</p>
        capo_chime_sdk_messaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_chime_sdk_messaging.types.create_channel_request.CreateChannelRequest]",
    ) -> AsyncOperationResponse[
        "capo_chime_sdk_messaging.types.create_channel_response.CreateChannelResponse"
    ]:
        import capo_chime_sdk_messaging._operations.chime_messaging_service.create_channel

        (
            output,
            http_response,
        ) = await capo_chime_sdk_messaging._operations.chime_messaging_service.create_channel.async_create_channel(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_chime_sdk_messaging.types.create_channel_request.CreateChannelRequest",
    ) -> dict[str, Any]:
        import capo_chime_sdk_messaging.types.create_channel_request

        return (
            capo_chime_sdk_messaging.types.create_channel_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateChannel", redact_input=_redact_input),
    )
    input_: capo_chime_sdk_messaging.types.create_channel_request.CreateChannelRequest = {
        "app_instance_arn": app_instance_arn,
        "name": name,
        "client_request_token": client_request_token,
        "chime_bearer": chime_bearer,
    }
    if mode is not None:
        input_["mode"] = mode
    if privacy is not None:
        input_["privacy"] = privacy
    if metadata is not None:
        input_["metadata"] = metadata
    if tags is not None:
        input_["tags"] = tags
    if channel_id is not None:
        input_["channel_id"] = channel_id
    if member_arns is not None:
        input_["member_arns"] = member_arns
    if moderator_arns is not None:
        input_["moderator_arns"] = moderator_arns
    if elastic_channel_configuration is not None:
        input_["elastic_channel_configuration"] = elastic_channel_configuration
    if expiration_settings is not None:
        input_["expiration_settings"] = expiration_settings

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output