Every HTTP request to Content Moderation includes a set of common request headers and query parameters. Combine these common parameters with the operation-specific parameters described in each API operation topic.
Common request headers
The following table describes the common request headers for Content Moderation detection API requests.
Parameter | Type | Required | Description |
Accept | String | Yes | The type of the returned result. Only the JSON type is supported. Valid value: application/json. |
Content-Type | String | Yes | The data type of the current request body. Only the JSON type is supported. Valid value: application/json. |
Content-MD5 | String | No | The Base64-encoded MD5 hash of the request body. Algorithm: Treat the content of the request body as a string, apply MD5 encoding to it, which returns data in binary format, and then apply Base64 encoding. Note If the encryption algorithm is set to HMAC-SM3, you can leave this field blank. If the encryption algorithm is set to HMAC-SHA1 (default), this field is required. |
Date | String | Yes | The time when the request is made. Specify the value in GMT format. For example, |
x-acs-version | String | Yes | The version number of the Content Moderation API. Valid value: 2018-05-09. Versions earlier than 2018-05-09 are discontinued. If you use an earlier version number, the request returns |
x-acs-signature-nonce | String | Yes | The signature nonce. It prevents network replay attacks. We recommend that you use a different random number for each request. |
x-acs-signature-version | String | Yes | The version of the signature algorithm. Valid value: 1.0. |
x-acs-signature-method | String | Yes | The signing method. Valid values: - HMAC-SHA1 (default) - HMAC-SM3 For more information about signing methods, see Request signatures. |
x-acs-content-sm3 | String | No | The SM3 hash of the request body, converted to a hexadecimal string. Algorithm: Treat the content of the request body as a string, apply SM3 encryption to it to obtain a byte array, and then convert the byte array to hexadecimal. That is, |
Authorization | String | Yes | The authentication method. The format is |
Common request parameters
The following table describes the common query parameters for Content Moderation detection API requests.
Parameter | Type | Required | Description |
clientInfo | String | No | Information about the client that initiates the request. The value is obtained from the ClientInfo struct through JSON serialization and includes information such as umid or imei. For the structure, see clientInfo. |
The clientInfo parameter includes the following fields:
Parameter | Type | Required | Description |
sdkVersion | String | No | The SDK version number. Provide this field when you make calls by using an SDK. For more information, see SDK overview. |
cfgVersion | String | No | The version of the configuration information. Provide this field when you make calls by using an SDK. For more information, see SDK overview. |
userType | String | No | The type of the user account. Valid values: - taobao: a Taobao account. - Others: an account in another account system. |
userId | String | No | The unique identifier of the user in your business system. We strongly recommend that you specify this value for user violation analysis. |
userNick | String | No | The user nickname. |
imei | String | No | The International Mobile Equipment Identity (IMEI) of the device. |
imsi | String | No | The International Mobile Subscriber Identity (IMSI) of the device. |
umid | String | No | The unique machine identifier (UMID) of the device. |
ip | String | No | The public IP address associated with the user. If the request originates from a device, you usually leave this field blank. If the request originates from your backend, set this field to the sign-in IP address of the user or the public IP address of the device. We recommend that you specify this IP address for user violation analysis. If you do not specify it in the request, the server attempts to obtain the IP address from the request URL or the HTTP request header. |
os | String | No | The type of the operating system of the device. For example, Android 6.0. |
channel | String | No | The channel ID. |
hostAppName | String | No | The name of the host application. |
hostPackage | String | No | The package name of the host application. |
hostVersion | String | No | The version of the host application. |
Request example
POST /green/image/scan?clientInfo=%7b%22userId%22%3a%22120234234%22%2c%22userNick%22%3a%22Mike%22%2c%22userType%22%3a%22others%22%7d HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-MD5: C+5Y0crpO4sYgC2DNjycug==
Date: Tue, 15 May 2018 10:16:36 GMT
x-acs-version: 2018-05-09
x-acs-signature-nonce: adfkjfaHKslkjf
x-acs-signature-version: 1.0
x-acs-signature-method: HMAC-SHA1
Authorization: acs q23Q9K4PaGi12Wyk:adFff0FFO6sGcDbDNjRtso==
Host: green.cn-shanghai.aliyuncs.com
Content-Length: 191
{
"scenes": [
"porn"
],
"tasks": [
{
"dataId": "test2NInmO$tAON6qYUrtCRgLo-1mwxdi",
"url": "https://img.alicdn.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png"
}
]
}The request includes the following components:
POST: the request method./green/image/scan: The request path.clientInfo=%7b%22userId%22%3a%22120234234%22%2c%22userNick%22%3a%22Mike%22%2c%22userType%22%3a%22others%22%7d: the encoded common request parameter.The lines from
Accept: application/jsontoContent-Length: 191: the HTTP request headers. Among them, the headers fromAccept: application/jsontoAuthorization: acs q23Q9K4PaGi12Wyk:adFff0FFO6sGcDbDNjRtso==are the common request headers used to calculate the signature.The content in
{}: the request body in JSON format. The structure of the request body depends on the definition of each API operation. See the documentation for the specific API operation.