Manual text review

Updated at:

This topic describes how to call the /green/text/manual/asyncScan operation to submit text for manual review. In addition to its machine-based detection service, AI Guardrails provides a manual review service. You can use the manual review feature if you require a high accuracy and recall rate for your detection results.

Note

Before you use this service, contact your account manager to determine the review standards and content scope. This operation does not return machine-based detection results. If you need machine-based detection results, you must call a detection service operation. For more information about detection service operations, see Synchronous text detection.

Usage notes for manual text review

Operation: /green/text/manual/asyncScan

The manual review operation does not return detection results in real time. You must obtain the results using a callback or polling. The detection results are retained for a maximum of 30 days.

  • Billing:

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

  • Response:

    The time it takes to return manual review results depends on the amount of data to be reviewed.

    • Obtain detection results using a callback: When you submit manual review tasks, you can specify the callback parameter in the request to automatically receive the detection results. For more information, see Request parameters.

    • Obtain detection results using polling: When you submit manual review tasks, you do not need to specify the callback parameter. After you submit the tasks, you can call the result query operation to obtain the detection results. For more information, see Usage notes for querying manual text review results.

For more information about how to use this operation, see Enable the manual review service.

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 for manual review

For more information about the common request parameters that must be included in requests, see Common parameters.

The request body is a JSON struct that contains the following fields:

Name

Type

Required

Example

Description

callback

String

No

http://aliyundoc.com

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

Yes

seedxxx

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.

tasks

JSONArray

No

The detection objects. Each element in the JSON array is a struct for a detection task. You can specify up to 100 elements. This means you can submit up to 100 pieces of content for detection at a time. To specify 100 elements, you must set the number of concurrent tasks to more than 100. For more information about the structure of each element, see task.

Table 1. task

Name

Type

Required

Example

Description

content

String

Yes

test

The text content for manual review. The content can be up to 10,000 characters in length, including Chinese characters, letters, and punctuation marks.

dataId

String

No

dataIdxxxx

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.

Response parameters for manual review

Name

Type

Example

Description

code

Integer

200

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

For more information, see Common error codes.

data

JSONArray

The data returned for the request. Each element in the array indicates the result of a manual review task. For more information about the structure of each element, see data.

msg

String

OK

The message returned for the request.

requestId

String

2C01A0EE-B5BF-429B-898A-9F6D301342EB

The request ID.

Table 2. data

Name

Type

Example

Description

code

Integer

200

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

For more information, see Common error codes.

dataId

String

dataIdxxxx

The data ID of the detection object.

Note

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

msg

String

OK

The message returned for the detection task.

taskId

String

txt17xfqjr4XWx4FrfsGw5YxL-1tyzBX

The ID of the manual review task. You can use this ID to call the result query operation to query the result of the manual review task.

content

String

text

The text content for manual review. The content can be up to 10,000 characters in length, including Chinese characters, letters, and punctuation marks.

Examples for manual review

Sample request

http(s)://[Endpoint]/green/text/manual/asyncScan
&<Common request parameters>
{
    "callback": "http://aliyundoc.com",
    "seed": "seedxxx",
    "tasks": [{
        "content": "test text",
        "dataId": "dataIdxxxx"
    }]
}

Sample success response

{
    "code": 200,
    "data": [{
        "code": 200,
        "content": "test text",
        "dataId": "dataIdxxxx",
        "msg": "OK",
        "taskId": "txt17xfqjr4XWx4FrfsGw5YxL-1tyzBX"
    }],
    "msg": "OK",
    "requestId": "2C01A0EE-B5BF-429B-898A-9F6D301342EB"
}

Usage notes for querying manual text review results

Operation: /green/text/manual/scan/results. You can use this operation to query the results of a manual text review.

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 for result query

Name

Type

Required

Example value

Description

body

StringArray

Yes

["txt17xfqjr4XWx4FrfsGw5YxL-1tyzBX"]

A list of the taskId values of the manual review tasks that you want to query. The array can contain up to 100 elements.

Response parameters for result query

Name

Type

Example

Description

code

Integer

200

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

For more information, see Common error codes.

data

JSONArray

The data returned for the request. Each element in the array indicates the result of a manual review task. For more information about the structure of each element, see data.

msg

String

OK

The message returned for the request.

requestId

String

2061F868-396C-4F00-9F32-792914428EA1

The request ID.

Table 3. data

Name

Type

Example value

Description

code

Integer

200

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

For more information, see Common error codes.

dataId

String

dataIdxxxx

The data ID of the detection object.

Note

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

msg

String

OK

The message returned for the detection task.

suggestion

String

block

The recommended subsequent operation. Valid values:

  • pass: The result is normal. No other operations are required.

  • block: The result is a violation. We recommend that you delete the content or restrict public access to it.

taskId

String

txt17xfqjr4XWx4FrfsGw5YxL-1tyzBX

The task ID.

content

String

test text xxx

The text content for manual review.

Examples for result query

Sample request

http(s)://[Endpoint]/green/text/manual/scan/results
&<Common request parameters>
[
    "txt17xfqjr4XWx4FrfsGw5YxL-1tyzBX"
]

Sample success response

{
    "code": 200,
    "data": [{
        "code": 200,
        "content": "test text xxx",
        "dataId": "dataIdxxxx",
        "msg": "OK",
        "suggestion": "block",
        "taskId": "txt17xfqjr4XWx4FrfsGw5YxL-1tyzBX"
    }],
    "msg": "OK",
    "requestId": "2061F868-396C-4F00-9F32-792914428EA1"
}