# Moderation

Stream Feeds has support for moderation, allowing you to manage user interactions, content moderation, and platform safety. It's accessible through the `client.moderation` property.

## Overview

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let client = FeedsClient(apiKey: apiKey, user: user, token: token)
let moderation = client.moderation
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
const client = new FeedsClient("<API key>");

client.moderation;
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
const apiKey = "";
const secret = "";
const client = new StreamClient(apiKey, secret);

client.moderation;
```

</codetabs-item>

</codetabs>

## User Moderation

### Ban Users

Ban a user from the platform with various options including timeout, shadow bans, and IP bans.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let banRequest = BanRequest(
    targetUserId: "user-123",
    reason: "Violation of community guidelines",
    timeout: 3600, // 1 hour in seconds
    shadow: false,
    ipBan: false
)

let response = try await client.moderation.ban(banRequest: banRequest)
print("User banned for: \(response.duration)")
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
await client.moderation.ban({
  target_user_id: "user-123",
  reason: "Violation of community guidelines",
  timeout: 3600, // 1 hour in seconds
  shadow: false,
  ip_ban: false,
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
await client.moderation.ban({
  target_user_id: "user-123",
  banned_by_id: "<banned by user id>",
  reason: "Violation of community guidelines",
  timeout: 3600, // 1 hour in seconds
  shadow: false,
  ip_ban: false,
});
```

</codetabs-item>

</codetabs>

**Parameters:**

- `targetUserId`: The ID of the user to ban
- `reason`: Optional reason for the ban
- `timeout`: Optional timeout in seconds (null for permanent ban)
- `shadow`: Whether to perform a shadow ban (user doesn't know they're banned)
- `ipBan`: Whether to ban the user's IP address
- `bannedBy`: Optional user who performed the ban
- `deleteMessages`: Whether to delete user's messages

### Mute Users

Mute one or more users to prevent them from interacting with your content.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let muteRequest = MuteRequest(
    targetIds: ["user-123", "user-456"],
    timeout: 86400 // 24 hours in seconds
)

let response = try await client.moderation.mute(muteRequest: muteRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.mute({
  target_ids: ["user-123", "user-456"],
  timeout: 86400, // 24 hours in seconds
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.mute({
  target_ids: ["user-123", "user-456"],
  user_id: "<moderator id>",
  timeout: 86400, // 24 hours in seconds
});
```

</codetabs-item>

</codetabs>

**Parameters:**

- `targetIds`: Array of user IDs to mute
- `timeout`: Optional timeout in seconds (null for permanent mute)

### Block Users

Block a user to prevent them from following you or seeing your content.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let blockRequest = BlockUsersRequest(blockedUserId: "user-123")
let response = try await client.moderation.blockUsers(blockUsersRequest: blockRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
await client.blockUsers({
  blocked_user_id: "user-123",
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
await client.blockUsers({
  blocked_user_id: "user-123",
  user_id: "<moderator id>",
});
```

</codetabs-item>

</codetabs>

### Unblock Users

Unblock a previously blocked user.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let unblockRequest = UnblockUsersRequest(blockedUserId: "user-123")
let response = try await client.moderation.unblockUsers(unblockUsersRequest: unblockRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.unblockUsers({
  blocked_user_id: "user-123",
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.unblockUsers({
  blocked_user_id: "user-123",
  user_id: "<moderator user id>",
});
```

</codetabs-item>

</codetabs>

### Get Blocked Users

Retrieve a list of users you have blocked.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let blockedUsers = try await client.moderation.getBlockedUsers()
for user in blockedUsers.users {
    print("Blocked user: \(user.id)")
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.getBlockedUsers();
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.getBlockedUsers({ user_id: "<moderator user id>" });
```

</codetabs-item>

</codetabs>

## Content Moderation

### Flag Content

Flag inappropriate content for moderation review.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let flagRequest = FlagRequest(
    entityId: "activity-123",
    entityType: "activity",
    reason: "Inappropriate content",
    entityCreatorId: "user-456"
)

let response = try await client.moderation.flag(flagRequest: flagRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
await client.moderation.flag({
  entity_type: "activity",
  entity_id: "activity_123",
  reason: "Inappropriate content",
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
await client.moderation.flag({
  entity_type: "activity",
  entity_id: "activity_123",
  reason: "Inappropriate content",
  user_id: "<moderator user id>",
});
```

</codetabs-item>

</codetabs>

**Parameters:**

- `entityId`: The ID of the content to flag
- `entityType`: The type of content (e.g., "activity", "comment")
- `reason`: Optional reason for flagging
- `entityCreatorId`: Optional ID of the content creator
- `custom`: Optional custom data for the flag

### Submit Moderation Actions

Submit moderation actions for flagged content.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let actionRequest = SubmitActionRequest(
    // Action details for moderation
)

let response = try await client.moderation.submitAction(submitActionRequest: actionRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.submitAction({
  // Action details for moderation
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.submitAction({
  // Action details for moderation
  user_id: "<user id>",
});
```

</codetabs-item>

</codetabs>

## Review Queue

### Query Review Queue

Retrieve items in the moderation review queue.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let queryRequest = QueryReviewQueueRequest(
    // Query parameters for filtering and pagination
)

let reviewQueue = try await client.moderation.queryReviewQueue(queryReviewQueueRequest: queryRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.queryReviewQueue({
  // Query parameters for filtering and pagination
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.queryReviewQueue({
  // Query parameters for filtering and pagination
  user_id: user.id,
});
```

</codetabs-item>

</codetabs>

## Configuration Management

### Upsert Moderation Configuration

Create or update moderation configuration settings.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let configRequest = UpsertConfigRequest(
    // Configuration details
)

let response = try await client.moderation.upsertConfig(upsertConfigRequest: configRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.upsertConfig({
    key: 'feeds',
    block_list_config: {
        enabled: true,
        rules: [
        // Names of existing block lists
        { name: blocklistName, action: 'remove', team: '' },
        { name: flagBlocklistName, action: 'flag', team: '' },
        { name: shadowBlocklistName, action: 'shadow', team: '' },
        { name: bounceBlocklistName, action: 'bounce', team: '' },
        ],
    },
    ai_image_config: {
        enabled: true,
        rules: [{ label: 'Non-Explicit Nudity', action: 'remove', min_confidence: 0 }],
        ocr_rules: [{ label: 'Non-Explicit Nudity', action: 'remove' }],
    },
}),
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.upsertConfig({
    key: 'feeds',
    block_list_config: {
        enabled: true,
        rules: [
        // Names of existing block lists
        { name: blocklistName, action: 'remove', team: '' },
        { name: flagBlocklistName, action: 'flag', team: '' },
        { name: shadowBlocklistName, action: 'shadow', team: '' },
        { name: bounceBlocklistName, action: 'bounce', team: '' },
        ],
    },
    ai_image_config: {
        enabled: true,
        rules: [{ label: 'Non-Explicit Nudity', action: 'remove', min_confidence: 0 }],
        ocr_rules: [{ label: 'Non-Explicit Nudity', action: 'remove' }],
    },
}),
```

</codetabs-item>

</codetabs>

### Get Moderation Configuration

Retrieve a specific moderation configuration.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let config = try await client.moderation.getConfig(key: "automod_settings", team: "team-123")
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.getConfig({
  key: "feeds",
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.getConfig({
  key: "feeds",
});
```

</codetabs-item>

</codetabs>

**Parameters:**

- `key`: The configuration key to retrieve
- `team`: Optional team identifier

### Delete Moderation Configuration

Remove a moderation configuration.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let response = try await client.moderation.deleteConfig(key: "automod_settings", team: "team-123")
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.deleteConfig({
  key: "feeds",
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.deleteConfig({
  key: "feeds",
});
```

</codetabs-item>

</codetabs>

### Query Moderation Configurations

Search and filter moderation configurations.

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
let queryRequest = QueryModerationConfigsRequest(
    // Query parameters for filtering and pagination
)

let configs = try await client.moderation.queryModerationConfigs(queryModerationConfigsRequest: queryRequest)
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
client.moderation.queryModerationConfigs({
  filter: {
    // Filter params
  },
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
client.moderation.queryModerationConfigs({
  filter: {
    // Filter params
  },
});
```

</codetabs-item>

</codetabs>

## Error Handling

All moderation methods can throw errors. Handle them appropriately:

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift
do {
    let response = try await client.moderation.ban(banRequest: banRequest)
    print("User banned successfully")
} catch {
    print("Failed to ban user: \(error)")
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
try {
  const response = await client.moderation.ban({
    target_user_id: "user-123",
    reason: "Violation of community guidelines",
    timeout: 3600, // 1 hour in seconds
    shadow: false,
    ip_ban: false,
  });

  console.log(`Banned successfully`);
} catch (e) {
  console.error(`Failed to ban user, error: ${e}`);
}
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
try {
  const response = await client.moderation.ban({
    target_user_id: "user-123",
    banned_by_id: "<banned by user id>",
    reason: "Violation of community guidelines",
    timeout: 3600, // 1 hour in seconds
    shadow: false,
    ip_ban: false,
  });

  console.log(`Banned successfully`);
} catch (e) {
  console.error(`Failed to ban user, error: ${e}`);
}
```

</codetabs-item>

</codetabs>

---

This page was last updated at 2025-08-15T14:14:10.846Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/react-native/moderation/](https://getstream.io/activity-feeds/docs/react-native/moderation/).