Skip to main content
JavaScript
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: 'x', type: 'text' } });

console.log(response.author);
{
  "content": {
    "id": "<string>",
    "masked": true,
    "modified": "<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
  },
  "recommendation": {
    "action": "review",
    "reason_codes": [
      "severity_reject"
    ]
  },
  "policies": [
    {
      "id": "<string>",
      "type": "<string>",
      "probability": 0.5,
      "flagged": true,
      "flagged_fields": [
        "<string>"
      ],
      "labels": [
        {
          "id": "<string>",
          "probability": 0.5,
          "flagged": true
        }
      ]
    }
  ],
  "insights": [
    {
      "id": "<string>",
      "type": "<string>",
      "probability": 0.5,
      "value": "positive"
    }
  ],
  "meta": {
    "status": "success",
    "timestamp": 123,
    "channel_key": "<string>",
    "usage": 123,
    "processing_time": "<string>"
  },
  "errors": [
    {
      "id": "<string>",
      "message": "<string>"
    }
  ]
}
Submit content for moderation and receive analysis results immediately. Supports text, image, object, video, and audio content types. For detailed usage examples and content metadata options, see Submitting content.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
content
Content leaf · object
required

The content sent for moderation Text

channel
string

Provide a channel ID or key. Will use the project's default channel if not provided.

contentId
string

The unique ID of the content in your database.

Maximum string length: 100
metaType
enum<string>

The meta type of content being moderated

Available options:
profile,
message,
post,
comment,
event,
product,
review,
other
authorId
string

The author of the content.

conversationId
string

For example the ID of a chat room or a post

metadata
object

Any metadata you want to store with the content

doNotStore
boolean

Do not store the content. The content won't enter the review queue

policies
(Toxicity · object | Personal Information · object | Toxicity Severe · object | Hate · object | Illicit · object | Illicit Drugs · object | Illicit Alcohol · object | Illicit Firearms · object | Illicit Tobacco · object | Illicit Gambling · object | Sexual · object | Flirtation · object | Profanity · object | Violence · object | Self Harm · object | Spam · object | Self Promotion · object | Political · object | Religion · object | Code Abuse · object | PII Masking · object | URL Masking · object | Guideline · object)[]

(Enterprise) override the channel policies for this moderation request only.

Response

Successful response

content
object
required

Potentially modified content.

author
object
required

The author of the content if your account has authors enabled. Requires you to send authorId when submitting content.

evaluation
object
required

The evaluation of the content after running the channel policies.

recommendation
object
required

The recommendation for the content based on the evaluation.

policies
(Classifier output · object | Entity matcher output · object)[]
required

Results of all policies in the channel. Sorted by highest probability.

Policy output schema. Classifier policy.

insights
(Sentiment insight · object | Language insight · object)[]
required

Results of all insights enabled in the channel.

Sentiment insight

meta
object
required

Metadata about the moderation request

errors
object[]

Policies that had errors