This topic describes the signature method that you can use to call the Content Moderation API.


  1. Serialize request headers.
    Concatenate all the request headers that start with x-acs- to create a string based on the following rules:
    1. Extract all the HTTP headers that start with x-acs-.
    2. Sort the extracted HTTP headers in alphabetical order.
    3. Write each HTTP header in the format of "HTTP header name" + ":" + "HTTP header value" + "\n".
  2. Serialize the URI and query parameters.
    Use the uri + "?clientInfo =" + "JSON string of ClientInfo" format to concatenate the URI and clientInfo parameters.
    Note In this step, URL encoding is not required.
  3. Create a string-to-sign.
    Use the following syntax:
    "POST\napplication/json\n" + 
    "Value of the Content-MD5 header" + "\n" + 
    "application/json" + "\n" + 
    "Value of the Date header" + "\n" + 
    "Serialized request headers" + 
    "Serialized URI and query parameters"
    The following example shows a complete string-to-sign that can be used to call a synchronous operation for image moderation:
    Tue, 14 Mar 2017 06:29:50 GMT
    /green/image/scan? clientInfo={"ip":"","userId":"12023xxxx","userNick":"Mike","userType":"others"}
  4. Generate the signature string.
    1. Use the HMAC-SHA1 algorithm to calculate the HMAC value of the string-to-sign that is created in Step 3. The AccessKey secret is used as the key for the HMAC calculation. The HMAC value is an array of bytes.
      Note In this step, do not perform other operations on the HMAC value.
    2. Encode the HMAC value in Base64 to obtain the signature string.
    3. Set the value of signature to the obtained signature string in the Authorization header. The value of the Authorization header follows the syntax: "acs" + " " + AccessKeyId + ":" + signature.
      Note In the preceding syntax, a space is added between acs and AccessKeyId.