Updated on 2023-07-17 GMT+08:00

Job Submission

Function

This API submits a batch of image moderation jobs, and returns the job IDs used for querying the results. It is an asynchronous API. Compared with the Image Moderation (Batch) API, this API supports a larger batch.

URI

POST /v2/{project_id}/moderation/image/batch/jobs

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Indicates the user token.

Used to obtain the permission to operate APIs. For details about how to obtain the token, see Authentication. The value of X-Subject-Token in the response header is the token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

urls

Yes

Array of strings

Indicates the URL of an image. The options are as follows:

  • HTTP/HTTPS URLs on the public network
  • HUAWEI CLOUD OBS URLs. To use OBS data, authorization is required, including service authorization, temporary authorization, and anonymous public authorization. For details, see Configuring the Access Permission of OBS.
NOTE:

You can configure a maximum of 500 URLs. The API response time depends on the image download time. If the image download takes a long time, the API call will fail. Ensure that the storage service where the image to be detected resides is stable and reliable. You are advised to use HUAWEI CLOUD OBS.

categories

No

Array of strings

Indicates the detection scenario.

  • porn: pornographic elements

You can set the parameter to the preceding values to check the corresponding elements.

moderation_rule

No

String

Indicates the name of the moderation rule. The default value is default.

NOTE:

For details about how to create and use moderation rules, see Configuring Moderation Rules.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

result

result object

Indicates the calling result of a successful API call.

This parameter is not included when the API fails to be called.

Table 5 result parameters

Parameter

Type

Description

job_id

String

Indicates the ID of a batch image moderation task, which is used for subsequent query.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Indicates the error code of a failed API call. For details, see Error Codes.

This parameter is not included when the API is successfully called.

error_msg

String

Indicates the error message of a failed API call.

This parameter is not included when the API is successfully called.

fail_category

String

Indicates the API calling failure scenario when there are multiple scenarios.

Example Requests

endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.

For example, the endpoint of the service deployed in the CN-Hong Kong region is moderation.ap-southeast-1.myhuaweicloud.com, the request URL is https://moderation.ap-southeast-1.myhuaweicloud.com/v2/{project_id}/moderation/image/batch/jobs, and project_id is the project ID. For details, see Obtaining a Project ID and Name.

Submit an asynchronous batch image moderation task to check for pornographic content.

POST https://{endpoint}/v2/{project_id}/moderation/image/batch/jobs

{
  "urls" : [ "https://bucketname.obs.myhwclouds.com/ObjectName1", "https://bucketname.obs.myhwclouds.com/ObjectName2" ],
  "categories" : [ "porn" ]
}

Example Responses

Status code: 200

Example of a successful response

{
  "result" : {
    "job_id" : "44d93b70-db01-4f96-a618-2a79c964c4b2"
  }
}

Status code: 400

Example of a failed response

{
  "error_code" : "AIS.0005",
  "error_msg" : "The service does not exist."
}

Status Codes

Status Code

Description

200

Example of a successful response

400

Example of a failed response

Error Codes

For details, see Error Codes.