All Products
Search
Document Center

AI Guardrails:/green/text/scan

Last Updated:Mar 18, 2026

Scans text synchronously for undesirable content such as pornography, advertising violations, spam, political content, and abuse.

Usage notes

Operation: /green/text/scan

Submit text moderation tasks through this endpoint. For details on constructing HTTP requests, see Request syntax. To use an SDK instead, see SDK overview.

By default, this operation moderates Chinese text. To moderate text in other languages, contact your account manager. Supported languages: English, French, German, Indonesian, Malaysian, Portuguese, Spanish, Thai, Vietnamese, Japanese, Arabic, Filipino, Hindi, Turkish, Russian, Italian, and Dutch.

Billing

Calling this operation incurs charges. For details, see AI Guardrails Pricing.

QPS limit

This operation supports up to 100 calls per second per account. Exceeding this limit triggers throttling, which may affect your business. Factor this limit into your implementation.

Request parameters

Parameter Type Required Example Description
bizType String No default The business scenario. Create business scenarios in the AI Guardrails console. For details, see Customize policies for machine-assisted moderation.
scenes StringArray Yes ["antispam"] The moderation scenario. Set to antispam for text moderation.
tasks JSONArray Yes The list of text entries to moderate. Contains up to 100 elements, each structured as a task object (see the following table). To submit more than 100 entries per request, contact your account manager to increase the concurrency limit.

task

Parameter Type Required Example Description
clientInfo JSONObject No Client information. For details, see the "Common request parameters" section of Common parameters. The task-level clientInfo takes priority over the global clientInfo parameter.
dataId String No cfd33235-71a4-468b-8137-a5ffe323\*\*\*\* A unique identifier for the moderated object. Accepts letters, digits, underscores (\_), hyphens (-), and periods (.). Maximum length: 128 characters.
content String Yes 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. The text to moderate. Maximum length: 10,000 characters, including punctuation.

Response parameters

Parameter Type Example Description
code Integer 200 HTTP status code. For details, see Common error codes.
msg String OK The response message.
dataId String cfd33235-71a4-468b-8137-a5ffe323\*\*\*\* The ID of the moderated object. Returned only if dataId was set in the request.
taskId String txt6HB8NQoEbU@5fosnj2xVEM-1t\*\*\*\* The moderation task ID.
content String 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. The original text submitted in the request.
filteredContent String 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. The text with matched custom terms replaced by asterisks (\*). Customize terms through the CreateKeywordLib API or the AI Guardrails console. For details, see Manage custom text libraries.
results JSONArray The moderation results. On success (HTTP 200), returns an array of result objects (see the following table).

result

Parameter Type Example Description
scene String antispam The moderation scenario specified in the request.
suggestion String block The recommended action. Valid values: pass (text is normal), review (text requires human review), block (text contains violations and can be deleted or blocked).
label String porn The content category. 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).
rate Float 99.91 The confidence score. Valid values: 0 to 100. Higher values indicate greater confidence. When suggestion is pass, a higher score means the content is more likely normal. When suggestion is review or block, a higher score means the content is more likely to contain violations. Use the suggestion, label, and sublabel parameters to determine whether content contains violations. The sublabel parameter is returned by specific operations.
extras JSONObject {"userId":"xxx"} Additional information (extended parameter).
details JSONArray Details of the risky content detected. A text entry can match multiple risk categories. Each element is a detail object (see the following table).

detail

Parameter Type Example Description
label String porn The risk category of matched content. 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).
contexts JSONArray Context information for the matched risky content. Each element is a context object (see the following table).

context

Parameter Type Example Description
context String door-to-door The term matched in the text. Returned only for term-based matches, not for algorithmic model matches.
positions JSONArray [{"startPos":1, "endPos":10}] The position of the matched term in the original text.
libName String Name of your custom text library The name of the custom text library. Returned only when the text matches a term in a custom text library.
libCode String 123456 The code of the custom text library. Returned only when the text matches a term in a custom text library.
ruleType String ip The behavior rule type. Returned only when the text matches a behavior rule. Valid values: user_id, ip, umid, content, similar_content, imei, imsi.

Examples

Sample request

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 response

{
  "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"
}