Text Moderation

Text Moderation API for identifying text risks including prohibited, erotic, harassment, fraud and privacy content.

Requirements

ItemSpecification
EncodingUTF-8
MethodPOST
Recommended timeout1s

Request

Request URL

ClusterRequest URLSupported Products
Shanghaihttp://api-text-sh.fengkongcloud.com/text/v4Chinese Text
USA (Virginia)http://api-text-fjny.fengkongcloud.com/text/v4Chinese Text, International Text
Singaporehttp://api-text-xjp.fengkongcloud.com/text/v4Chinese Text, International Text
Beijinghttp://api-text-bj.fengkongcloud.com/text/v4Chinese Text

Request Parameters

ParameterTypeRequiredDescription
accessKeystringYesAPI authentication key, provided by ISHUMEI.
appIdstringYesApplication identifier. Contact ISHUMEI to activate. Use the value provided by ISHUMEI.
eventIdstringYesEvent identifier. Contact ISHUMEI to activate. Use the value provided by ISHUMEI.
typestringYesRisk detection types. See Detection Types.
agentTypestringNoAgent detection risk types. Same values as type (excluding PROMPTATTACK and PUBLICFIGURE). Combine with underscores.
datajson_objectYesRequest data content. Max 1 MB. See data Object.
kbTypestringNoKnowledge base type. Max input: 510 characters (exceeding this prevents knowledge base matching). Contact ISHUMEI sales to enable. See Knowledge Base Types.
translationTargetLangstringNoTranslate input text to a target language. Contact ISHUMEI sales to enable. zh: Chinese. en: English.
acceptLangstringNoLanguage for returned labels. zh: Chinese. en: English. Defaults to Chinese if not specified.
callbackstringNoCallback HTTP URL. When non-empty, the service sends moderation results to this URL.

Detection Types

Combine multiple types with underscores (e.g., TEXTRISK_FRAUD). Combined types take the union of detection capabilities.

ValueDescription
POLITYPolitical content detection
VIOLENTViolence & terrorism detection
BANProhibited content detection
EROTICPornographic content detection
DIRTYAbusive language detection
ADVERTAdvertising detection
PRIVACYPrivacy information detection
ADLAWAdvertising law violation detection
MEANINGLESSMeaningless content detection
TEXTRISKStandard risk detection (includes: political, terrorism, prohibited, pornographic, abusive, advertising, privacy, advertising law, meaningless)
FRAUDOnline fraud detection
UNPOACHHigh-value user anti-poaching detection
TEXTMINORMinor-related content detection
PROMPTATTACKPrompt injection / instruction attack detection
PUBLICFIGUREPublic figure recognition

Knowledge Base Types

Contact ISHUMEI sales to enable.

ValueDescription
PKBPolitical knowledge base
BKBProhibited content knowledge base
SKBPornographic knowledge base
AKBAbusive language knowledge base

data Object

ParameterTypeRequiredDescription
textstringYesText to be moderated. Max 10,000 characters per request (error returned if exceeded). If the nickname field is also provided, both text and nickname content are validated simultaneously.
relateTextstringNoAssociated text for moderation. Max 128 characters (truncated if exceeded). When provided, it is reviewed in combination with text.
tokenIdstringYesUser account identifier. Recommended to use your user UID (can be encrypted). Used for behavioral risk detection (spam, advertising, etc.). Must be an alphanumeric string with underscores and hyphens, up to 64 characters.
langstringNoLanguage of the text. Default: zh. For domestic clusters, omit or use zh. For international text that cannot be categorized, use auto for automatic language detection. See Supported Languages.
nicknamestringNoUser nickname. Validates nickname content for risks. Max 150 characters (truncated if exceeded).
ipstringNoPublic IPv4 or IPv6 address of the user who sent the text.
deviceIdstringNoISHUMEI device fingerprint identifier.
dataIdstringNoCustom data identifier.
extrajson_objectNoAuxiliary parameters. See extra Object.

extra Object

ParameterTypeRequiredDescription
receiveTokenIdstringNoMessage receiver's tokenId for private chat scenarios. Alphanumeric with underscores and hyphens, up to 64 characters. Required when eventId is message.
topicstringNoTopic ID, book review section ID, or forum post ID. When eventId is article, this field is strongly recommended to enable context recognition. Without it, context cannot be associated.
atIdstringNotokenId of the @mentioned user in group chat scenarios. Alphanumeric with underscores and hyphens, up to 64 characters. Required when eventId is groupChat.
roomstringNoLive room / game room ID. When eventId is groupChat, this field is strongly recommended to enable context recognition. Without it, context cannot be associated.
sexintNoUser gender. 0: male. 1: female. 2: unknown.
passThroughjsonNoPass-through field. Content is returned as-is with the response.

Supported Languages

ValueLanguage
zhChinese (default)
enEnglish
arArabic
hiHindi
esSpanish
frFrench
ruRussian
ptPortuguese
idIndonesian
deGerman
jaJapanese
trTurkish
viVietnamese
itItalian
thThai
tlFilipino
koKorean
msMalay
autoAutomatic language detection

Response

Response Parameters

ℹ️

Parameters other than code, message, and requestId are only guaranteed to be returned when code is 1100.

ParameterTypeRequiredDescription
codeintYesResponse code. See Response Codes.
messagestringYesResponse message corresponding to the code.
requestIdstringYesUnique request identifier. Strongly recommended to save for troubleshooting and optimization.
riskLevelstringYesDisposition recommendation. PASS: normal (allow), REVIEW: suspicious (manual review), REJECT: violation (block).
riskLabel1stringYesLevel 1 risk label. Returns normal when riskLevel is PASS.
riskLabel2stringYesLevel 2 risk label. Empty when riskLevel is PASS.
riskLabel3stringYesLevel 3 risk label. Empty when riskLevel is PASS.
riskDescriptionstringYesRisk description. Returns "Normal" when riskLevel is PASS.
riskDetailjson_objectYesRisk detail information. See riskDetail Object.
tokenLabelsjson_objectYesAccount risk profile label information.
tokenLabels.UGC_account_riskjson_objectNoUGC content risk.
tokenLabels.UGC_account_risk.sexy_risk_tokenidfloatNoPornographic account risk score (0–1).
auxInfojson_objectYesAuxiliary information. See auxInfo Object.
allLabelsjson_arrayYesAll matched risk labels and details. See allLabels Array.
businessLabelsjson_arrayYesAll matched business labels and details. See businessLabels Array.
tokenProfileLabelsjson_arrayNoAccount attribute labels.
tokenRiskLabelsjson_arrayNoAccount risk labels.
langResultjson_objectNoLanguage information. See langResult Object.
kbDetailjson_objectNoKnowledge base detail. See kbDetail Object.
finalResultintYesWhether this is the final result. 1: final result (can be used directly for downstream processing). 0: intermediate result (machine moderation; human review will follow).
resultTypeintYesCurrent result stage. 0: machine moderation. 1: human moderation.
disposaljson_objectNoCustom disposition and mapping result. Returned only when a custom label system is configured. See disposal Object.

Response Codes

CodeMessage
1100Success
1901QPS limit exceeded
1902Invalid parameters
1903Service failure
1905Character count exceeded
9101Unauthorized operation

riskDetail Object

ParameterTypeRequiredDescription
matchedListsjson_arrayNoMatched custom list information.
matchedLists[].namestringNoName of the matched list.
matchedLists[].wordsjson_arrayNoMatched sensitive word details.
matchedLists[].words[].wordstringNoThe matched sensitive word.
matchedLists[].words[].positionint_arrayNoPosition of the sensitive word.
riskSegmentsjson_arrayNoHigh-risk content segments. Present when political, terrorism, prohibited, or advertising law content is detected.
riskSegments[].segmentstringNoHigh-risk content segment text.
riskSegments[].positionint_arrayNoPosition of the high-risk segment.

auxInfo Object

ParameterTypeRequiredDescription
filteredTextstringNoText with risky segments replaced by asterisks (*).
passThroughjson_objectNoPass-through field. Same value as data.extra.passThrough in the request.
contactResultjson_arrayNoContact information detection results, including WeChat, QQ, and phone numbers.
contactResult[].contactTypeintNoContact type. 0: phone number. 1: QQ number. 2: WeChat ID. 3: other.
contactResult[].contactStringstringNoDetected contact information string.
contextTextstringNoReturned when context recognition is enabled.
unauthorizedTypestringNoModeration types that are not enabled. Contact ISHUMEI to enable.

allLabels Array

Each element in the array:

ParameterTypeRequiredDescription
riskLabel1stringYesLevel 1 risk label.
riskLabel2stringYesLevel 2 risk label.
riskLabel3stringYesLevel 3 risk label.
riskDescriptionstringYesRisk description.
riskLevelstringYesRisk level: REVIEW or REJECT.
probabilityfloatYesConfidence score (0–1). Higher values indicate greater confidence.
riskDetailjson_objectYesRisk detail with same structure as riskDetail Object.

businessLabels Array

Each element in the array:

ParameterTypeRequiredDescription
businessLabel1stringYesLevel 1 business label.
businessLabel2stringYesLevel 2 business label.
businessLabel3stringYesLevel 3 business label.
businessDescriptionstringYesBusiness label description.
probabilityfloatYesConfidence score (0–1).
businessDetailjson_objectYesBusiness detail information.

Token Labels

Both tokenProfileLabels and tokenRiskLabels share the same structure:

ParameterTypeRequiredDescription
label1stringNoLevel 1 label.
label2stringNoLevel 2 label.
label3stringNoLevel 3 label.
descriptionstringNoLabel description.
timestampintNoLabel timestamp. 13-digit Unix timestamp in milliseconds.

langResult Object

ParameterTypeRequiredDescription
detectedLangstringNoLanguage detection result. Returned when lang is set to auto on an international text product. Value is a standard language code (e.g., zh, en, ar).
translatedTextstringNoTranslation result. Returned when translationTargetLang is provided in the request.

kbDetail Object

ParameterTypeRequiredDescription
qlabelstringYesQuestion label. UNKNOWN: no match. CANNOT_ASK: question is not allowed. EXACTNESS: answer must be accurate (including stance). POSITIVE: answer must contain positive guidance. PENDING: temporary answer for streaming queries.
answerstringYesSuggested answer. Provided when qlabel is EXACTNESS or POSITIVE.
isEndboolYesWhether the full answer has been returned.
hasAnswerintYesWhether an answer is available. 0: no suggested answer. 1: suggested answer available. 2: streaming query needed. Default: 0.

disposal Object

Returned only when a custom label system is configured with ISHUMEI. ISHUMEI can return results aligned with your company's custom label system and identifiers.

ParameterTypeRequiredDescription
riskLevelstringYesMapped disposition recommendation. If rule labels do not map, the default recommendation is returned.
riskLabel1stringYesMapped level 1 risk label. Returns normal when unmapped and riskLevel is PASS.
riskLabel2stringYesMapped level 2 risk label. Empty when unmapped and riskLevel is PASS.
riskLabel3stringYesMapped level 3 risk label. Empty when unmapped and riskLevel is PASS.
riskDescriptionstringYesMapped risk description. Returns "Normal" when riskLevel is PASS.
riskDetailjson_objectYesMapped risk detail. Same structure as riskDetail Object.

Risk Label Reference

Chinese Text Labels (lang=zh or auto-detected as Chinese)

Level 1 LabelIdentifierTypeRequired type Value
PoliticalpoliticsRegulatoryTEXTRISK
Violence & TerrorismviolenceRegulatoryTEXTRISK
PornographicpornRegulatoryTEXTRISK
ProhibitedbanRegulatoryTEXTRISK
AbusiveabuseRegulatoryTEXTRISK
Advertising Lawad_lawRegulatoryTEXTRISK
AdvertisingadRegulatoryTEXTRISK
BlocklistblacklistRegulatoryTEXTRISK
MeaninglessmeaninglessRegulatoryTEXTRISK
PrivacyprivacyRegulatoryTEXTRISK
Online FraudfraudRegulatoryFRAUD
MinorminorRegulatoryTEXTMINOR

Non-Chinese Text Labels

Level 1 LabelIdentifierTypeRequired type Value
PoliticalPoliticsRegulatoryTEXTRISK
Violence & TerrorismViolenceRegulatoryTEXTRISK
PornographicEroticRegulatoryTEXTRISK
ProhibitedProhibitRegulatoryTEXTRISK
AbusiveAbuseRegulatoryTEXTRISK
AdvertisingAdsRegulatoryTEXTRISK
BlocklistBlacklistRegulatoryTEXTRISK

Examples

Request Example

{
  "accessKey": "YOUR_ACCESS_KEY",
  "appId": "default",
  "eventId": "text",
  "type": "TEXTRISK",
  "data": {
    "text": "Add me on QQ: qq12345",
    "tokenId": "4567898765jhgfdsa",
    "ip": "118.89.214.89",
    "deviceId": "device_fingerprint_id",
    "nickname": "user_nickname",
    "extra": {
      "topic": "12345",
      "atId": "username1",
      "room": "ceshi123",
      "receiveTokenId": "username2"
    }
  }
}

Response Example

{
  "allLabels": [
    {
      "probability": 1,
      "riskDescription": "Politics: Political: Political",
      "riskDetail": {},
      "riskLabel1": "politics",
      "riskLabel2": "shezheng",
      "riskLabel3": "shezheng",
      "riskLevel": "REVIEW"
    },
    {
      "probability": 0.95559550232975,
      "riskDescription": "Advertising: Add friend: Add friend",
      "riskDetail": {
        "matchedLists": [
          {
            "name": "Community Sensitive Word List",
            "words": [
              {
                "position": [6, 7],
                "word": "qq"
              }
            ]
          }
        ]
      },
      "riskLabel1": "ad",
      "riskLabel2": "jiahaoyou",
      "riskLabel3": "jiahaoyou",
      "riskLevel": "REJECT"
    },
    {
      "probability": 1,
      "riskDescription": "Advertising: Contact information: Contact information",
      "riskDetail": {},
      "riskLabel1": "ad",
      "riskLabel2": "lianxifangshi",
      "riskLabel3": "lianxifangshi",
      "riskLevel": "REJECT"
    }
  ],
  "auxInfo": {
    "contactResult": [
      {
        "contactString": "qq12345",
        "contactType": 2
      }
    ],
    "filteredText": "Add me on QQ: **12345"
  },
  "businessLabels": [],
  "code": 1100,
  "message": "Success",
  "finalResult": 1,
  "resultType": 0,
  "requestId": "bb917ec5fa11fd02d226fb384968feb1",
  "riskDescription": "Advertising: Contact information: Contact information",
  "riskDetail": {},
  "riskLabel1": "ad",
  "riskLabel2": "lianxifangshi",
  "riskLabel3": "lianxifangshi",
  "riskLevel": "REJECT"
}