Content

Send content to Stream and get a keep, flag, or remove decision. There are two endpoints. Both use the same policies and rules.

Which should I use?

CheckAnalyze
Start here ifYou have image URLs and want one actionYou need a verdict per field, or you have image bytes
Requestclient.moderation.checkclient.moderation.analyze
ImagesPublic URLs in moderation_payload.imagesRaw bytes via HTTP multipart (image:<label>). Not in the SDK
TextsA list of stringsA map of named fields (title, caption, …)
ResultOne recommended_action for the entityPer-field action on texts and images
SDKsAll server-side SDKsAll server-side SDKs for texts. Image bytes are HTTP only
Review queueYesStateful mode only (when you send entity fields)

Use Custom Check when your own model already classified the content and you want that result on the dashboard.

Examples below use the server-side SDKs. See the setup guides for Node, Python, Go, Java, PHP, Ruby, or .NET.

Check

Submit text, image URLs, and/or video URLs. Get back one recommended_action (keep, flag, or remove) and a review-queue item you can show on a custom dashboard.

  1. Create a policy with engines and actions
  2. Call check with your entity ids and config_key
  3. Apply recommended_action in your product
  4. Review flagged items in the dashboard or via the review queue API

API Usage

In the context of the Moderation API, the term "entity" refers to a piece of content that you send for moderation. This can be text, an image, and/or a video.

$response = $client->moderation()->check(new CheckRequest(
    entityCreatorID: 'entity_creator_id',
    entityID: 'entity_id',
    entityType: 'entity_type',
    moderationPayload: new ModerationPayload(
        texts: ['this is bullshit', 'f*ck you as***le'],
        images: ['example.com/test.jpg'],
    ),
    configKey: 'config_key',
    options: (object)['force_sync' => true],
));

Request Params

keyrequiredtypedescription
entity_typetruestringThis is identifier for the type of content you are sending for moderation. This helps with categorizing content on dashboard. E.g., if you have multiple products then you can set unique entity_type for content coming from each product. It could be any string.
entity_idtruestringUnique identifier for entity
entity_creator_idtruestringUnique identifier for user who created this entity. Generally this is the user id of the app user.
moderation_payloadtrueobjectEntity or content to be moderated
config_keytruestringKey of the config to be used for moderation. See Configuration for details.

Response

keytypedescription
status“complete” , “partial”Status of moderation. In case you have configured both synchronous and asynchronous (image moderation) moderations, then status will be “partial”. This is because async moderations are still running in background task.
task_idstringId of the task running the async moderation. You can check the status of the task itself using GetTask endpoint.
recommended_action“flag” , “remove” , “keep”Final result of moderation which suggest what action should be taken for moderated entity.
  • “flag” suggests that the content needs manual review either on Stream dashboard or custom dashboard you may have
  • “remove” suggests that this content should be removed from the platform. You will be able to access/review this content from Stream dashboard
  • “keep” suggests that this content is safe and doesn’t contain any harms
itemobjectThis is basically a json representation of the review queue item accessible on Stream dashboard. You can use this to compose your own dashboard UI.

Analyze

Submit named text fields and get a keep / flag / remove decision per label. Use it when you need a verdict per field instead of one action for the whole entity.

Server-side only. Call analyze the same way as check for named texts. At least one text field or image is required.

Raw image bytes are not in the SDK. Send them with an HTTP multipart/form-data request: one JSON payload part plus image:<label> file parts. That is the only way to attach bytes today.

Modes

Stateful vs stateless. Send entity_type, entity_id, and entity_creator_id together to persist a review-queue row (when content is flagged) and evaluate rules. Omit all three for a stateless call: verdicts only, no queue, no webhooks. config_key is required when stateless. Partial entity fields return 400.

entity_type is yours (listing, external:call). Types that start with stream: are reserved. You may add a subtype for routing (external:call:keyframe); webhooks echo the canonical type (external:call).

Sync vs async. Default is sync: verdicts in the HTTP body. Set async_response: true (stateful only) to get status: "pending" and receive moderation.text_analysis.complete / moderation.image_analysis.complete webhooks instead. Do not send async_response: true without entity fields.

Calling Analyze

$response = $client->moderation()->analyze(new AnalyzeRequest(
    entityCreatorID: 'user_42',
    entityID: 'listing_42',
    entityType: 'listing',
    configKey: 'catalog-v1',
    contentIds: ['caption' => 'cap_42'],
    texts: ['caption' => 'Vintage watch, mint condition'],
));

Image bytes (HTTP only)

client.moderation.analyze sends the JSON fields above. It cannot attach files. To send raw image bytes, POST multipart/form-data yourself (max 10 images, 250 KB each by default, 20 MB for the whole request):

curl -X POST "https://chat.stream-io-api.com/api/v2/moderation/analyze?api_key=${API_KEY}" \
  -H "Authorization: ${TOKEN}" \
  -H "stream-auth-type: jwt" \
  -F 'payload={"entity_type":"listing","entity_id":"listing_42","entity_creator_id":"user_42","config_key":"catalog-v1","texts":{"caption":"Vintage watch, mint condition"},"content_ids":{"caption":"cap_42","main_photo":"img_42_main"}};type=application/json' \
  -F "image:main_photo=@frame.jpg;type=image/jpeg"

Analyze request

keyrequiredtypedescription
entity_typewith the other entity fieldsstringCaller-defined type. Required with entity_id and entity_creator_id. Omit all three for stateless mode
entity_idwith the other entity fieldsstringYour identifier for this content
entity_creator_idwith the other entity fieldsstringUser id of the content creator
config_keystateless: yesstringPolicy key. Optional in stateful mode (resolved from entity_type). Unknown keys return 422
textsnoobjectNamed text fields, keyed by your label. Max 20 keys, each 1 to 64 characters
content_idsnoobjectPer-field ids keyed by the same labels as texts or image:<label>. Echoed as id on each verdict. Values: 1 to 128 chars, A-Z a-z 0-9 . _ -
content_published_atnostring (RFC3339)When the content was produced. Used as the score for aggregation-rule windows
customnoobjectMetadata stored on the review-queue item and echoed on webhooks
async_responsenoboolStateful only. When true, HTTP is pending and verdicts arrive via webhooks

Images: HTTP only. Each file part is named image:<label>. Max 10 images, 250 KB each by default, 20 MB for the whole request. The SDK analyze method does not accept file parts.

Analyze response

Successful calls return 201.

keytypedescription
statuscomplete, partial, pendingcomplete if every field was screened. partial if some have error. pending is the async ack
textsobjectPer-text verdicts keyed by your label. Absent on async pending
imagesobjectPer-image verdicts keyed by your label
durationstringServer wall-clock duration

Each text or image field:

keydescription
idEcho of content_ids[<label>] when you sent one
actionkeep, flag, or remove. Omitted when error is set. Never treat a missing action as keep
classificationsText: { name, severity }. Image: { name, confidence, subclassifications }
severityText only. Highest severity across classifications (low, medium, high, critical)
languageText only. Detected language code
confidenceImage only. Highest confidence (0 to 1)
ocr_classificationsImage only. Text labels extracted from the image (name, severity)
errorField could not be screened. Retry this label only
{
  "status": "complete",
  "texts": {
    "caption": {
      "id": "cap_42",
      "action": "flag",
      "classifications": [{ "name": "INSULT", "severity": "high" }],
      "severity": "high",
      "language": "en"
    }
  },
  "images": {
    "main_photo": {
      "id": "img_42_main",
      "action": "keep"
    }
  }
}

If some fields fail, status is partial (still 201). Retry only the labels with error. If nothing could be screened, the API returns 503 with a standard error envelope, not this body. Bad input is 400. A missing policy is 422.

Async pending body:

{ "status": "pending", "duration": "112.84ms" }

Wait for Analyze webhook events. A provider error stays on *.complete as field error. moderation.analysis.failed means Stream could not finish the listed content_ids after the pending ack. Treat those ids as unscreened.

Custom Check

Custom Check enables you to submit your own AI moderation results of a chat message/custom uploaded content for review by moderators on the Dashboard.

Add Custom Flags to a Chat Message

Custom Flags can be added to a Chat message. This enables you to submit your own AI moderation results of a chat message for review by moderators on the Dashboard.

$client->moderation()->customCheck(new CustomCheckRequest(
    entityType: 'stream:chat:v1:message',
    entityID: $messageId,
    entityCreatorID: 'user_id',
    flags: [
        new CustomCheckFlag(type: 'custom_check_image', reason: 'Image was NSFW', labels: ['NSFW']),
        new CustomCheckFlag(type: 'custom_check_text', reason: 'Text was harmful', labels: ['harmful']),
        new CustomCheckFlag(type: 'custom_check_video', reason: 'Video contains copyright material', labels: ['copyright-violation']),
    ],
));

Add Custom Check Flags to the Custom Content

The Custom Check endpoint enables you to submit your own AI moderation results for the custom content for review by moderators on the Dashboard.

$client->moderation()->customCheck(new CustomCheckRequest(
    entityType: 'entity_type',
    entityID: 'entity_id',
    entityCreatorID: 'entity_creator_id',
    moderationPayload: new ModerationPayload(texts: ['offensive']),
    flags: [
        new CustomCheckFlag(
            type: 'custom_check_text',
            reason: 'Text was offensive',
            custom: (object)['explaination' => 'custom is a nullable field allowing you to attach a custom object to the flag for your specific use cases or requirements'],
        ),
    ],
));

Request Params

keyrequiredtypedescription
entity_typetruestringThis is identifier for the type of the entity. This helps with categorizing Content.
entity_idtruestringUnique identifier for entity.
entity_creator_idtruestringUnique identifier for user who created this entity. Generally this is the user id of the app user.
moderation_payloadtrueobjectEntity or content to be moderated
flagstruearrayList of custom flags
flag.typetrue"custom_check_text", "custom_check_image", "custom_check_video"Type of a custom flag

Response

keytypedescription
status“complete” , “partial”Status of moderation. In case you have configured both synchronous and asynchronous (image moderation) moderations, then status will be “partial”. This is because async moderations are still running in background task.
idstringid of the review queue item.
itemobjectThis is basically a json representation of the review queue item accessible on Stream dashboard. You can use this to compose your own dashboard UI.