Skip to content

Modify Sensitive Field Masking Rule



POST /api/v1/data_mask_rule/{data_mask_rule_uuid}/modify

Overview

Modify the current workspace's masking rule configuration in full while preserving its enabled/disabled status.

Prerequisites and Usage Steps

This write endpoint requires the dataRightsManage.workspaceConfigManage management permission.

Use the API Key of the target workspace. This configuration group is an independent sensitive rule at the query return stage; it does not rewrite raw stored data, does not create fields, and is not a permanent deletion/anonymization API.

First read the details for backup, then submit all name/type/field/reExpr/roleUUIDs using the rule UUID. This is a full configuration overwrite rather than a partial update; status is preserved, and enabling/disabling uses a separate endpoint.

Writes are committed first, then the rule cache for the corresponding data category is deleted (modification clears both old and new categories); a cache failure may occur after the commit. Then test with the actual reading identity. A successful save in the rule list does not mean the rule has been verified as effective across all query surfaces and caches.

Effectiveness also depends on the target query chain, data category, and actual role set; role configuration is not data query authorization itself. When the same account/Key has multiple roles with query permission for that category, if one of those roles has no applicable sensitive rule, the entire rule group may not be applied. Do not bind only one role and assume masking is enforced for all readers; verify with the actual role/Key in Query Data and the target display surface. Current regex replacement processes only string values; numbers, objects, arrays, booleans, and null are not automatically converted to strings for masking. In standard query matching, the matched string portion is replaced with ***, and the other text is retained. Regular expression validation on save uses the regex library, while the query execution path uses standard re; it is recommended to use only syntax compatible with Python standard re.

Route Parameters

Parameter Name Type Required Description
data_mask_rule_uuid string Y UUID of a non-deleted rule in the current workspace; disabled rules can also be read/modified.
Example: wdmk_example
How to obtain or enter: Obtain from content.data[\*].uuid in the response of Masking Rule List.

Request Headers

Parameter Name Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or enter: Obtain an OpenAPI Key with this operation permission from API Key management in the target workspace.

Body Request Parameters

Parameter Name Type Required Description
roleUUIDs[*] string One role UUID. Before writing, the server checks that it is in the workspace's available role set.
Example: role_example
How to obtain or enter: Enter the UUID of each role in the role list, not the role name.
name string Y Required and non-empty, maximum 128 characters; duplicate names are currently allowed, and idempotency by name is not guaranteed.
Allows null: False
Maximum length: 128
Allows empty string: False
Example: 验证码脱敏
How to obtain or enter: Enter the purpose of the rule; first check existing configurations in the list to avoid duplicate creation after a timeout.
type string Y Required. The historical declaration allows null, but clients must select an actually supported category and must not treat null as all categories; null cannot form a reliably effective rule, and modification may also violate the non-null storage constraint.
Allows null: True
Allowed values: ['lineage', 'logging', 'metric', 'object', 'custom_object', 'keyevent', 'tracing', 'rum', 'security', 'network', 'profiling', 'billing']
Example: logging
How to obtain or enter: Select lineage/logging/metric/object/custom_object/keyevent/tracing/rum/security/network/profiling/billing according to the actual query data category.
field string Y Comma-separated list of field names; a standalone * item means all fields. Field-name prefix wildcards such as message* are not supported. When all fields are needed, it is recommended to pass * alone.
Allows null: False
Maximum length: 128
Allows empty string: False
Example: message
How to obtain or enter: Obtain the original field name from the corresponding data field query; do not enter an alias.
reExpr string Y Required and non-empty, maximum 5000 characters. The example converts 验证码=123456 to 验证码=***; custom replacement parameters are not supported. Some extended regex syntax can be saved but fails when executed with standard re; do not determine usability based only on a successful save.
Allows null: False
Maximum length: 5000
Allows empty string: False
Example: (?<=验证码=)[0-9]{6}
How to obtain or enter: Enter a standard Python re-compatible expression and use JSON escaping; you can first test it with controlled samples in Masking Test.
roleUUIDs array Y Required array. The current check excludes deleted roles; disabled but non-deleted roles may pass. [] means no explicitly matched role, not all roles. Do not treat * as a validation-free wildcard role for this public API; if the normal role table does not contain that UUID, a 404 is returned.
Allows null: False
Example: ["role_example"]
How to obtain or enter: Obtain available, non-deleted role UUIDs in the current workspace from Role List; for system roles, use the real identifier from the list.

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/data_mask_rule/wdmk_example/modify' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"验证码脱敏","type":"logging","field":"message","reExpr":"(?<=验证码=)[0-9]{6}","roleUUIDs":["role_example"]}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content boolean Returns true on success; read back the details to confirm the configuration.
{
  "code": 200,
  "content": true,
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Invalid request JSON syntax Request JSON format error Fix the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The top level of the request JSON is not an object Partial JSON file format error Submit an object as shown in the example.
404 ft.ObjectNotExists The target UUID does not belong to the current workspace, does not exist, or has been deleted The specified object does not exist Obtain a valid UUID from the current workspace list; disabled rules can still be read.
404 ft.NotFoundRole Any roleUUIDs member is not in the set of available, non-deleted roles in the current workspace The specified role was not found or has been deleted Obtain the UUID again from the role list; do not use names, roles from another workspace, or *.
400 ft.ErrorRegularExpression Regular expression pre-check failed on save The regular expression is invalid Change it to a valid expression compatible with standard re, and verify JSON backslash escaping.
500 ft.InternalServerError Storage or response failed; a cache clearing failure after a write commit may also return 500 Internal error For write requests, first read back through the list/details, then decide whether to retry; keep the traceId and contact the administrator.

Feedback

Is this page helpful?