import ModerationAPI from '@moderation-api/sdk';
const client = new ModerationAPI({
secretKey: process.env['MODAPI_SECRET_KEY'], // This is the default and can be omitted
});
const response = await client.content.submit({ content: { text: 'text', type: 'text' } });
console.log(response.author);import os
from moderation_api import ModerationAPI
client = ModerationAPI(
secret_key=os.environ.get("MODAPI_SECRET_KEY"), # This is the default and can be omitted
)
response = client.content.submit(
content={
"text": "text",
"type": "text",
},
)
print(response.author)require "moderation_api"
moderation_api = ModerationAPI::Client.new(secret_key: "My Secret Key")
response = moderation_api.content.submit(content: {text: "text", type: :text})
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use ModerationAPI\Client;
use ModerationAPI\Core\Exceptions\APIException;
$client = new Client(secretKey: getenv('MODAPI_SECRET_KEY') ?: 'My Secret Key');
try {
$response = $client->content->submit(
content: ['text' => 'text', 'type' => 'text'],
authorID: 'authorId',
channel: 'channel',
clientAction: [
'action' => 'review',
'behavior' => 'override',
'reason' => 'reason',
'source' => 'source',
],
contentID: 'contentId',
conversationID: 'conversationId',
doNotStore: true,
metadata: ['foo' => 'bar'],
metaType: 'profile',
policies: [['id' => 'toxicity', 'flag' => true, 'threshold' => 0]],
timestamp: 0,
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using ModerationApi;
using ModerationApi.Models.Content;
ModerationApiClient client = new();
ContentSubmitParams parameters = new() { Content = new Text("text") };
var response = await client.Content.Submit(parameters);
Console.WriteLine(response);{
"content": {
"id": "<string>",
"masked": true,
"modified": "<string>",
"transcript": "<string>"
},
"author": {
"id": "<string>",
"block": {
"until": 123,
"reason": "<string>"
},
"status": "enabled",
"trust_level": {
"level": 123,
"manual": true
},
"external_id": "<string>"
},
"evaluation": {
"flagged": true,
"flag_probability": 123,
"severity_score": 123,
"unicode_spoofed": true,
"shadow_flagged": true
},
"recommendation": {
"action": "review",
"reason_codes": [
"severity_reject"
],
"matched_rules": [
{
"key": "<string>",
"name": "<string>"
}
]
},
"policies": [
{
"id": "<string>",
"type": "classifier",
"probability": 0.5,
"flagged": true,
"flagged_fields": [
"<string>"
],
"labels": [
{
"id": "<string>",
"probability": 0.5,
"flagged": true
}
],
"data": {}
}
],
"insights": [
{
"id": "sentiment",
"type": "insight",
"probability": 0.5,
"value": "positive"
}
],
"meta": {
"status": "success",
"timestamp": 123,
"channel_key": "<string>",
"usage": 123,
"processing_time": "<string>"
},
"errors": [
{
"id": "<string>",
"message": "<string>"
}
]
}{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Submit content
Submit text, image, video, audio, or object content for moderation analysis.
import ModerationAPI from '@moderation-api/sdk';
const client = new ModerationAPI({
secretKey: process.env['MODAPI_SECRET_KEY'], // This is the default and can be omitted
});
const response = await client.content.submit({ content: { text: 'text', type: 'text' } });
console.log(response.author);import os
from moderation_api import ModerationAPI
client = ModerationAPI(
secret_key=os.environ.get("MODAPI_SECRET_KEY"), # This is the default and can be omitted
)
response = client.content.submit(
content={
"text": "text",
"type": "text",
},
)
print(response.author)require "moderation_api"
moderation_api = ModerationAPI::Client.new(secret_key: "My Secret Key")
response = moderation_api.content.submit(content: {text: "text", type: :text})
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use ModerationAPI\Client;
use ModerationAPI\Core\Exceptions\APIException;
$client = new Client(secretKey: getenv('MODAPI_SECRET_KEY') ?: 'My Secret Key');
try {
$response = $client->content->submit(
content: ['text' => 'text', 'type' => 'text'],
authorID: 'authorId',
channel: 'channel',
clientAction: [
'action' => 'review',
'behavior' => 'override',
'reason' => 'reason',
'source' => 'source',
],
contentID: 'contentId',
conversationID: 'conversationId',
doNotStore: true,
metadata: ['foo' => 'bar'],
metaType: 'profile',
policies: [['id' => 'toxicity', 'flag' => true, 'threshold' => 0]],
timestamp: 0,
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using ModerationApi;
using ModerationApi.Models.Content;
ModerationApiClient client = new();
ContentSubmitParams parameters = new() { Content = new Text("text") };
var response = await client.Content.Submit(parameters);
Console.WriteLine(response);{
"content": {
"id": "<string>",
"masked": true,
"modified": "<string>",
"transcript": "<string>"
},
"author": {
"id": "<string>",
"block": {
"until": 123,
"reason": "<string>"
},
"status": "enabled",
"trust_level": {
"level": 123,
"manual": true
},
"external_id": "<string>"
},
"evaluation": {
"flagged": true,
"flag_probability": 123,
"severity_score": 123,
"unicode_spoofed": true,
"shadow_flagged": true
},
"recommendation": {
"action": "review",
"reason_codes": [
"severity_reject"
],
"matched_rules": [
{
"key": "<string>",
"name": "<string>"
}
]
},
"policies": [
{
"id": "<string>",
"type": "classifier",
"probability": 0.5,
"flagged": true,
"flagged_fields": [
"<string>"
],
"labels": [
{
"id": "<string>",
"probability": 0.5,
"flagged": true
}
],
"data": {}
}
],
"insights": [
{
"id": "sentiment",
"type": "insight",
"probability": 0.5,
"value": "positive"
}
],
"meta": {
"status": "success",
"timestamp": 123,
"channel_key": "<string>",
"usage": 123,
"processing_time": "<string>"
},
"errors": [
{
"id": "<string>",
"message": "<string>"
}
]
}{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Text
- Text
- Image
- Video
- Audio
- Object
Show child attributes
Show child attributes
Unix timestamp (in milliseconds) of when the content was created. Use if content is not submitted in real-time.
Provide a channel ID or key. Will use the project's default channel if not provided.
The unique ID of the content in your database.
100The meta type of content being moderated
profile, message, post, comment, event, product, review, voice, other The author of the content.
For example the ID of a chat room or a post
Any metadata you want to store with the content
Show child attributes
Show child attributes
A recommendation from your own client-side flagging (e.g. a banned-IP list or a third-party tool). Feeds the rules engine and can escalate or override the recommended action. Does not change whether our analysis flagged the content.
Show child attributes
Show child attributes
Do not store the content. The content won't enter the review queue
(Enterprise) override the channel policies for this moderation request only.
- Toxicity
- Personal Information
- Toxicity Severe
- Hate
- Illicit
- Illicit Drugs
- Illicit Alcohol
- Illicit Firearms
- Illicit Tobacco
- Illicit Gambling
- Cannabis
- Adult
- Crypto
- Sexual
- Flirtation
- Profanity
- Violence
- Self Harm
- Spam
- Low-quality content
- Face detection
- Self Promotion
- Political
- Religion
- Code Abuse
- PII Masking
- URL Masking
- URL Risk
- Guideline
Show child attributes
Show child attributes
Response
Successful response
Potentially modified content.
Show child attributes
Show child attributes
The author of the content if your account has authors enabled. Requires you to send authorId when submitting content.
Show child attributes
Show child attributes
The evaluation of the content after running the channel policies.
Show child attributes
Show child attributes
The recommendation for the content based on the evaluation.
Show child attributes
Show child attributes
Results of all policies in the channel. Sorted by highest probability.
Classifier policy.
- Classifier output
- Entity matcher output
Show child attributes
Show child attributes
Results of all insights enabled in the channel.
Sentiment insight
- Sentiment insight
- Language insight
Show child attributes
Show child attributes
Metadata about the moderation request
Show child attributes
Show child attributes
Policies that had errors
Show child attributes
Show child attributes
Was this page helpful?