import { ModerationApi } from "@moderation-api/sdk";
const moderationApi = new ModerationApi({
secretKey: process.env["MODAPI_SECRET_KEY"] ?? "",
});
async function run() {
const result = await moderationApi.content.submit({
body: {
content: {
type: "text",
text: "Hey, check out my profile for a deal!",
},
contentId: "message-48213",
authorId: "user-1092",
conversationId: "room-general",
metadata: {
"platform": "ios",
},
},
});
console.log(result);
}
run();
import os
from moderation_api import ModerationAPI
with ModerationAPI(
secret_key=os.environ["MODAPI_SECRET_KEY"],
) as moderation_api:
res = moderation_api.content.submit(content={
"type": "text",
"text": "Hey, check out my profile for a deal!",
}, content_id="message-48213", author_id="user-1092", conversation_id="room-general", metadata={
"platform": "ios",
})
# Handle response
print(res)
declare(strict_types=1);
require 'vendor/autoload.php';
use ModerationApi;
use ModerationApi\Models\Operations;
$sdk = ModerationApi\ModerationApi::builder()
->setSecurity(
getenv('MODAPI_SECRET_KEY')
)
->build();
$body = new Operations\SubmitContentRequestBody(
content: new Operations\TextRequest(
text: 'Hey, check out my profile for a deal!',
),
contentId: 'message-48213',
authorId: 'user-1092',
conversationId: 'room-general',
metadata: [
'platform' => 'ios',
],
);
$response = $sdk->content->submit(
body: $body
);
if ($response->object !== null) {
// handle response
}
require 'moderation_api'
Models = ::ModerationApi::Models
s = ::ModerationApi::ModerationApi.new(
secret_key: ENV.fetch('MODAPI_SECRET_KEY')
)
res = s.content.submit(body: Models::Operations::SubmitContentRequestBody.new(
content: Models::Operations::TextRequest.new(
type: 'text',
text: 'Hey, check out my profile for a deal!'
),
content_id: 'message-48213',
author_id: 'user-1092',
conversation_id: 'room-general',
metadata: {
'platform' => 'ios',
}
))
unless res.object.nil?
# handle response
end
modapi content submit --secret-key "$MODAPI_SECRET_KEY" --content '{"type":"text","text":"Hey, check out my profile for a deal!"}' --content-id message-48213 --author-id user-1092 --conversation-id room-general --metadata '{"platform":"ios"}'
{
"content": {
"id": "<string>",
"masked": true,
"unicode_cleaned": 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>"
}
]
},
"casebook": {
"verdict": "allow",
"similarity": 123,
"agreement": 123,
"confidence": 123,
"case_count": 123,
"topic": {
"id": "<string>",
"label": "<string>"
}
},
"policies": [
{
"id": "<string>",
"type": "classifier",
"probability": 0.5,
"flagged": true,
"flagged_fields": [
"<string>"
],
"labels": [
{
"id": "<string>",
"probability": 0.5,
"flagged": true,
"shadowFlagged": true
}
],
"data": {}
}
],
"insights": [
{
"id": "sentiment",
"type": "insight",
"probability": 0.5,
"value": "positive",
"scores": {
"positive": 0.5,
"negative": 0.5
}
}
],
"meta": {
"status": "success",
"timestamp": 123,
"channel_key": "<string>",
"usage": 123,
"processing_time": "<string>"
},
"errors": [
{
"id": "<string>",
"message": "<string>"
}
]
}{
"type": "invalid_request_error",
"code": "invalid_request",
"message": "Invalid input data",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "authentication_error",
"code": "unauthorized",
"message": "Authorization not provided",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "permission_error",
"code": "permission_denied",
"message": "Insufficient access",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "api_error",
"code": "internal_error",
"message": "Internal server error",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}Submit content
Submit text, image, video, audio, or object content for moderation analysis.
import { ModerationApi } from "@moderation-api/sdk";
const moderationApi = new ModerationApi({
secretKey: process.env["MODAPI_SECRET_KEY"] ?? "",
});
async function run() {
const result = await moderationApi.content.submit({
body: {
content: {
type: "text",
text: "Hey, check out my profile for a deal!",
},
contentId: "message-48213",
authorId: "user-1092",
conversationId: "room-general",
metadata: {
"platform": "ios",
},
},
});
console.log(result);
}
run();
import os
from moderation_api import ModerationAPI
with ModerationAPI(
secret_key=os.environ["MODAPI_SECRET_KEY"],
) as moderation_api:
res = moderation_api.content.submit(content={
"type": "text",
"text": "Hey, check out my profile for a deal!",
}, content_id="message-48213", author_id="user-1092", conversation_id="room-general", metadata={
"platform": "ios",
})
# Handle response
print(res)
declare(strict_types=1);
require 'vendor/autoload.php';
use ModerationApi;
use ModerationApi\Models\Operations;
$sdk = ModerationApi\ModerationApi::builder()
->setSecurity(
getenv('MODAPI_SECRET_KEY')
)
->build();
$body = new Operations\SubmitContentRequestBody(
content: new Operations\TextRequest(
text: 'Hey, check out my profile for a deal!',
),
contentId: 'message-48213',
authorId: 'user-1092',
conversationId: 'room-general',
metadata: [
'platform' => 'ios',
],
);
$response = $sdk->content->submit(
body: $body
);
if ($response->object !== null) {
// handle response
}
require 'moderation_api'
Models = ::ModerationApi::Models
s = ::ModerationApi::ModerationApi.new(
secret_key: ENV.fetch('MODAPI_SECRET_KEY')
)
res = s.content.submit(body: Models::Operations::SubmitContentRequestBody.new(
content: Models::Operations::TextRequest.new(
type: 'text',
text: 'Hey, check out my profile for a deal!'
),
content_id: 'message-48213',
author_id: 'user-1092',
conversation_id: 'room-general',
metadata: {
'platform' => 'ios',
}
))
unless res.object.nil?
# handle response
end
modapi content submit --secret-key "$MODAPI_SECRET_KEY" --content '{"type":"text","text":"Hey, check out my profile for a deal!"}' --content-id message-48213 --author-id user-1092 --conversation-id room-general --metadata '{"platform":"ios"}'
{
"content": {
"id": "<string>",
"masked": true,
"unicode_cleaned": 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>"
}
]
},
"casebook": {
"verdict": "allow",
"similarity": 123,
"agreement": 123,
"confidence": 123,
"case_count": 123,
"topic": {
"id": "<string>",
"label": "<string>"
}
},
"policies": [
{
"id": "<string>",
"type": "classifier",
"probability": 0.5,
"flagged": true,
"flagged_fields": [
"<string>"
],
"labels": [
{
"id": "<string>",
"probability": 0.5,
"flagged": true,
"shadowFlagged": true
}
],
"data": {}
}
],
"insights": [
{
"id": "sentiment",
"type": "insight",
"probability": 0.5,
"value": "positive",
"scores": {
"positive": 0.5,
"negative": 0.5
}
}
],
"meta": {
"status": "success",
"timestamp": 123,
"channel_key": "<string>",
"usage": 123,
"processing_time": "<string>"
},
"errors": [
{
"id": "<string>",
"message": "<string>"
}
]
}{
"type": "invalid_request_error",
"code": "invalid_request",
"message": "Invalid input data",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "authentication_error",
"code": "unauthorized",
"message": "Authorization not provided",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "permission_error",
"code": "permission_denied",
"message": "Insufficient access",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "api_error",
"code": "internal_error",
"message": "Internal server error",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
The project to act on, when you call with an organization key. Optional when the organization has one project. A project key acts on its own project: naming another one is an error.
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
- Hate
- Illicit
- Illicit Drugs
- Illicit Alcohol
- Illicit Firearms
- Illicit Tobacco
- Illicit Gambling
- Cannabis
- Adult
- Crypto
- Sexual
- Sexual Minors
- Profanity
- Violence
- Self Harm
- Spam
- Low-quality content
- Face detection
- Self Promotion
- Political
- Religion
- Threat
- Sexual Solicitation
- Channel Circumvention
- Illegal Trade
- Alcohol
- Drugs
- Gambling
- Tobacco
- Weapons
- Promotion
- Extremism
- Code Abuse
- Unicode Spoofing
- 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
What your casebook — the record of your past moderation decisions — found for this content, or null when it had nothing close enough to say, when the matching cases disagreed, or when casebook lookups are not switched on for this channel. Reports what the casebook found; whether it decided the outcome is shown in recommendation, where a higher-priority rule may have settled the item first.
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
- Curiosity insight
- Respect insight
- Personal story insight
- Compassion 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?