# Getting Started

Stream's Moderation API lets you integrate content moderation into any application. This guide walks you through installing one of the [backend SDKs](https://getstream.io/docs/platform/backend-sdks/), creating a policy, and running your first moderation check.

Moderation lives in the [Stream Dashboard](https://getstream.io/signin/?product=moderation), where you can create and tune policies, manage AI rules and blocklists, and review flagged content across your app.

## Start here

- [Moderate any content](https://getstream.io/moderation/docs/java/integrations/custom-content/): Check text, images, audio, and video from your own product.
- [Policies](https://getstream.io/moderation/docs/java/configuration/policies/): Choose which engines run and what happens when content matches.
- [Stream Chat integration](https://getstream.io/moderation/docs/java/integrations/stream-chat/): Moderate chat messages with no code changes.
- [Stream Feeds integration](https://getstream.io/moderation/docs/java/integrations/stream-feeds/): Automatically moderate activities and comments as they are created or updated.
- [Review Queue](https://getstream.io/moderation/docs/java/content-moderation/review-queue/): Review flagged content and act on it: approve, delete, or ban.
- [Live video and audio](https://getstream.io/moderation/docs/java/integrations/live-video-and-audio/): Moderate calls and livestreams in real time with keyframes and captions.

## Stream CLI and Agent Skills

Manage moderation from your terminal with the [Stream CLI](https://getstream.io/cli/docs/), including scripting policy setup and AI-agent workflows. Install the CLI and the default [Agent Skills](https://getstream.io/agent-skills/docs/):

```bash
curl -fsSL https://getstream.io/cli.sh | bash
getstream skills
```

Then ask your agent in plain English, for example:

```text
/stream Show flagged content in the review queue.
```

See the [CLI docs](https://getstream.io/cli/docs/) and [Agent Skills docs](https://getstream.io/agent-skills/docs/) for more.

## Installation

The SDK is published to the [Stream Maven repository](https://browse.stream-io-repo.com/releases/stream-sdk-java). Add the repository and the dependency to your `build.gradle`:

```groovy
repositories {
    mavenCentral()
    maven { url "https://stream-io-repo.com" }
}

dependencies {
    implementation 'io.getstream:stream-sdk-java:11.0.0'
}
```

Or Maven `pom.xml`:

```xml
<repositories>
    <repository>
        <id>stream</id>
        <url>https://stream-io-repo.com</url>
    </repository>
</repositories>

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

> Use the latest available SDK release when starting a new integration.
> `11.0.0` is the current release. Check [stream-sdk-java releases](https://github.com/GetStream/stream-sdk-java/releases) if a newer one is available.

## Initialize the client

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

var client = new StreamSDKClient("YOUR_API_KEY", "YOUR_API_SECRET");
```

## Create a moderation policy

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

```java
client.moderation()
    .upsertConfig(UpsertConfigRequest.builder()
        .key("my_config")
        .aiTextConfig(AITextConfig.builder()
            .rules(List.of(
                BodyguardRule.builder().label("SPAM").action("flag").build(),
                BodyguardRule.builder().label("HATRED").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](https://getstream.io/moderation/docs/java/configuration/policies/) for details.

## Check content

```java
var response = client.moderation()
    .check(CheckRequest.builder()
        .entityType("post")
        .entityID("post-123")
        .entityCreatorID("user-456")
        .moderationPayload(ModerationPayload.builder()
            .texts(List.of("Selling a bike, pickup in the city"))
            .build())
        .configKey("my_config")
        .build())
    .execute();

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

## Handle the response

The response includes:

- `recommendedAction` -- `"keep"`, `"flag"`, `"remove"`, `"shadow"`, `"bounce"`, `"bounce_flag"`, `"bounce_remove"`, `"mask"`, or `"mask_flag"`
- `status` -- `"completed"` or `"pending"` (`pending` means async checks are still running)
- `item` -- the review queue item (if content was flagged or removed)

The check returns a recommendation for your code to enforce. Stream adds flagged and removed content to the review queue:

```mermaid
flowchart TD
  content[Your content] --> check[Check API]
  check --> rec{recommended_action}
  rec -->|keep| keep[Publish it]
  rec -->|flag| queue[Review queue]
  rec -->|shadow| hidden[Show it only to the author]
  rec -->|remove| removed[Do not publish it]
  rec -->|bounce| bounced[Reject it before it is published]
  hidden --> queue
  removed --> queue
  queue --> review[Moderator marks it reviewed, restores it, or bans the user]
```

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

switch (action) {
    case "keep":
        // Content is safe, no action needed
        break;
    case "flag":
        // Content is suspicious; Stream has queued it for review
        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;
}
```

## What's next

- [Policies](https://getstream.io/moderation/docs/java/configuration/policies/): Choose which engines run and what happens when content matches.
- [Review queue](https://getstream.io/moderation/docs/java/content-moderation/review-queue/): Query and act on flagged content.
- [Webhooks](https://getstream.io/moderation/docs/java/content-moderation/webhooks/): Get review queue events delivered to your backend.
- [Client configuration](https://getstream.io/moderation/docs/java/guides/client-configuration/): HTTP defaults, timeouts, and connection pooling.

## FAQ

**Which engines can check content?**

LLM and NLP text engines, plus image, video and audio moderation. Start with the [LLM text engine](https://getstream.io/moderation/docs/java/engines/ai-llm-text/).

**Do messages sent from my server get moderated?**

Content sent to the Check API is always moderated. Chat messages sent from the server skip moderation by default; set `forceModeration` to `true` to include them. See [chat moderation](https://getstream.io/moderation/docs/java/integrations/stream-chat/#server-side-integration).

**Can tenants manage their own moderation?**

Yes, for chat. Tenants manage their own policies, with client-side access restricted to their team, and team blocklists need a feature flag from support. See [multitenancy](https://getstream.io/moderation/docs/java/configuration/multitenancy/).

**Can I build my own review dashboard?**

Yes, on the same APIs Stream's dashboard uses. The [dashboard guide](https://getstream.io/moderation/docs/java/guides/build-moderation-dashboard/) walks through it.

---

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