# 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

```bash
composer require getstream/getstream-php
```

## Initialize the Client

```php
use GetStream\ClientBuilder;

$client = ClientBuilder::apiKey('YOUR_API_KEY')
    ->apiSecret('YOUR_API_SECRET')
    ->buildModerationClient();
```

## Create a Moderation Policy

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

```php
$client->upsertConfig(new UpsertConfigRequest(
    key: 'my_config',
    aiTextConfig: new AiTextConfig(
        rules: [
            new AiTextRule(label: 'SPAM', action: 'flag'),
            new AiTextRule(label: 'HARASSMENT', action: 'remove'),
        ],
    ),
    blockListConfig: new BlockListConfig(
        rules: [
            new BlockListRule(name: 'profanity_en', action: 'remove'),
        ],
    ),
));
```

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

## Check Content

```php
$response = $client->check(new CheckRequest(
    entityType: 'stream:chat:v1:message',
    entityID: 'message-123',
    entityCreatorID: 'user-456',
    moderationPayload: new ModerationPayload(
        texts: ['Hello, this is a test message'],
    ),
    configKey: 'my_config',
));

echo $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)

```php
$action = $response->getData()->getRecommendedAction();

if ($action === 'keep') {
    // Content is safe, no action needed
} elseif ($action === 'flag') {
    // Content is suspicious, send to review queue
    echo 'Flagged for review: ' . print_r($response->getData()->getItem(), true);
} elseif ($action === 'remove') {
    // Content violates policies, remove it
    echo 'Content removed: ' . print_r($response->getData()->getItem(), true);
}
```

## Next Steps

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


---

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

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