# Getting Started

Stream's Moderation API lets you integrate content moderation into any application. This guide walks you through installation, configuration, and your first moderation check.

## Installation

Add to your `build.gradle`:

```groovy
dependencies {
    implementation 'io.getstream:stream-sdk-java:7.+'
}
```

Or Maven `pom.xml`:

```xml
<dependency>
    <groupId>io.getstream</groupId>
    <artifactId>stream-sdk-java</artifactId>
    <version>7.0.0</version>
</dependency>
```

## Initialize the Client

```java
import io.getstream.services.framework.StreamSDKClient;

var client = StreamSDKClient.builder()
    .apiKey("YOUR_API_KEY")
    .apiSecret("YOUR_API_SECRET")
    .build();
```

## Create a Moderation Policy

Before checking content, create a moderation configuration that defines which rules to apply:

```java
client.moderation()
    .upsertConfig(UpsertConfigRequest.builder()
        .key("my_config")
        .aiTextConfig(AiTextConfig.builder()
            .rules(List.of(
                AiTextRule.builder().label("SPAM").action("flag").build(),
                AiTextRule.builder().label("HARASSMENT").action("remove").build()
            ))
            .build())
        .blockListConfig(BlockListConfig.builder()
            .rules(List.of(
                BlockListRule.builder().name("profanity_en").action("remove").build()
            ))
            .build())
        .build())
    .execute();
```

> For Stream Chat, use config key `chat:messaging`. For Stream Feeds, use `feeds`. See [Configuration](/moderation/docs/java/configuration/policies/) for details.

## Check Content

```java
var response = client.moderation()
    .check(CheckRequest.builder()
        .entityType("stream:chat:v1:message")
        .entityID("message-123")
        .entityCreatorID("user-456")
        .moderationPayload(ModerationPayload.builder()
            .texts(List.of("Hello, this is a test message"))
            .build())
        .configKey("my_config")
        .build())
    .execute();

System.out.println(response.getData().getRecommendedAction()); // "keep", "flag", or "remove"
```

## Handle the Response

The response includes:

- `getRecommendedAction()` -- `"keep"`, `"flag"`, or `"remove"`
- `getStatus()` -- `"complete"` or `"partial"` (if async checks are still running)
- `getItem()` -- the review queue item (if content was flagged or removed)

```java
String action = response.getData().getRecommendedAction();

switch (action) {
    case "keep":
        // Content is safe, no action needed
        break;
    case "flag":
        // Content is suspicious, send to review queue
        System.out.println("Flagged for review: " + response.getData().getItem());
        break;
    case "remove":
        // Content violates policies, remove it
        System.out.println("Content removed: " + response.getData().getItem());
        break;
}
```

## Next Steps

- [Configuration](/moderation/docs/java/configuration/policies/) -- Advanced policy setup
- [Stream Chat Integration](/moderation/docs/java/integrations/stream-chat/) -- Chat moderation
- [Stream Feeds Integration](/moderation/docs/java/integrations/stream-feeds/) -- Feeds moderation
- [Review Queue](/moderation/docs/java/content-moderation/review-queue/) -- Query and act on flagged content
- [Client Configuration](/moderation/docs/java/guides/client-configuration/) — HTTP defaults, timeouts, and connection pooling


---

This page was last updated at 2026-04-16T18:29:40.110Z.

For the most recent version of this documentation, visit [https://getstream.io/moderation/docs/java/](https://getstream.io/moderation/docs/java/).