This topic describes how to call the CreateKeywordLib operation to create a custom text library. You can use text libraries for text anti-spam. The effect of managing custom text libraries by calling API operations is the same as that of managing custom text libraries in the Alibaba Cloud Content Moderation console.

Description

Operation: CreateKeywordLib

You can call this operation to create a text library. The created text library can be used for text anti-spam.

Request parameters

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

The following table describes the parameters in the request body.
Parameter Type Required Description
ServiceModule String Yes The name of the service module to which the text library is applied. Valid value: open_api (indicates the Content Moderation API).
Name String Yes The name of the text library.
ResourceType String Yes The resource type of the text library. Valid values:
  • TEXT: a literal text library.
  • IMAGE: a text library against which text extracted from images is matched.
  • VOICE: a text library against which text converted from audio is matched.
BizTypes List No The business type of the custom text library that you set on the Moderation Policy tab (by choosing Settings > Moderation API).
Category String Yes The category of the text library. Valid values:
  • BLACK: a blacklist.
  • WHITE: a whitelist.
  • REVIEW: a review list.
LibType String Yes The type of the text library in each moderation scenario. Valid values:
  • Text anti-spam
    • textKeyword: a text library against which terms in text are matched.
    • similarText: a text library against which text patterns are matched.
  • Detection of ads in images

    textKeyword: a text library against which terms extracted from images are matched.

  • Audio anti-spam

    voiceText: a text library against which terms converted from audio are matched.

MatchMode String No The matching method. Valid values:
  • fuzzy: fuzzy matching.
  • precise: exact matching.
Enable Boolean No Specifies whether to enable the text library. A value of true indicates that the text library is enabled, and a value of false indicates that the text library is disabled.

Response parameters

For more information about common response parameters that this operation returns, see Common response parameters.
Parameter Type Required Description
code Integer Yes The error code. Most error codes are consistent with HTTP status codes, and some error codes are extended.
  • 2xx: indicates a success.
  • 4xx: indicates an incorrect request.
  • 5xx: indicates a back-end error.
For more information, see Common errors.
msg String No The description of the call error.
requestId String Yes The unique ID of the request, which can be used to locate issues.
id String Yes The unique ID of the text library, which can be used to perform subsequent operations on the text library.

Examples

Sample requests
{
  "Name": "test1sdkdk",
  "BizTypes": [],
  "Category": "BLACK",
  "ServiceModule": "open_api",
  "ResourceType": "TEXT",
  "LibType": "textKeyword"
}
Sample success responses
{
  "RequestId": "795D8871-4889-4C0F-A8B1-C7D2B990FF61",
  "code": 200,
  "Id":123
}