API Security lets you configure built-in and custom policies across nine areas: risk detection, security events, sensitive data, authentication credentials, business purposes, allowlists, lifecycle management, log subscriptions, and effective objects. These policies improve detection accuracy, reduce false positives, and help you respond to threats against your API assets.
Key concepts
| Concept | Description |
|---|---|
| Risk | A vulnerability in an API caused by defects in development, management, or configuration. A risk does not mean an attack has occurred. |
| Security event | An abnormal call or attack on an API, such as a brute-force attack on a login API or a message flooding attack on an SMS API. |
1. Risk detection configuration
Built-in risk detection policies cover common vulnerability categories. For each built-in policy, you can enable or disable it and set its risk level to Low, Medium, or High.
In addition to built-in policies, you can create up to 20 custom risk detection policies.
Detection condition reference
The following table lists all supported match fields and their logical operators.
| Match field | Sub-condition | Logical operators | Match content |
|---|---|---|---|
| Domain Name | Not supported | Is one of / Contains no value / Is one of (exact match) / Is not one of (exact match) | Enter up to 50 values. Press Enter after each value. |
| API | Not supported | Is one of / Is not one of / Is one of (exact match) / Is not one of (exact match) | Enter up to 50 values. Press Enter after each value. |
| Request Method | Not supported | Is one of (exact match) / Is not one of (exact match) | Select one or more methods: GET, POST, DELETE, PUT. |
| User-Agent | Not supported | Can be one of / Contains no value / Is one of (exact match) / Is not one of (exact match) | Enter up to 50 values. Press Enter after each value. |
| Referer | Not supported | Contains one or more values / Contains no value / Is one of (exact match) / Is not one of (exact match) | Enter up to 50 values. Press Enter after each value. |
| Communication Protocol | Not supported | Equals | Select HTTP or HTTPS. |
| Request Content-Type | Not supported | Is one of / Contains no value | Enter up to 50 values. Press Enter after each value. |
| Request Length | Not supported | Equals / Is less than / Is greater than | Enter an integer from 0 to 8192. |
| Response Content-Type | Not supported | Is one of / No value | Enter up to 50 values. Press Enter after each value. |
| Response Length | Not supported | Equals / Is less than / Is greater than | Enter an integer from 0 to 8192. |
| HTTP Status Code | Not supported | Is one of (exact match) / Is not one of (exact match) | Enter up to 50 values. Press Enter after each value. |
| Request Header | Custom Header | Exists / Does not exist / Length is / Length is less than / Length is greater than / Is one of / Contains no value | — |
| Cookie Parameter | Custom Cookie-Exact | Exists / Does not exist / Length is / Length is less than / Length is greater than / Is one of / Contains no value | — |
| GET Parameter | Custom Parameter | Exists / Does not exist / Length is / Length is less than / Length is greater than / Is one of / Is not one of | — |
| POST Parameter | Custom Post-Arg | Exists / Does not exist / Length is / Length is less than / Length is greater than / Contains one or more values / Is not one of | — |
| Response Header | Response Header | Exists / Does not exist / Length is / Length is less than / Length is greater than / Is one of / Contains no value | — |
| Response Parameter | Response Parameter | Exists / Does not exist / Length is / Length is less than / Length is greater than / Is one of / Contains no value | — |
| Purpose | Not supported | Is one of / Contains no value | Select one or more business purposes. For available types, see How API Security classifies API business purposes. |
| Service Object | Not supported | Contains any of / Contains no value | Select one or more service objects. For available types, see How API Security classifies API service objects. |
| Authentication | Not supported | Is | YES or NO |
| Request Sensitive Data Type | Not supported | Contains any of / Contains no value / Number of types is greater than | Select one or more sensitive data types. For the "number of types is greater than" condition, enter an integer from 0 to 8192. |
| Sensitivity Level of Request Sensitive Data | Not supported | Contains any of / Contains no value | Select one or more levels from S1 to S4. |
| Response Sensitive Data Type | Not supported | Contains any of / Is not one of / Number of types is greater than | Select one or more sensitive data types. For the "number of types is greater than" condition, enter an integer from 0 to 8192. |
| Sensitivity Level of Response Sensitive Data | Not supported | Contains any of / Is not one of | Select one or more levels from S1 to S4. |
| Response Sensitive Data | Select one or more response sensitive data types. | Count is greater than | Enter an integer from 0 to 8192. |
| Source Location | Not supported | Equals | CN / NOT-CN |
| IP | Not supported | Belongs to / Does not belong to | Enter an IP address or CIDR block (for example, 1.1.X.X/24). Regular expressions are not supported. Enter up to 50 values, separated by commas or Enter. |
| Account (security events only) | Not supported | Is one of (exact match) / Is not one of (exact match) | Enter up to 50 values. Press Enter after each value. |
2. Security event configuration
Built-in security event policies detect attacks based on IP address and account dimensions. When a built-in policy triggers an alert, subsequent attacks of the same type update the attack time of the original alert rather than generating a new alert. The alert level may change based on factors such as attack volume.
Built-in policies are read-only. You cannot edit or delete them.
In addition to built-in policies, you can create up to 10 custom security event policies.
Data statistics condition reference
| Match field | Sub-condition | Logical operators | Match content |
|---|---|---|---|
| Status Code Statistics | Status code (integer from 100 to 600) | Value greater than | Enter an integer from 0 to 8192. |
| Request Header | Custom Header | Distinct less than / Distinct equals / Distinct greater than | Enter an integer from 0 to 8192. |
| Cookie Parameter | Custom Cookie-Exact | Distinct less than / Distinct equals / Distinct greater than | Enter an integer from 0 to 8192. |
| GET Parameter | Custom Parameter | Distinct less than / Distinct equals / Distinct greater than | Enter an integer from 0 to 8192. |
| POST Parameter | Custom Post-Arg | Distinct less than / Distinct equals / Distinct greater than | Enter an integer from 0 to 8192. |
| Response Sensitive Data Type | Select one or more response sensitive data types. | Distinct less than / Distinct equals / Distinct greater than | Enter an integer from 0 to 8192. |
| Sensitivity Level of Response Sensitive Data | Select one or more response sensitive data levels. | Distinct greater than | Enter an integer from 0 to 8192. |
| Source IP Count | Set the value for source IP count statistics. | Value greater than | Enter an integer from 0 to 8192. |
3. Sensitive data configuration
On the Sensitive Data-related Configurations tab of the Policy Configurations page, you can search, filter, and view sensitive data policies.
Data masking
The De-identification Display switch controls whether sensitive data is masked in the console. It is disabled by default.
When enabled, the following data is masked:
In Risk Details and API Details: sensitive data in all request and response sample fields is replaced with a placeholder such as
{{Phone}}.In Event Details: request and response data samples that contain sensitive data are masked as
{}.In sample information: Request Cookie is masked as
{{Cookie}}, a Request Header containing a token is masked as{{XXXToken}}, and Response Set-Cookie is masked as{{SetCookie}}.
Masking applies as follows:
Risk Details and API Details: applies only to new request and response data samples.
Event Details: applies to both new and existing request and response data samples.
Built-in policies
Built-in sensitive data policies are read-only. You can enable or disable them, but cannot edit or delete them.
Create a custom sensitive data policy
If your business uses custom sensitive data types, create custom detection rules. You can create up to 20 custom policies.
On the API Security page, go to Policy Configuration > Sensitive Data-related Configurations.
Click Create Policy.
In the panel that appears, configure the following parameters. You can use Basic mode or Expert mode.
Parameter Description Name Set a name for the rule. The name can contain Chinese characters, uppercase and lowercase letters, digits, periods (.), underscores (_), and hyphens (-). Mode Basic: Provides a simple interface. Set Characters (one or more character types: digits, uppercase letters, lowercase letters) and Length (range: 6–64, integer start and end values). Expert: Supports regular expressions. Enter a regular expression for detection. To avoid false positives, make sure the expression matches at least 6 characters. Sensitivity level Set the sensitivity level. Valid values: S1, S2, S3, and S4. For details, see What sensitive data can API Security detect. Click OK.
4. Authentication credential configuration
If your APIs use non-standard fields or fields with weak naming patterns (such as all-numeric names) for authentication, built-in credential detection may miss them. Create custom authentication credential policies to specify the parameter names that carry credentials. This improves the accuracy of unauthenticated risk detection.
Create a custom authentication credential policy
On the API Security page, go to Policy Configuration > Authentication Credential Configurations.
Click Create Policy.
Configure the following parameters, then click OK.
Parameter Description Name Set a name for the policy. The name can contain Chinese characters, uppercase and lowercase letters, digits, periods (.), underscores (_), and hyphens (-). Match condition Each condition consists of a Match Field, a Logical Operator, and Match Content. Add up to 10 conditions, including at least one for Request Header, Request Cookie, Request Query, or Request Body. If you define multiple conditions, a rule is triggered only when all conditions are met.
Match content for Authentication Credential Configurations is case-sensitive. You can enter up to 50 values per field. Press Enter after each value.
Match condition reference
| Match field | Sub-condition | Logical operators |
|---|---|---|
| Domain Name | Not supported | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value |
| API | Not supported | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value |
| Request Header | Custom Header | Exists / Length equal to / Length less than / Length greater than |
| Request Cookie | Custom Cookie-Exact | Exists / Length equal to / Length less than / Length greater than |
| Request Query | Custom Parameter | Exists / Length equal to / Length less than / Length greater than |
| Request Body | Custom Post-Arg | Exists / Length equal to / Length less than / Length greater than |
5. Business purpose configuration
Business purpose policies classify APIs by their function—for example, login, registration, SMS sending, or file download. Accurate classification improves detection in business-specific scenarios.
API Security provides two types of business purpose policies:
Built-in policies: Cover common scenarios such as data updates, data sharing, text message sending, and information sending. You can enable or disable built-in policies, but cannot modify or delete them.
Custom policies: Let you define custom URL and parameter name patterns for scenarios not covered by built-in policies.
Create a custom business purpose policy
On the API Security page, go to Policy Configuration > Business Purpose.
Click the Custom Policy tab, then click Create Policy.
Configure the match conditions, then click OK.
Match content for Business Purpose is case-sensitive. You can enter up to 50 values per field. Press Enter after each value.
Match condition reference
| Match field | Logical operators | Match content |
|---|---|---|
| Domain Name | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
| API | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
| Request Header Parameter Name | Contains one of multiple values / Equals one of multiple values | Enter up to 50 values. Press Enter after each value. |
| Request Cookie Parameter Name | Contains one of multiple values / Equals one of multiple values | Enter up to 50 values. Press Enter after each value. |
| Request Query Parameter Name | Contains one of multiple values / Equals one of multiple values | Enter up to 50 values. Press Enter after each value. |
| Request Body Parameter Name | Contains one of multiple values / Equals one of multiple values | Enter up to 50 values. Press Enter after each value. |
| Request Sensitive Data Type | Equals one of multiple values / Does not equal any value | Select one or more request sensitive data types. |
| Response Sensitive Data Type | Equals one of multiple values / Does not equal any value | Select one or more response sensitive data types. |
| Response Parameter Name | Contains one of multiple values / Equals one of multiple values | Enter up to 50 values. Press Enter after each value. |
6. Allowlist configuration
Allowlists let you suppress alerts from known-safe sources—for example, traffic from your office network's egress IP address. You can create allowlists for risk detection and security events separately.
Create an allowlist policy
On the API Security page, go to Policy Configuration > Configure Whitelist.
Click Create Policy, enter a name, and select the feature type: Risk Detection or Security Events.
Set match conditions based on the feature type, then select the risk or event types to ignore, and click OK.
You can add up to 10 match conditions. Match conditions for Configure Whitelist are case-sensitive. You can select multiple built-in and custom types to ignore.
Risk detection allowlist match conditions
| Match field | Logical operators | Match content |
|---|---|---|
| Domain Name | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
| API | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
Security event allowlist match conditions
| Match field | Logical operators | Match content |
|---|---|---|
| Domain Name | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
| API | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
| IP | Belongs to / Does not belong to | Enter an IP address or CIDR block (for example, 1.1.X.X/24). Regular expressions are not supported. Enter up to 50 values, separated by commas or Enter. |
| Account | Contains one of multiple values / Does not contain any value / Equals one of multiple values / Does not equal any value | Enter up to 50 values. Press Enter after each value. |
7. Lifecycle management
API lifecycle management lets you define what counts as an inactive API, so you can identify and act on APIs that are no longer actively used. Inactive APIs can be exploited if left unaddressed.
Configure inactive API criteria
On the API Security page, go to Policy Configuration > Lifecycle Management.
Set the criteria for inactive APIs, then click OK.
Built-in model: An API is considered inactive if it has not been accessed or its access volume has dropped significantly over the past 8 days.
Custom: Set the daily access volume threshold and duration (up to 31 days). An API is considered inactive if its daily access count stays below the specified value for the entire duration.
If an asset's Last Active Time exceeds 30 days, the system automatically deletes the asset along with its associated risk data and security event records.
8. Log subscription
Log subscription delivers API Security logs to a Logstore in Simple Log Service (SLS), where you can centrally manage, query, and analyze them.
Three log types are available: asset information, risk information, and attack event information.
WAF instances in the Chinese mainland can deliver logs only to SLS Logstores in the Chinese mainland. WAF instances outside the Chinese mainland can deliver logs only to SLS Logstores outside the Chinese mainland. Cross-region log delivery between the Chinese mainland and other regions is not supported.
Prerequisites
Before you begin, make sure you have:
Enabled the service-linked role for WAF (skip this step if you already granted this authorization when enabling Simple Log Service for WAF). For details, see Service-linked Role.
Created a Project and Logstore in the Simple Log Service console to receive the logs.
The log subscription feature does not support Logstores automatically created by SLS or Logstores namedwaf-logstore,wafng-logstore, orwafnew-logstore.
Configure a log subscription task
On the API Security page, go to Policy Configuration > Log Subscription.
Select the log type, then click Configure.
Select the Region, Project name, and Logstore name, then click OK. After configuration, logs are delivered to the Logstore when trigger conditions are met. To query and analyze logs in SLS, enable indexing as prompted. For details, see Create indexes.
To disable a log subscription task and avoid ongoing Logstore charges, disable the task on the Log Subscription tab and delete the corresponding Logstore. For details, see How do I disable Simple Log Service or stop billing?.
Creating cloud resources and enabling indexing in Simple Log Service may incur additional fees billed by Simple Log Service. For pricing details, see Billing overview of Simple Log Service.
Charges may still apply after you create a Project or Logstore even if no log subscription task is enabled. Delete unused Logstores promptly to avoid extra charges. For details, see Why am I charged for creating only a Project and a Logstore?.
Log trigger conditions and fields
Log field value reference
Use this reference when analyzing logs or correlating field values with the WAF console display.
9. Effective object configuration
Effective object configuration controls which detection policies apply to which protected objects.
Subscription WAF
API Security provides three switches at the protected object or protected object group level:
Basic Detection: Enabled by default. Controls whether all built-in and custom detection policies are active.
Compliance Check: Disabled by default. Can be enabled only after Basic Detection is on. Controls whether the Compliance Check feature is active.
Tracing and Auditing: Disabled by default. Can be enabled only after Basic Detection is on. Controls whether the Tracing and Auditing feature is active.
Pay-as-you-go WAF
API Security provides one switch at the protected object or protected object group level:
Basic Detection: Controls whether all built-in and custom detection policies are active. To disable API Security entirely, turn off Basic Detection for all protected objects and protected object groups.