This topic describes how to use the Enhanced Manual Moderation API for the manual review of images, text, audio, and video. Use this service for high-accuracy moderation.
Before you use this service, contact your account manager to finalize the moderation criteria and content scope. This API does not return automated moderation results. If you need automated results, call the automated moderation API.
Access
Sign up for an Alibaba Cloud account: Sign up now.
To enable the pay-as-you-go Enhanced Manual Moderation service: Make sure you have enabled the service. Enabling the service is free. After you integrate and use the API, the system automatically bills you based on your usage. For more information, see Introduction and Billing of Enhanced Manual Moderation.
Create an AccessKey: Make sure that you have used RAM to create an AccessKey. If you use a RAM user's AccessKey, you must use your primary account to grant the AliyunYundunGreenWebFullAccess permission to the RAM user. For more information, see RAM authorization.
Integrate with the API: We recommend calling the API using an SDK. For more information, see SDKs and access guide for Enhanced Manual Moderation.
The Enhanced Manual Moderation asynchronous service consists of two APIs:
ManualModeration: Submits an asynchronous manual moderation task.
ManualModerationResult: Queries the results of a moderation task.
Submit an asynchronous moderation task
Overview
Call this API to create a manual moderation task. For information on how to construct an HTTP request, see Build an HTTP request. You can also use a pre-built HTTP request. For more information, see Access guide.
API operation: ManualModeration
Supported regions and endpoints:
Region | Public endpoint | Internal endpoint |
China (Shanghai) | https://green-cip.cn-shanghai.aliyuncs.com | https://green-cip-vpc.cn-shanghai.aliyuncs.com |
Billing:
This is a paid API. For information about billing, see Introduction and billing of Enhanced Manual Moderation.
Response: Asynchronous moderation tasks do not return results in real time. You must retrieve the moderation results by using a callback or by polling. The results are stored for up to 30 days. The time to receive results depends on the data volume.
Callback: When you submit a manual moderation task, include the callback parameter in the request to automatically receive the moderation results. For more information, see Request parameters.
Polling: When you submit a manual moderation task, you do not need to include the callback parameter. After submitting the task, call the result query API to retrieve the moderation results. For more information, see Query the moderation results.
Content requirements:
Text requirements:
A single long text submission cannot exceed 10,000 characters. Submissions that exceed this limit return an error. We recommend that you split longer text into segments.
Image requirements:
Image URLs must use the HTTP or HTTPS protocol.
Supported image formats: PNG, JPG, JPEG, BMP, WEBP, TIFF, SVG, HEIC (the longest side must be less than 8,192 pixels), GIF (first frame only), and ICO (last image only).
The maximum image size is 20 MB. The height or width cannot exceed 16,384 pixels, and the total pixel count cannot exceed 167 million. We recommend a resolution of at least 200 x 200 pixels. Low resolution can affect algorithm performance.
The timeout for image downloads is 3 seconds. If the download takes longer, the request times out and returns an error.
Audio requirements:
Supported audio file formats: MP3, WAV, AAC, WMA, OGG, M4A, and AMR.
Supported video file formats: AVI, FLV, MP4, MPG, ASF, WMV, MOV, RMVB, and RM.
The audio file size limit is 500 MB.
Video requirements:
Video file URLs must use the HTTP or HTTPS protocol.
Supported video file formats: AVI, FLV, MP4, MPG, ASF, WMV, MOV, WMA, RMVB, RM, FLASH, and TS.
The default video size limit is 500 MB per file. If your video exceeds 500 MB, split it into smaller segments or contact us to increase the size limit.
Moderation time depends on the file download time. For best results, use a stable and reliable storage service, such as Alibaba Cloud OSS.
QPS limit
The QPS limit per user is 100. Exceeding this limit results in API throttling, which may affect your business. Call the API at a reasonable rate. If you have a high volume of traffic or require an urgent increase in your QPS limit, contact your account manager.
Debug
Before you integrate with the API, you can use the OpenAPI Explorer to debug the ManualModeration API online. This tool provides sample code and SDK dependency information to help you understand how to use the API and its parameters.
API calls made through the online debugger use your logged-in account and are billed accordingly.
Request parameters
For information about the common request parameters that must be included in a request, see Access guide.
The request body is a JSON object that contains the following fields:
Parameter | Type | Required | Example | Description |
Service | String | Yes | imageManualCheck | The moderation service supported by Enhanced Manual Moderation. Valid values:
|
ServiceParameters | JSONString | Yes | The parameter set for the content to be moderated. This is a JSON string. For a description of each field, see ServiceParameters. |
Table 1. ServiceParameters
Parameter | Type | Required | Example | Description |
url | String | Yes. Provide one of the following:
| https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png | The URL of the content to be moderated. Ensure that the URL is publicly accessible and does not exceed 2,048 characters. Note The URL cannot contain Chinese characters. Ensure that only one URL is provided per request. |
content | String | This is the text content to be moderated. | The text content to be moderated. | |
dataId | String | No | img123**** | The data ID associated with the content to be moderated. This ID can be up to 64 characters long and can contain letters, digits, underscores (_), hyphens (-), and periods (.). Use it to map the moderation task to your business data. |
callback | String | No | http://www.aliyundoc.com | The URL to which moderation results are sent as a callback notification. Both HTTP and HTTPS are supported. If this field is empty, you must periodically poll for the moderation results. The callback endpoint must support POST requests, UTF-8 encoded data, and the form parameters ReqId, Checksum, and Content. Content Moderation sets the ReqId, Checksum, and Content parameters and calls your callback endpoint according to the following rules:
Note The user UID must be the UID of the Alibaba Cloud account, not the UID of a RAM user.
Note When your server's callback endpoint receives the results from Content Moderation, an HTTP status code of 200 indicates successful receipt. Any other HTTP status code is considered a failure. If a delivery fails, Content Moderation retries up to 16 times. After 16 failed attempts, the delivery is abandoned. We recommend that you check the status of your callback endpoint. |
seed | String | No | abc**** | A random string used to sign the callback notification. It can contain letters, digits, and underscores (_) and be up to 64 characters long. Define this value to verify that the callback notification originates from Alibaba Cloud Content Moderation. Note This field is required if you use callbacks. |
cryptType | String | No | SHA256 | When using callback notifications (callback), this specifies the encryption algorithm for the callback content. Content Moderation encrypts the result (a string created by concatenating user UID + seed + content) using the specified algorithm before sending it to your callback URL. Valid values:
|
Response data
Name | Type | Example | Description | |
Code | Integer | 200 | The status code. For more information, see Status codes. | |
Msg | String | OK | The response message for the request. | |
RequestId | String | ABCD1234-1234-1234-1234-123**** | The request ID. | |
Data | Object | The response data. | ||
TaskId | String | task-1234-1234-1234-123**** | The task ID. You can use this ID to query the moderation task results. | |
DataId | String | img123****** | The data ID associated with the moderated content. | |
Examples
Image, audio, or video moderation request example:
{
"Service": "imageManualCheck",
"ServiceParameters": {
"url": "https://img.alicdn.com/tfs/TB1Mq6ZmCslXu8jSZFuXXXg7FXa-1440-568.jpg",
"dataId": "test0307******"
}
}Text moderation request example:
{
"Service": "longTextManualCheck",
"ServiceParameters": {
"content": "This is the text content to be moderated.",
"dataId": "test0307******"
}
}Response example:
{
"Msg": "OK",
"Code": 200,
"RequestId": "ABCD1234-1234-1234-1234-1234XYZ",
"Data": {
"TaskId": "task-1234-2024-0307-0728****",
"DataId": "test0307******"
}
}Query the moderation results
API
API operation: ManualModerationResult, used to retrieve the results of an Enhanced Manual Moderation task.
Billing: This API is free of charge.
We recommend waiting 30 seconds after submitting a task before you begin polling for results. The results are automatically deleted after 30 days.
QPS limit
The QPS limit for a single user is 100. If you exceed this limit, API calls are throttled, which may affect your business. Call the API at a reasonable rate.
Debug
Before you integrate with the API, you can use the OpenAPI Explorer to debug the ManualModerationResult API online. This tool provides sample code and SDK dependency information to help you understand how to use the API and its parameters.
Request parameters
Parameter | Type | Required | Example | Description |
taskId | String | Yes | task-1234-2024-0307-0728**** | The task ID. This is the TaskId field returned when you submit an asynchronous moderation task. |
Response data
Parameter | Type | Example | Description |
RequestId | String | ABCD1234-1234-1234-1234-123**** | A unique, Alibaba Cloud-generated identifier for the request. Use this ID for troubleshooting. |
Data | Object | The content moderation result. For more information, see Data. | |
Code | Integer | 200 | The status code. For more information, see Status codes. |
Msg | String | OK | The response message for this request. |
Table 2. Data
Parameter | Type | Example | Description |
Result | Array | The result parameters, such as risk labels. For more information, see Result. | |
RiskLevel | String | high | The risk level, returned based on the configured high and low risk thresholds. Valid values include:
Note We recommend taking immediate action on high-risk content. No action is required for content with a risk level of |
DataId | String | img123****** | The data ID associated with the moderated content. Note If you provided a dataId in the moderation request, the same dataId is returned here. |
TaskId | String | task-1234-2024-0307-0728**** | The task ID associated with the moderated content. |
Table 3.Result
Parameter | Type | Example | Description |
Label | String | porn | The label assigned by manual moderation. Multiple labels may be returned. Supported labels:
|
Description | String | Pornography | A description of the Label field. Important This field is a human-readable description of the |
Examples
Request example
{
"taskId": "TASK1234-1234-1234-1234-123****"
}Response examples
Example response when manual moderation detects risky content:
{
"Msg": "success",
"Code": 200,
"Data": {
"DataId": "img123****",
"TaskId": "TASK1234-1234-1234-1234-123***",
"Result": [
{
"Label": "porn",
"Description": "Pornography"
}
],
"RiskLevel": "high"
},
"RequestId": "ABCD1234-1234-1234-1234-123****"
}Example response when manual moderation does not detect any risky content:
{
"Msg": "success",
"Code": 200,
"Data": {
"DataId": "img123****",
"TaskId": "TASK1234-1234-1234-1234-123***",
"Result": [
{
"Label": "nonLabel",
"Description": "No risk detected"
}
],
"RiskLevel": "none"
},
"RequestId": "ABCD1234-1234-1234-1234-123****"
}Status codes
The following table describes the API status codes. You are only billed for successful requests that return a status code of 200.
Code | Description |
200 | The request was successful. |
280 | The task is under review. |
400 | A request parameter is empty. |
401 | A request parameter is invalid. |
402 | The length of a request parameter does not meet the API requirements. Check and modify the parameter. |
403 | The request exceeds the QPS limit. Check and adjust the concurrency. |
404 | An error occurred while downloading the file. Check the file URL or try again. |
405 | The file download timed out. The file may be inaccessible. Check the URL and try again. |
406 | The file is too large. Check the file size and try again. |
407 | The file format is not supported. Check the format and try again. |
408 | The account does not have permission to call this API. The account may not have the service activated, may have overdue payments, or may not be authorized to access the API. |
500 | A system error occurred. |