> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Member Management

> Add and remove chat channel members with the current SDK APIs.

Use member management when your app needs to add users to a channel or remove users from a channel. Channel type, membership rules, and moderator permissions can still determine whether a request is accepted by the server.

## Platform Surface

| Operation      | TypeScript                                                       | iOS                                                    | Android                                        | Flutter                             |
| -------------- | ---------------------------------------------------------------- | ------------------------------------------------------ | ---------------------------------------------- | ----------------------------------- |
| Add members    | `ChannelRepository.Membership.addMembers(channelId, userIds)`    | `AmityChannelMembership(channelId:).addMembers(_:)`    | `membership(channelId).addMembers(userIds)`    | `addMembers(channelId, userIds)`    |
| Remove members | `ChannelRepository.Membership.removeMembers(channelId, userIds)` | `AmityChannelMembership(channelId:).removeMembers(_:)` | `membership(channelId).removeMembers(userIds)` | `removeMembers(channelId, userIds)` |
| Result         | `Promise<boolean>`                                               | `Void`                                                 | `Completable`                                  | `Future`                            |

## Parameters

| Parameter             | Required | Description                                                                |
| --------------------- | -------- | -------------------------------------------------------------------------- |
| `channelId`           | Yes      | Channel ID whose membership should change.                                 |
| `userIds`             | Yes      | One or more user IDs to add or remove. Empty lists are rejected.           |
| Membership permission | Yes      | The current user must be allowed to manage members for the target channel. |

## Add Members

Add members when an existing channel should include additional users. For conversation channels, prefer the conversation creation APIs when creating the conversation membership for the first time.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ChannelRepository } from '@amityco/ts-sdk';

  const didAdd = await ChannelRepository.Membership.addMembers(channelId, [
    userId,
  ]);

  if (didAdd) {
    showSuccessMessage(channelId);
  }
  ```

  ```swift iOS theme={null}
  let membership = AmityChannelMembership(channelId: channelId)

  try await membership.addMembers([userId])

  showSuccessMessage(channelId)
  ```

  ```kotlin Android theme={null}
  val disposable = channelRepository
      .membership(channelId = channelId)
      .addMembers(userIds = listOf(targetUserId))
      .subscribe(
          { showSuccessMessage(channelId) },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  await AmityChatClient.newChannelRepository()
      .addMembers(channelId, [targetUserId]);
  ```
</CodeGroup>

## Remove Members

Remove members when users should no longer participate in the channel. If the user is currently viewing the channel, update the route or composer state after removal succeeds.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ChannelRepository } from '@amityco/ts-sdk';

  const didRemove = await ChannelRepository.Membership.removeMembers(channelId, [
    userId,
  ]);

  if (didRemove) {
    showSuccessMessage(channelId);
  }
  ```

  ```swift iOS theme={null}
  let membership = AmityChannelMembership(channelId: channelId)

  try await membership.removeMembers([userId])

  showSuccessMessage(channelId)
  ```

  ```kotlin Android theme={null}
  val disposable = channelRepository
      .membership(channelId = channelId)
      .removeMembers(userIds = listOf(targetUserId))
      .subscribe(
          { showSuccessMessage(channelId) },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  await AmityChatClient.newChannelRepository()
      .removeMembers(channelId, [targetUserId]);
  ```
</CodeGroup>

## Implementation Notes

<CardGroup cols={2}>
  <Card title="Bulk Input" icon="users">
    All platforms accept a list of user IDs, so use one call for a small batch instead of looping one user at a time.
  </Card>

  <Card title="Channel Rules" icon="lock">
    Some channel types or roles can reject member changes. Treat failures as server authority, not as local state to override.
  </Card>

  <Card title="Current User" icon="user-check">
    Use join and leave APIs when the current user is entering or exiting a channel themselves.
  </Card>

  <Card title="Member State" icon="list">
    Query members after add or remove operations when your UI needs confirmed membership, role, or banned-state data.
  </Card>
</CardGroup>

## Related Topics

<CardGroup cols={3}>
  <Card title="Join and Leave" href="/social-plus-sdk/chat/conversation-management/members/join-leave-channel" icon="door-open">
    Let the current user join or leave a channel.
  </Card>

  <Card title="Query Members" href="/social-plus-sdk/chat/conversation-management/members/query-members" icon="users">
    Retrieve and filter channel membership.
  </Card>

  <Card title="Role Management" href="./role-management" icon="user-gear">
    Assign channel roles to members.
  </Card>
</CardGroup>
