> ## 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.

# Ban Management

> Ban and unban chat channel members with the current SDK APIs.

Use channel bans when a member should lose access to a specific chat channel until a moderator restores access. The SDK operation is per-channel; ban reasons, appeal flows, and moderation audit logs are app-owned product logic.

## Platform Surface

| Operation     | TypeScript                                                      | iOS                                                   | Android                                       | Flutter                                       |
| ------------- | --------------------------------------------------------------- | ----------------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
| Ban members   | `ChannelRepository.Moderation.banMembers(channelId, userIds)`   | `AmityChannelModeration(channelId:).banMembers(_:)`   | `moderation(channelId).banMembers(userIds)`   | `moderation(channelId).banMembers(userIds)`   |
| Unban members | `ChannelRepository.Moderation.unbanMembers(channelId, userIds)` | `AmityChannelModeration(channelId:).unbanMembers(_:)` | `moderation(channelId).unbanMembers(userIds)` | `moderation(channelId).unbanMembers(userIds)` |
| Result        | Cached channel memberships                                      | `Void`                                                | `Completable`                                 | `Future`                                      |

## Parameters

| Parameter             | Required | Description                                                           |
| --------------------- | -------- | --------------------------------------------------------------------- |
| `channelId`           | Yes      | Channel ID where the ban or unban should be applied.                  |
| `userIds`             | Yes      | One or more user IDs to ban or unban. Empty lists are rejected.       |
| Moderation permission | Yes      | The current user must have permission to moderate the target channel. |

## Ban Members

Ban removes the users from channel participation and prevents them from rejoining until they are unbanned.

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

  const banned = await ChannelRepository.Moderation.banMembers(channelId, [
    userId,
  ]);

  renderResults(banned.data);
  ```

  ```swift iOS theme={null}
  let moderation = AmityChannelModeration(channelId: channelId)

  try await moderation.banMembers([userId])

  showSuccessMessage(channelId)
  ```

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

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

## Unban Members

Unban restores the users to the channel's allowed membership state. If your app shows a ban list, refresh that list after the operation succeeds.

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

  const unbanned = await ChannelRepository.Moderation.unbanMembers(channelId, [
    userId,
  ]);

  renderResults(unbanned.data);
  ```

  ```swift iOS theme={null}
  let moderation = AmityChannelModeration(channelId: channelId)

  try await moderation.unbanMembers([userId])

  showSuccessMessage(channelId)
  ```

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

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

## Implementation Notes

<CardGroup cols={2}>
  <Card title="Permission Checks" icon="shield">
    The SDK call can fail when the current user cannot moderate the channel or the target user cannot be moderated. Handle permission and validation errors in your UI.
  </Card>

  <Card title="Channel Scope" icon="message">
    A channel ban applies to the target channel. It is not a global user block and does not replace user-level block or content flag workflows.
  </Card>

  <Card title="Product Policy" icon="gavel">
    Store ban reasons, moderator notes, appeal state, or compliance records in your own system if your product requires them.
  </Card>

  <Card title="Member Lists" icon="users">
    Query channel members with banned-membership filters when you need to render a ban list or confirm current ban state.
  </Card>
</CardGroup>

## Related Topics

<CardGroup cols={3}>
  <Card title="Query Members" href="/social-plus-sdk/chat/conversation-management/members/query-members" icon="users">
    Filter channel members by membership state.
  </Card>

  <Card title="Mute Management" href="./mute-management" icon="microphone-slash">
    Temporarily restrict message sending.
  </Card>

  <Card title="Member Management" href="./member-management" icon="user-plus">
    Add or remove channel members.
  </Card>
</CardGroup>
