> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-auto-generate-llmstxt.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Member Management

> Add and remove community members with the community membership APIs

Use member management APIs when a moderator or admin needs to add users to a community or remove existing members. These APIs are separate from user-initiated join and leave flows.

> [!NOTE]
>
> Member management APIs require the current user to have the relevant community permissions. The SDK methods perform the operation; your app should query member lists afterward if the UI needs an updated collection.

## Parameters

| Operation | Parameter | Required | Description |
| - | - | - | - |
| Add members | `communityId` | Yes | Community ID whose membership should change. |
| Add members | `userIds` | Yes | User IDs to add to the community. |
| Remove members | `communityId` | Yes | Community ID whose membership should change. |
| Remove members | `userIds` | Yes | User IDs to remove from the community. |

## Add Members

Use `addMembers()` to add one or more users to a community.

```swift iOS theme={null}
let communityMembership = AmityCommunityMembership(communityId: communityId)

do {
    try await communityMembership.addMembers(["user1", "user2"])
} catch let error {
    handleError(error)
}
```

```kotlin Android theme={null}
fun addMembers(communityRepository: AmityCommunityRepository) {
    communityRepository
        .membership(communityId = "communityId")
        .addMembers(userIds = listOf("user1", "user2"))
        .doOnComplete {
            // Members added
        }
        .doOnError { throwable ->
            // Handle error
        }
        .subscribe()
}
```

```typescript TypeScript theme={null}
import { CommunityRepository } from '@amityco/ts-sdk';

async function addMembers(
  communityId: Amity.Community['communityId'],
  userIds: Amity.User['userId'][],
): Promise<boolean> {
  return CommunityRepository.Membership.addMembers(communityId, userIds);
}
```

```dart Flutter theme={null}
Future<void> addMembers(String communityId, List<String> userIds) async {
  await AmitySocialClient.newCommunityRepository()
      .membership(communityId)
      .addMembers(userIds);
}
```

## Remove Members

Use `removeMembers()` to remove one or more users from a community.

> [!WARNING]
>
> Removing members changes their community membership immediately. If the community requires approval, removed users may need to request access again before rejoining.

```swift iOS theme={null}
let communityMembership = AmityCommunityMembership(communityId: communityId)

do {
    try await communityMembership.removeMembers(["user1", "user2"])
} catch let error {
    handleError(error)
}
```

```kotlin Android theme={null}
fun removeMembers(communityRepository: AmityCommunityRepository) {
    communityRepository
        .membership(communityId = "communityId")
        .removeMembers(userIds = listOf("user1", "user2"))
        .doOnComplete {
            // Members removed
        }
        .doOnError { throwable ->
            // Handle error
        }
        .subscribe()
}
```

```typescript TypeScript theme={null}
import { CommunityRepository } from '@amityco/ts-sdk';

async function removeMembers(
  communityId: Amity.Community['communityId'],
  userIds: Amity.User['userId'][],
): Promise<boolean> {
  return CommunityRepository.Membership.removeMembers(communityId, userIds);
}
```

```dart Flutter theme={null}
Future<void> removeMembers(String communityId, List<String> userIds) async {
  await AmitySocialClient.newCommunityRepository()
      .membership(communityId)
      .removeMembers(userIds);
}
```

## Related Topics

> **[Community Moderation](./community-moderation)**
>
> Assign roles and ban or unban community members

> **[Join / Leave Community](./join-leave-community)**
>
> User-initiated membership workflows and approval requests

> **[Query Community Members](./query-community-members)**
>
> Search and filter community member lists

> **[Community Invitation](./community-invitation)**
>
> Invitation-based member onboarding workflows


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.