Text moderation API
Moderation API provides a direct method of accessing the platform’s moderation functionality, similar to Moderation request functionality provided by the Controller class.
Review the platform moderation functionality at Moderation
Basic vs Advanced Moderation Service is automatically selected based on the service level configured for an instance identified by the provided API key.
Target URL
The moderation endpoint format is:
/api/v2/blueprint/review/text
Method
Text moderation requests shall be done using POST HTTP method.
Inbound payload
Inbound payload shall be in the JSON format:
{
"text": "<text to validate>",
"locale": "optional, desired moderation locale"
}
The locale parameter shall be an ISO locale/country identifier, such as en-US
If the instance is configured using Advanced Moderation, it is possible to configure a specific request to use the Basic Moderation. As the basic moderation is unmetered, high-performance, alternative to AI-driven Advanced Moderation, in some use cases it may be useful to perform a “pre-validation” step - for example, when doing as-you-type validation.
Disable advanced moderation by passing useAdvanced parameter:
{
"text": "<text to validate>",
"useAdvanced": false
}
Note that it is not possible to “force” advanced moderation if it is not enabled on the account.
Response payload
The format of the response changes depending on the moderation level, however, advanced moderation is a superset of the data available from basic moderation.
Basic moderation
The response shall be a JSON object with following properties:
hasProfanity— A boolean property indicating whether the text contains sensitive or vulgar content.censored— A copy of the input text with sensitive text censored.corrected— if it is possible to automatically correct spelling errors, the property will include a correct text.
For example:
{
"hasProfanity": false
}
or
{
"hasProfanity": true,
"censored": "***"
}
Advanced moderation
Advanced moderation provides additional data points:
hasProfanity— A boolean property indicating whether the text contains sensitive or vulgar content.censored— A copy of the input text with sensitive text censored.corrected— if it is possible to automatically correct spelling errors, the property will include a correct text.reviewRecommended— A boolean property indicate that the reviewed text may contain questionable content, however the detected scores where not high enough to trigger the rejection threshold.explicit— A number between 0 and 1 indicating the explicit text detection score.suggestiveMature— A number between 0 and 1 indicating mature content detection score.offensiveToxic— A number between 0 and 1 indicating toxic content detection.