- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CreateChannelMembershipCommand
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.
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { ChimeSDKMessagingClient, CreateChannelMembershipCommand } from "@aws-sdk/client-chime-sdk-messaging"; // ES Modules import
// const { ChimeSDKMessagingClient, CreateChannelMembershipCommand } = require("@aws-sdk/client-chime-sdk-messaging"); // CommonJS import
const client = new ChimeSDKMessagingClient(config);
const input = { // CreateChannelMembershipRequest
ChannelArn: "STRING_VALUE", // required
MemberArn: "STRING_VALUE", // required
Type: "DEFAULT" || "HIDDEN", // required
ChimeBearer: "STRING_VALUE", // required
SubChannelId: "STRING_VALUE",
};
const command = new CreateChannelMembershipCommand(input);
const response = await client.send(command);
// { // CreateChannelMembershipResponse
// ChannelArn: "STRING_VALUE",
// Member: { // Identity
// Arn: "STRING_VALUE",
// Name: "STRING_VALUE",
// },
// SubChannelId: "STRING_VALUE",
// };
CreateChannelMembershipCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
ChannelArn Required | string | undefined | The ARN of the channel to which you're adding users. |
ChimeBearer Required | string | undefined | The ARN of the |
MemberArn Required | string | undefined | The |
Type Required | ChannelMembershipType | undefined | The membership type of a user, |
SubChannelId | string | undefined | The ID of the SubChannel in the request. Only required when creating membership in a SubChannel for a moderator in an elastic channel. |
CreateChannelMembershipCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
ChannelArn | string | undefined | The ARN of the channel. |
Member | Identity | undefined | The ARN and metadata of the member being added. |
SubChannelId | string | undefined | The ID of the SubChannel in the response. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
BadRequestException | client | The input parameters don't match the service's restrictions. |
ConflictException | client | The request could not be processed because of conflict in the current state of the resource. |
ForbiddenException | client | The client is permanently forbidden from making the request. |
NotFoundException | client | One or more of the resources in the request does not exist in the system. |
ResourceLimitExceededException | client | The request exceeds the resource limit. |
ServiceFailureException | server | The service encountered an unexpected error. |
ServiceUnavailableException | server | The service is currently unavailable. |
ThrottledClientException | client | The client exceeded its request rate limit. |
UnauthorizedClientException | client | The client is not currently authorized to make the request. |
ChimeSDKMessagingServiceException | Base exception class for all service exceptions from ChimeSDKMessaging service. |