Common parameters must be included in all HTTP requests. Common parameters consist of common request headers and common request parameters.

Common request headers

The following table describes common request headers that must be used when you use URLs to send HTTP POST requests to call the Content Moderation API.
HeaderTypeRequiredDescription
AcceptStringYesThe data type of the response that can be accepted. Only the JSON type is supported. Set the value to application/json.
Content-TypeStringYesThe data type of the request body. Only the JSON type is supported. Set the value to application/json.
Content-MD5StringNoThe encoded value that is computed based on the request body.
To obtain the value, use the content of the request body as a string, apply the MD5 algorithm on the string to obtain an output of binary data, and then encode the output based on the Base64 algorithm.
Note This header is optional when the HMAC-SM3 encryption algorithm is used. This header is required when the HMAC-SHA1 encryption algorithm is used. By default, the HMAC-SHA1 encryption algorithm is used.
DateStringYesThe time when the request is sent. This header uses the GMT format. Example: Tue, 17 Jan 2017 10:16:36 GMT.
x-acs-versionStringYesThe version of the Content Moderation API. Set the value to 2018-05-09.
x-acs-signature-nonceStringYesA unique, random number used to prevent replay attacks. You must use different numbers for different requests.
x-acs-signature-versionStringYesThe version of the signature encryption algorithm. Set the value to 1.0.
x-acs-signature-methodStringYesThe encryption method of the signature string. Valid values:
  • HMAC-SHA1: This is the default value.
  • HMAC-SM3

For more information about the encryption method, see Request signatures.

x-acs-content-sm3StringNoThe encoded value that is computed based on the request body.

To obtain the value, use the content of the request body as a string, apply the SM3 encryption algorithm on the string to obtain a byte array, and then convert the array into the hexadecimal format. This is the encodeHexString(SM3Digest(body)) method.

AuthorizationStringYesThe authentication method. The format is "acs" + " " + AccessKeyId + ":" + signature.
Parameter description:
  • AccessKeyId: the AccessKey ID that you can obtain from the Alibaba Cloud Management Console. For more information about how to obtain the AccessKey ID, see Obtain an AccessKey pair.
  • signature: the request signature. For more information about the signature encryption algorithm, see Request signatures.

Common request parameters

The following table describes common request parameters that can be used when you use URLs to send HTTP POST requests to call the Content Moderation API.
ParameterTypeRequiredDescription
clientInfoStringNoThe information about the client that sends the request. The information is serialized from the ClientInfo structure in the JSON format. The information includes the unique machine identifier (UMID) and International Mobile Equipment Identity (IMEI) of the client. For more information, see ClientInfo.
Table 1. ClientInfo
ParameterTypeRequiredDescription
sdkVersionStringNoThe version of the Content Moderation SDK.

This parameter is required when an operation is called by using the Content Moderation SDK. For more information, see SDK overview.

cfgVersionStringNoThe version of the configuration.

This parameter is required when an operation is called by using the Content Moderation SDK. For more information, see SDK overview.

userTypeStringNoThe type of the user account. Valid values:
  • taobao: indicates a Taobao account.
  • others: indicates an account other than a Taobao account.
userIdStringNoThe unique ID of the user in the business system.

We recommend that you set this parameter to help analyze the violation behavior of the user.

userNickStringNoThe nickname of the user.
imeiStringNoThe IMEI of the device.
imsiStringNoThe International Mobile Subscriber Identity (IMSI) of the device.
umidStringNoThe UMID of the device.
ipStringNoThe public IP address of the user in the business system.

If the request is initiated from the device, this parameter can be left empty. If the request is initiated from the server, this parameter is set to the logon IP address of the user or the public IP address of the device.

We recommend that you set this parameter to help analyze the violation behavior of the user. If this parameter is not specified in the request, the server attempts to obtain the IP address from the request URL or HTTP request headers.

osStringNoThe operating system of the device. Example: Android 6.0.
channelStringNoThe channel number.
hostAppNameStringNoThe name of the host application.
hostPackageStringNoThe name of the host application package.
hostVersionStringNoThe version of the host application.

Sample requests

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"
        }
    ]
}
Parameter description:
  • POST specifies the request method.
  • /green/image/scan specifies the request path.
  • clientInfo=%7b%22userId%22%3a%22120234234%22%2c%22userNick%22%3a%22Mike%22%2c%22userType%22%3a%22others%22%7d is the encoded common request parameters.
  • The content from Accept:application/json to Content-Length:191 specifies HTTP request headers. The headers from Accept: application/json to Authorization: acs q23Q9K4PaGi12Wyk:adFff0FFO6sGcDbDNjRtso== are the common request headers used for signature.
  • The content enclosed in braces {} is the JSON-formatted request body. The structure of the request body depends on the definitions of different API operations. For more information, see List of operations by function.