:doc:`ChimeSDKMessaging <../../chime-sdk-messaging>` / Client / create_channel_membership

*************************
create_channel_membership
*************************



.. py:method:: ChimeSDKMessaging.Client.create_channel_membership(**kwargs)

  

  Adds a member to a channel. The ``InvitedBy`` field in ``ChannelMembership`` is derived from the request header. A channel member can:

   

  
  * List messages
   
  * Send messages
   
  * Receive messages
   
  * Edit their own messages
   
  * Leave the channel
  

   

  Privacy settings impact this action as follows:

   

  
  * Public Channels: You do not need to be a member to list messages, but you must be a member to send messages.
   
  * Private Channels: You must be a member to list or send messages.
  

   

  .. note::

    

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

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/chime-sdk-messaging-2021-05-15/CreateChannelMembership>`_  


  **Request Syntax**
  ::

    response = client.create_channel_membership(
        ChannelArn='string',
        MemberArn='string',
        Type='DEFAULT'|'HIDDEN',
        ChimeBearer='string',
        SubChannelId='string'
    )
    
  :type ChannelArn: string
  :param ChannelArn: **[REQUIRED]** 

    The ARN of the channel to which you're adding users.

    

  
  :type MemberArn: string
  :param MemberArn: **[REQUIRED]** 

    The ``AppInstanceUserArn`` of the member you want to add to the channel.

    

  
  :type Type: string
  :param Type: **[REQUIRED]** 

    The membership type of a user, ``DEFAULT`` or ``HIDDEN``. Default members are always returned as part of ``ListChannelMemberships``. Hidden members are only returned if the type filter in ``ListChannelMemberships`` equals ``HIDDEN``. Otherwise hidden members are not returned. This is only supported by moderators.

    

  
  :type ChimeBearer: string
  :param ChimeBearer: **[REQUIRED]** 

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

    

  
  :type SubChannelId: string
  :param SubChannelId: 

    The ID of the SubChannel in the request.

     

    .. note::

      

      Only required when creating membership in a SubChannel for a moderator in an elastic channel.

      

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'ChannelArn': 'string',
          'Member': {
              'Arn': 'string',
              'Name': 'string'
          },
          'SubChannelId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **ChannelArn** *(string) --* 

        The ARN of the channel.

        
      

      - **Member** *(dict) --* 

        The ARN and metadata of the member being added.

        
        

        - **Arn** *(string) --* 

          The ARN in an Identity.

          
        

        - **Name** *(string) --* 

          The name in an Identity.

          
    
      

      - **SubChannelId** *(string) --* 

        The ID of the SubChannel in the response.

        
  
  **Exceptions**
  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.BadRequestException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.NotFoundException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.ForbiddenException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.UnauthorizedClientException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.ConflictException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.ResourceLimitExceededException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.ThrottledClientException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.ServiceUnavailableException`

  
  *   :py:class:`ChimeSDKMessaging.Client.exceptions.ServiceFailureException`

  