All Products
Search
Document Center

AI Guardrails:Asynchronous scan

Last Updated:Aug 25, 2026

Asynchronous image moderation detects risky or non-compliant content in images. Supported scenarios are pornography detection, terrorism and politically sensitive content detection, ad violation, QR code detection, undesirable scene detection, and logo detection. Asynchronous moderation has two stages: you submit the moderation task by calling one operation, and then retrieve the results either through a callback or by calling the result query operation.

Usage notes (submit a moderation task)

API operation: /green/image/asyncscan, which submits an asynchronous image moderation task.

Call this operation to create an asynchronous image moderation task. Submitting the task is the first of two steps: this operation returns a taskId, and you then retrieve the moderation results either through a callback or by querying the result operation.For information about how to construct an HTTP request, see Request structure. You can also use a pre-constructed HTTP request. For more information, see SDK overview.

  • Billing information:

    This is a paid API operation. For more information about billing, see Content Moderation Pricing.

    - Moderation timeout:

    The maximum detection time for a synchronous detection request is 6 seconds. If the detection is not completed within this time limit, a timeout error is returned. If you do not require real-time results, you can use asynchronous detection. Otherwise, use synchronous detection because its API call is simpler. For these calls, set the timeout period to 6 seconds.

    - Retrieving moderation results:

    Asynchronous detection tasks do not return results in real time. You must use a callback or polling to retrieve the results, which are stored for up to one hour.

    - Callback: When you submit an asynchronous moderation task, specify the callback parameter in the request. Content Moderation then delivers the moderation results to the callback URL automatically. For more information, see Request parameters (submit a moderation task).- Polling: When you submit an asynchronous moderation task, do not specify the callback parameter. After you submit the task, call the result query operation to obtain the moderation results. Observe the query interval and the validity period of the taskId. For more information, see Usage notes (query moderation results).- Image requirements:

    • The image URL must use the HTTP or HTTPS protocol.

    • Supported image formats: PNG, JPG, JPEG, BMP, GIF, and WEBP.

    • The image size cannot exceed 20 MB for both synchronous and asynchronous calls.

    • The image must be downloaded within 3 seconds. If the download time exceeds 3 seconds, a download timeout error is returned.

    • For optimal performance, we recommend that the image resolution be at least 256x256 pixels. A lower resolution may affect the detection accuracy.

    • The response time of the image detection API depends on the image download time. Ensure that the storage service where the image is stored is stable and reliable. For best performance, use Alibaba Cloud Object Storage Service (OSS) or a Content Delivery Network (CDN).

    The following table describes the moderation scenarios that asynchronous image moderation supports.
Table 1. Scenario descriptions
Scenario Description Detection categories
pornography detection Detects pornographic or sexually suggestive content in images. normal, pornographic, sexually suggestive
terrorist content detection Detects terrorist or politically sensitive content in images. normal, bloody, explosions and smoke/flashes, special attire, special symbols, weapons, politics, fighting, gatherings, marches, traffic accident scenes, flags, landmarks
ad violation detection Detects policy-violating ads or text in images. normal, text contains politically sensitive content, text contains pornographic content, text contains abusive content, text contains terrorist content, text contains prohibited content, text contains other spam content, small ad stickers, contains QR codes, contains mini program codes, other ads
Note Configure the detection categories based on your business requirements. For more information, see custom machine-assisted moderation policy.
QR code detection Detects QR codes or mini program codes in images. normal, contains QR codes, contains mini program codes
Note Configure the detection categories based on your business requirements. For more information, see custom machine-assisted moderation policy.
undesirable scene detection Detects undesirable scenes in images, such as black screens, black borders, dim footage, picture-in-picture, smoking, or live streaming inside a vehicle. normal, no content in the image (for example, a black screen or a white screen), picture-in-picture, smoking, live streaming inside a vehicle
logo detection Detects logos in images, such as TV station logos and trademarks. normal, contains controlled logos, contains trademarks

QPS limit

The queries per second (QPS) limit for this API is 50 per user. Exceeding this limit triggers throttling, which can impact your business. Plan your calls accordingly.

Request parameters (submit a moderation task)

The following table describes the request parameters of /green/image/asyncscan.

ParameterTypeRequiredExampleDescription
bizTypeStringNodefault

This field identifies your business scenario. You can create a business scenario in the Content Moderation console. For more information, see Customize moderation rules.

scenesStringArrayYes["porn"]The moderation scenes. Valid values:- porn: pornography detection- terrorism: terrorism and politically sensitive content detection- ad: ad violation- qrcode: QR code detection- live: undesirable scene detection- logo: logo detection
One request can specify multiple scenes. For example, ["porn", "terrorism"] moderates the image for both pornography and terrorism and politically sensitive content.> Note: If you specify multiple scenes, the fee is the sum, across scenes, of the number of images moderated in each scene multiplied by the unit price of that scene.

| callback | String | No | http://www.aliyundoc.com |

The URL to which you want to receive callback notifications for the detection results. The URL must use the HTTP or HTTPS protocol. If you leave this parameter empty, you must periodically poll for the detection results.

The callback interface must support the POST method, UTF-8 encoded data, and the form parameters checksum and content. Content Moderation sets the checksum and content parameters according to the following rules and formats, and calls your callback interface to return the detection results.

  • checksum: A SHA-256 hash of the concatenated string User UID + seed + content. The user UID is your Alibaba Cloud account ID, which is available in the Alibaba Cloud console. To prevent tampering, regenerate this string on your end and verify it against the received checksum.

    Note

    The user UID must be that of the root account, not a RAM user.

  • content: A JSON string that you must parse. For an example of the content payload, see the sample response in "Query detection results".

Note

After your callback server receives a result notification, it must return an HTTP status code of 200 to indicate success. Any other status code is treated as a failure. If the notification fails, Content Moderation retries up to 16 times until it succeeds. If it still fails after 16 retries, no more attempts are made. We recommend that you check the status of your callback endpoint.

| | seed | String | No | abc_123 |

A random string used for the signature in the callback notification request.

The string can contain letters, digits, and underscores (_), and must be 64 characters or less. Customize this string to verify the origin of callback requests.

Note

This parameter is required when you use a callback.

| | cryptType | String | No | SHA256 | The digest algorithm that is applied to the content of callback notifications. When you use callback notifications, Content Moderation concatenates user UID + seed + content into a string, computes the digest of that string with the specified algorithm, and sends the result to your callback URL. Valid values:- SHA256 (default)- SM3: the HMAC-SM3 algorithm defined by the Chinese national cryptographic standards. A hexadecimal string that consists of lowercase letters and digits is returned. For example, abc returns 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 after SM3 computation. | | offline | Boolean | No | false | The moderation mode. This setting also determines how long the returned taskId remains valid, as described in the usage notes for querying moderation results. Valid values:- true: offline moderation mode. In this mode, the service does not guarantee real-time processing. Your task is queued and moderation starts within 24 hours.- false (default): real-time moderation mode. Moderation requests that exceed the concurrency limit are rejected. | | tasks | JSONArray | Yes | | The objects to moderate. Each element in the JSON array is a moderation task struct. One request supports up to 100 elements, which means that you can submit 100 items for moderation in a single request. To use 100 elements, first increase your concurrent task limit to more than 100. For a description of the structure, see task. |

task

Each element of the tasks array is a task struct that contains the following fields.

ParameterTypeRequiredExampleDescription
clientInfoJSONObjectNo{"userId":"12023****","userNick":"Mike","userType":"others"}

The client information. For more information, see the common query parameters in Common parameters.

The server merges the global clientInfo with the individual clientInfo specified for the request.

Note

The individual clientInfo has a higher priority.

dataIdStringNotest4lNSMdggA0c56MMvfYoh4e-1mwxpx

The data ID of the detection object.

This ID can contain uppercase and lowercase letters, digits, underscores (_), hyphens (-), and periods (.), and must be 128 characters or less. Use it to uniquely identify your business data.

urlStringYeshttps://www.aliyundoc.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png

A public HTTP or HTTPS URL. The URL cannot exceed 2,048 characters in length.

extrasJSONObjectNoAdditional request parameters. This parameter is not required for image moderation.
intervalIntegerNo1The frame extraction interval. This parameter applies only to the moderation of GIF images and long images.- A GIF image can be regarded as an array of images. The interval parameter specifies how many images to skip between extracted frames. Frames are extracted from a GIF image only if this parameter is specified.- Long images are either tall images or wide images.- For a tall image, whose height is greater than 400 pixels (px) and whose ratio of height to width is greater than 2.5, the total number of sub-images is the integer part of the height-to-width ratio, and the image is sliced accordingly.- For a wide image, whose width is greater than 400 pixels (px) and whose ratio of width to height is greater than 2.5, the total number of sub-images is the integer part of the width-to-height ratio, and the image is sliced accordingly.
By default, only the first frame of a GIF image or a long image is moderated. When you specify interval, the service skips frames at the specified interval during moderation, which reduces moderation costs. > Note: Use interval together with the maxFrames parameter. For example, if you set interval to 2 and maxFrames to 20, every other frame of the GIF image or long image is moderated, up to 20 frames, and you are billed for the number of frames that are actually moderated.

| maxFrames | Integer | No | 20 |

The maximum number of frames to capture. This parameter is used only for GIF and long image detection. Default value: 1.

If interval * maxFrames is less than the total number of frames in the GIF or long image, the interval is automatically adjusted to (Total frames / maxFrames) to improve overall detection coverage.

|

Response parameters (submit a moderation task)

The response body of /green/image/asyncscan contains the top-level fields code, msg, requestId, and data. The data array contains one element for each moderation task in the request. The following table describes the fields of each element.

ParameterTypeExampleDescription
codeInteger200

The error code. It is the same as the HTTP status code.

For more information, see Common error codes.

msgStringOKThe message that describes the result of the request.
dataIdStringtest4lNSMdggA0c56MMvfYoh4e-1mwxpx

The data ID of the detection object.

Note

If dataId was passed in the detection request, the same dataId is returned here.

taskIdStringfdd25f95-4892-4d6b-aca9-7939bc6e9baa-1486198766695The ID of the moderation task. Pass this value to the result query operation to obtain the moderation results.
urlStringhttps://www.aliyundoc.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png

A public HTTP or HTTPS URL. The URL cannot exceed 2,048 characters in length.

Examples (submit a moderation task)

The following code shows a sample request:

http(s)://[Endpoint]/green/image/asyncscan
&<common request parameters>
{
    "scenes": [
        "porn"
    ],
    "tasks": [
        {
            "dataId": "test4lNSMdggA0c56MMvfYoh4e-1mwxpx",
            "url": "https://www.aliyundoc.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png"
        }
    ]
}

The following code shows a sample success response:

{
    "code": 200,
    "msg": "OK",
    "requestId": "95AD868A-F5D2-4AEA-96D4-E0273B8E074C",
    "data": [
        {
            "code": 200,
            "msg": "OK",
            "dataId": "test4lNSMdggA0c56MMvfYoh4e-1mwxpx",
            "taskId": "fdd25f95-4892-4d6b-aca9-7939bc6e9baa-1486198766695",
            "url": "https://www.aliyundoc.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png"
        }
    ]
}

Usage notes (query moderation results)

API operation: /green/image/results, which queries the results of asynchronous image moderation.

Call this operation to query the results of an asynchronous image moderation task that you submitted through /green/image/asyncscan. Use this operation when you retrieve results by polling instead of through a callback.For information about how to construct an HTTP request, see Request structure. You can also use a pre-constructed HTTP request. For more information, see SDK overview.

  • Billing information:

    This API operation is free of charge.

    - Query timing and result validity: Set the query interval to 30 seconds. That is, query the results 30 seconds after you submit the asynchronous moderation task and obtain the taskId.> Note: If the offline parameter is set to true, the taskId remains valid for 24 hours. If the offline parameter is set to false, the taskId remains valid for 1 hour. Default value: false.

QPS limit

The queries per second (QPS) limit for this API is 50 per user. Exceeding this limit triggers throttling, which can impact your business. Plan your calls accordingly.

Request parameters (query moderation results)

The following table describes the request parameters of /green/image/results.

ParameterTypeRequiredExampleDescription
bodyJSONArrayYes["fdd25f95-4892-4d6b-aca9-7939bc6e9baa-1486198766695"]

A list of taskId values for the detection tasks you want to query. The array can contain up to 100 elements.

You can obtain the taskId from the response after you submit a detection task.

Response parameters (query moderation results)

The response body of /green/image/results contains the top-level fields code, msg, requestId, and data. The data array contains one element for each taskId in the request. The following table describes the fields of each element.

ParameterTypeExampleDescription
codeInteger200

The error code. It is the same as the HTTP status code.

For more information, see Common error codes.

msgStringOKThe message that describes the result of the request.
dataIdStringtest4lNSMdggA0c56MMvfYoh4e-1mwxpx

The data ID of the detection object.

Note

If dataId was passed in the detection request, the same dataId is returned here.

taskIdStringfdd25f95-4892-4d6b-aca9-7939bc6e9baa-1486198766695The ID of the moderation task.
urlStringhttps://www.aliyundoc.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png

A public HTTP or HTTPS URL. The URL cannot exceed 2,048 characters in length.

storedUrlStringhttp://www.aliyundoc.comIf you enable evidence storage to an OSS bucket and the moderation task matches the rules that you configure, the image is stored in your OSS bucket and the corresponding HTTP URL is returned.
extrasJSONObject{"hitLibInfo":[{"context":"Haokan Video","libCode":"2144002","libName":"Pre-release Test Ad Similar Text Library a"}]}Additional information.In the ad violation (ad) scenario, this parameter can return the following field. hitLibInfo: If the text in the image hits a custom text library, information about the text library that is hit is returned. The value is an array. For a description of the structure, see hitLibInfo.
resultsJSONArrayThe moderation results. If the call is successful (code=200), the results contain one or more elements. Each element is a struct. For a description of the structure, see result.

result

Each element of the results array is a result struct that contains the following fields.

ParameterTypeExampleDescription
sceneStringterrorismThe image moderation scene. The value corresponds to the scene specified in the request. Valid values:
  • porn: pornography detection
  • terrorism: terrorist content detection
  • ad: ad and violation detection
  • qrcode: QR code detection
  • live: undesirable scene detection
  • Logo: logo detection
labelStringsexyThe category of the moderation result. The categories vary with the moderation scene, as follows:
  • For porn (pornographic content detection):
    • normal: normal content
    • sexy: sexy content
    • porn: pornographic content
  • For terrorism (terrorism and political content detection):
    • normal: normal content
    • bloody: bloody content
    • explosion: explosion and smoke
    • outfit: special costume
    • Logo: special logo
    • weapon: weapon
    • politics: political content
    • violence: violence
    • crowd: crowd
    • parade: parade
    • carcrash: car crash
    • flag: flag
    • location: landmark
    • drug: drug-related content
    • gamble: gambling
    • others: other specified content
  • For ad (ad violation):
    • normal: normal content
    • ad: other ads
    • politics: political content in text
    • porn: pornographic content in text
    • abuse: abuse in text
    • terrorism: terrorist content in text
    • contraband: prohibited content in text
    • spam: junk content in text
    • npx: overlay ad
    • qrcode: QR code
    • programCode: mini program code
  • For qrcode (QR code detection):
    • normal: normal content
    • qrcode: QR code
    • programCode: mini program code
  • For live (undesirable scene detection):
    • normal: normal content
    • meaningless: no content in the image, such as a black or white screen
    • PIP: picture-in-picture
    • smoking: smoking
    • drivelive: streaming while driving
    • drug: drug-related content
    • gamble: gambling
  • For logo (logo detection):
    • normal: normal content
    • TV: logo of banned media
    • trademark: trademark
sublabelString

If the detection scenes include pornography (porn) and terrorism/politics (terrorism), this field can return fine-grained labels for the detection results.

This field is not returned by default.

suggestionStringblockThe recommended follow-up action. Valid values:
  • pass: The content is normal. No action is required.
  • review: The result is uncertain. Perform manual review.
  • block: The content violates policies. Delete or restrict access to the content.
rateFloat91.54

The confidence score. Valid values: 0 (lowest confidence) to 100 (highest confidence).

If the suggestion is pass, the higher the confidence score, the more likely the content is compliant. If the suggestion is review or block, the higher the confidence score, the more likely the content is non-compliant.

Important

We recommend that you use the suggestion and label (or sublabel, for some API operations) fields to determine whether the content is in violation.

framesJSONArrayIf the image to moderate is truncated because it is too long, this parameter returns the temporary URL of each frame after truncation. For a description of the structure, see frame.
hintWordsInfoJSONArray[{"context":"sensitive word"}]If the image contains ads, this parameter returns information about the risk keywords that the ad text in the image hits. The value is an array. For a description of the structure, see hintWordsInfo.> Note: This result is returned only in the ad violation (ad) scenario.

| qrcodeData | StringArray | ["http://www.aliyundoc.com/01ZZOliO"] | If the image contains QR codes, this parameter returns the text information contained in all QR codes in the image.> Note: This result is returned only in the QR code (qrcode) scenario. |

| qrcodeLocations | JSONArray | | The coordinates of the QR codes that are recognized in the image. For a description of the structure, see qrcodeLocation. | | programCodeData | JSONArray | | If the image contains mini program codes, this parameter returns the location information of the mini program codes. For a description of the structure, see programCodeData.> Note: This result is returned only in the QR code (qrcode) scenario, and mini program code recognition must be enabled. |

| logoData | JSONArray | | If the image contains logos, this parameter returns information about the logos that are recognized. For a description of the structure, see logoData.> Note: This result is returned only in the logo (logo) scenario. |

| sfaceData | JSONArray | | If the image contains terrorism or politically sensitive content, this parameter returns information about the terrorism and politically sensitive content that is recognized. For a description of the structure, see sfaceData.> Note: This result is returned only in the terrorism and politically sensitive content (terrorism) scenario. |

| ocrData | StringArray | xxxx | The full text that is recognized in the image.> Note: This result is not returned by default. To obtain this result, contact your business manager. |

frame

Each element of the frames array is a frame struct that contains the following fields.

ParameterTypeExampleDescription
rateFloat89.85

The confidence score. Valid values: 0 to 100. A higher confidence score indicates a higher probability that the detection result is accurate. Avoid using this score in your business logic.

urlStringhttp://www.aliyundoc.com/xxx-0.jpgThe temporary URL of the truncated image. The URL is valid for 5 minutes.

The moderation results can also contain the following structures.

Table 5. programCodeData
Parameter Type Example Description
x Float 11.0 The x-coordinate of the upper-left corner of the mini program code area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
y Float 0.0 The y-coordinate of the upper-left corner of the mini program code area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
w Float 402.0 The width of the mini program code area. Unit: pixels.
h Float 413.0 The height of the mini program code area. Unit: pixels.
Table 6. logoData
Parameter Type Example Description
type String TV The type of the detected logo. The value is TV, which indicates a TV station logo.
name String xxx TV The name of the detected logo.
x Float 140 The x-coordinate of the upper-left corner of the logo area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
y Float 68 The y-coordinate of the upper-left corner of the logo area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
w Float 106 The width of the logo area. Unit: pixels.
h Float 106 The height of the logo area. Unit: pixels.
Table 7. sfaceData
Parameter Type Example Description
x Float 49 The x-coordinate of the upper-left corner of the face area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
y Float 39 The y-coordinate of the upper-left corner of the face area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
w Float 97 The width of the face area. Unit: pixels.
h Float 131 The height of the face area. Unit: pixels.
faces JSONArray [{"name":"Matched person","rate":91.54,"id":"AliFace_0123****"}] Information about the detected faces. Each object contains the following fields:
  • name: String. The name of the matched person.
  • rate: Float. The confidence score. The value ranges from 0 (lowest confidence) to 100 (highest confidence). A higher score indicates a higher probability that the face recognition result is accurate.
  • id: String. The face ID.
Table 8. hitLibInfo
Parameter Type Example Description
context String Haokan Video The matched content from the custom text library.
libCode String 123456 The code of the matched custom text library.
libName String abc The name of the matched custom text library.
Table 9. hintWordsInfo
Parameter Type Example Description
context String Haokan Video The matched risk keyword.
Table 10. qrcodeLocation
Parameter Type Example Description
x Float 11.0 The x-coordinate of the upper-left corner of the QR code area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
y Float 0.0 The y-coordinate of the upper-left corner of the QR code area. The origin (0,0) is the upper-left corner of the image. Unit: pixels.
w Float 402.0 The width of the QR code area. Unit: pixels.
h Float 413.0 The height of the QR code area. Unit: pixels.
qrcode String http://www.aliyundoc.com/0.ZZOliO The URL to which the detected QR code points.

Examples (query moderation results)

The following code shows a sample request:

http(s)://[Endpoint]/green/image/results
&<common request parameters>
[
    "fdd25f95-4892-4d6b-aca9-7939bc6e9baa-1486198766695"
]

The following code shows a sample success response:

{
    "msg": "OK",
    "code": 200,
    "data": [
        {
            "msg": "OK",
            "code": 200,
            "dataId": "test4lNSMdggA0c56MMvfYoh4e-1mwxpx",
            "extras": {

            },
            "results": [
                {
                    "rate": 99.63,
                    "suggestion": "block",
                    "label": "sexy",
                    "scene": "porn"
                },
                {
                    "label": "politics",
                    "rate": 91.54,
                    "scene": "terrorism",
                    "sfaceData": [
                        {
                            "faces": [
                                {
                                    "id": "AliFace_0001234",
                                    "name": "hit name",
                                    "rate": 91.54
                                }
                            ],
                            "h": 131,
                            "w": 97,
                            "x": 49,
                            "y": 39
                        }
                    ],
                    "suggestion": "block"
                },
                {
                    "extras": {
                        "qrcodes": "http://www.aliyundoc.com/0.ZZOliO",
                        "npx": "72.01",
                        "hitCustomLibCode": "8012345000",
                        "hitCustomLibName": "Custom image library name",
                        "hitLibInfo": [
                            {
                                "context": "hit text",
                                "libCode": "123456",
                                "libName": "Text library name"
                            }
                        ]
                    },
                    "programCodeData": [
                        {
                            "w": 402.0,
                            "h": 413.0,
                            "x": 11.0,
                            "y": 0.0
                        }
                    ],
                    "frames": [
                        {
                            "rate": 89.85,
                            "url": "http://www.aliyundoc.com/xxx-0.jpg"
                        },
                        {
                            "rate": 68.06,
                            "url": "http://www.aliyundoc.com/xxx-1.jpg"
                        }
                    ],
                    "rate": 99.91,
                    "suggestion": "block",
                    "label": "ad",
                    "scene": "ad"
                },
                {
                    "rate": 99.91,
                    "suggestion": "block",
                    "label": "drug",
                    "scene": "live"
                },
                {
                    "qrcodeData": [
                        "http://www.aliyundoc.com/01ZZOliO"
                    ],
                    "rate": 99.91,
                    "suggestion": "review",
                    "label": "qrcode",
                    "scene": "qrcode"
                },
                {
                    "logoData": [
                        {
                            "name": "xxx TV",
                            "type": "TV",
                            "x": 140,
                            "y": 68,
                            "w": 106,
                            "h": 106
                        }
                    ],
                    "rate": 99.9,
                    "suggestion": "block",
                    "label": "TV",
                    "scene": "logo"
                }
            ],
            "taskId": "fdd25f95-4892-4d6b-aca9-7939bc6e9baa-1486198766695",
            "url": "https://www.aliyundoc.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png"
        }
    ],
    "requestId": "69B41AE8-1234-1234-1234-12D395695D2D"
}