Moderates text. You can call this operation to detect whether the specified text contains undesirable content, such as pornographic content, ad violations, spam, political content, and abuses.

Usage notes

Operation: /green/text/scan

You can call this operation to submit text moderation tasks. For more information about how to construct an HTTP request, see Request syntax. You can also select an existing HTTP request. For more information, see SDK overview.

Note By default, this operation is used to moderate Chinese text. If you need to moderate text in other languages, contact your account manager. Other languages include English, French, German, Indonesian, Malaysian, Portuguese, Spanish, Thai, Vietnamese, Japanese, Arabic, Filipino, Hindi, Turkish, Russian, Italian, and Dutch.

Billing:

You are charged for calling this operation. For more information about the billing methods, see Content Moderation Pricing.

QPS limit

You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.

Request parameters

ParameterTypeRequiredExampleDescription
bizTypeStringNodefaultThe business scenario. You can create a business scenario in the Content Moderation console. For more information, see Customize policies for machine-assisted moderation.
scenesStringArrayYes["antispam"]The moderation scenario. Set the value to antispam, which indicates text moderation.
tasksJSONArrayYesThe list of moderated objects. The JSON array can contain up to 100 elements. Each element is a structure. That is, you can submit up to 100 text entries at a time. If you need to submit more than 100 text entries at a time, contact your account manager to apply for an increase in the concurrency limit. For more information about the structures, see task.
Table 1. task
ParameterTypeRequiredExampleDescription
clientInfoJSONObjectNo

The information about the client. For more information, see the "Common request parameters" section of the Common parameters topic.

The server determines whether to use the global clientInfo parameter or the clientInfo parameter that is described in this table.
Note The clientInfo parameter in this table takes priority over the global one.
dataIdStringNocfd33235-71a4-468b-8137-a5ffe323****The ID of the moderated object.

The ID can contain letters, digits, underscores (_), hyphens (-), and periods (.). It can be up to 128 characters in length. This ID uniquely identifies your business data.

contentStringYesWe are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. The text to moderate. Each text entry can be up to 10,000 characters in length, including punctuation marks.

Response parameters

ParameterTypeExampleDescription
codeInteger200The returned HTTP status code.

For more information, see Common error codes.

msgStringOKThe message that is returned for the request.
dataIdStringcfd33235-71a4-468b-8137-a5ffe323****The ID of the moderated object.
Note If you set the dataId parameter in the moderation request, the value of the dataId request parameter is returned here.
taskIdStringtxt6HB8NQoEbU@5fosnj2xVEM-1t****The ID of the moderation task.
contentStringWe are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. The text that you specify in the moderation request.
filteredContentStringWe are a **** company that provides an *** loan on the same day with reliable, fast, convenient, and **** services when you apply for a loan on your mobile phone. The text that is returned if the original content hits terms in the custom term library, with the terms being replaced with asterisks (*).

You can customize terms by calling the CreateKeywordLib operation or in the Content Moderation console. For more information, see Manage custom text libraries and CreateKeywordLib.

resultsJSONArrayThe moderation results. If the call is successful, the HTTP status code 200 and moderation results are returned. The array of moderation results contains one or more elements. Each element is a structure. For more information about the structure of each element, see result.
Table 2. result
ParameterTypeExampleDescription
sceneStringantispamThe moderation scenario that you specify in the moderation request.
suggestionStringblockThe recommended subsequent operation. Valid values:
  • pass: The text is normal.
  • review: The text requires human review.
  • block: The text contains violations and can be deleted or blocked.
labelStringpornThe category of the moderation result for the moderated text. Valid values:
  • normal: normal content
  • spam: junk content
  • ad: advertising content
  • politics: political content
  • terrorism: terrorist content
  • abuse: abusive content
  • porn: pornographic content
  • flood: excessive junk content
  • contraband: prohibited content
  • meaningless: meaningless content
  • harmful: harmful content, including content related to mammonism, wealth flaunting, blind worshiping of idols, disruptive emotion, and negative enticing
  • customized: custom content, such as a custom term
rateFloat99.91The score of the confidence level. Valid values: 0 to 100. A greater value indicates a higher confidence level.
If a value of pass is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content is normal. If a value of review or block is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content contains violations.
Important We recommend that you use the values that are returned for the suggestion, label, and sublabel parameters to determine whether the content contains violations. The sublabel parameter is returned by specific operations.
extrasJSONObject{"userId":"xxx"}The additional information. This is an extended parameter.
detailsJSONArrayThe details of the risky content hit by the moderated text. A text entry can hit multiple pieces of risky content. For more information about the structure, see detail.
Table 3. detail
ParameterTypeExampleDescription
labelStringpornThe category of the risky content that the moderated text hits. Valid values:
  • spam: junk content
  • ad: advertising content
  • politics: political content
  • terrorism: terrorist content
  • abuse: abusive content
  • porn: pornographic content
  • flood: excessive junk content
  • contraband: prohibited content
  • meaningless: meaningless content
  • harmful: harmful content, including content related to mammonism, wealth flaunting, blind worshiping of idols, disruptive emotion, and negative enticing
  • customized: custom content, such as a custom term
contextsJSONArrayThe context information of the risky content that the moderated text hits. For more information about the structure, see context.
Table 4. context
ParameterTypeExampleDescription
contextStringdoor-to-doorThe term that the moderated text hits. If the text hits a term, the term is returned. If the text hits the algorithmic model, this parameter is not returned.
positionsJSONArray[{"startPos":1, "endPos":10}]The position of the term that the moderated text hits in the original text.
libNameStringName of your custom text libraryThe name of the custom text library. This parameter is returned if the moderated text hits a term in the custom text library.
libCodeString123456The code of the custom text library. This parameter is returned if the moderated text hits a term in the custom text library.
ruleTypeStringipThe behavior rule. This parameter is returned if the moderated text hits the behavior rule. Valid values:
  • user_id
  • ip
  • umid
  • content
  • similar_content
  • imei
  • imsi

Examples

Sample requests
http(s)://[Endpoint]/green/text/scan
&<Common request parameters>
{
     "scenes": [
        "antispam"
    ],
     "tasks": [
          {
               "dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
            ..."content": "We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone."
        }
    ]
}
Sample responses
{
  "code": 200,
  "data": [
    {
      "code": 200,
      "content": "We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone.",
      "dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
      "filteredContent": "We are a **** company that provides an *** loan on the same day with reliable, fast, convenient, and **** services when you apply for a loan on your mobile phone.",
      "msg": "OK",
      "results": [
        {
          "details": [
            {
              "contexts": [
                {
                  "context": "unsecured",
                  "positions": [
                    {
                      "endPos": 19,
                      "startPos": 16
                    }
                  ]
                },
                {
                  "context": "micro-lending",
                  "positions": [
                    {
                      "endPos": 6,
                      "startPos": 2
                    }
                  ]
                }
              ],
              "label": "spam"
            },
            {
              "contexts": [
                {
                  "context": "door-to-door",
                  "libCode": "123456",
                  "libName": "Name of your custom text library",
                  "positions": [
                    {
                      "endPos": 34,
                      "startPos": 30
                    }
                  ]
                }
              ],
              "label": "porn"
            }
          ],
          "label": "porn",
          "rate": 99.91,
          "scene": "antispam",
          "suggestion": "block"
        }
      ],
      "taskId": "txt6HB8NQoEbU@5fosnj2xVEM-1t****"
    }
  ],
  "msg": "OK",
  "requestId": "25711794-BF6D-4F32-A735-09CA21197D32"
}