Skip to content

Create



POST /api/v1/sensitive_data_scanner/add

Overview

Create a rule.

Prerequisites and Usage Steps

Create a rule. The current request allows only one item for each of dataTypes and rules. The initial status is enabled (status=0). The data scope is the Workspace to which the API Key belongs.

Request Headers

Parameter Type Required Description
DF-API-KEY string Y Access key.
Example: <DF-API-KEY>
How to obtain or specify: Obtain the key required by this API from API Key management in the target Workspace.

Body Request Parameters

Parameter Type Required Description
dataTypes array Y Data type to scan, a single-element string array. Valid values: logging, object, custom_object, keyevent, tracing, rum, dialtest, network, profiling, billing, llm, agent_monitor. Use keyevent for events.
Allows null: False
Minimum length: 1
Maximum length: 1
Example: ['logging']
How to obtain or specify: Select the data type to scan. The array must contain only one valid value.
dataTypes[*] string Valid values: ['logging', 'object', 'custom_object', 'keyevent', 'tracing', 'rum', 'dialtest', 'network', 'profiling', 'billing', 'llm', 'agent_monitor']
Example: logging
How to obtain or specify: Select one value from the valid values that matches the data to scan.
filters array Array of filter rows. Omit it or set it to [] for no filtering. Each row consists of name (letters, digits, underscores, or hyphens), operation (in or not_in), value (a non-empty string array; individual items cannot contain commas), and condition (and or or; default and). The condition must be the same for all rows, including the first row.
Allows null: False
Example: [{'name': 'service', 'operation': 'in', 'value': ['payment', 'checkout'], 'condition': 'or'}, {'name': 'env', 'operation': 'not_in', 'value': ['test'], 'condition': 'or'}]
How to obtain or specify: Construct filter conditions from actual fields and values in the target data.
filters[*] json Example: {"name":"service","operation":"in","value":["payment"],"condition":"and"}
How to obtain or specify: One row corresponds to one field and its matching condition.
filters[*].name string Conditionally required Filter field name. Only letters, digits, underscores, and hyphens are allowed.
Example: service
How to obtain or specify: Obtain an actual field name that exists in the target data.
filters[*].operation string Conditionally required in matches any specified value; not_in excludes specified values.
Valid values: ['in', 'not_in']
Example: in
How to obtain or specify: Choose in for matching or not_in for exclusion as needed.
filters[*].value array Conditionally required Non-empty string array. Individual items cannot contain commas.
Minimum length: 1
Example: ["payment"]
How to obtain or specify: Select values to match or exclude from the actual values of the corresponding field.
filters[*].value[*] string Example: payment
How to obtain or specify: Enter an actual field value. Individual items must not contain commas.
filters[*].condition string Relationship for the entire group. Must be the same for all rows; defaults to and when omitted.
Valid values: ['and', 'or']
Example: and
How to obtain or specify: Select and or or for the entire group filter relationship. Keep it consistent across all rows.
maskFieldCfg json Y Masked fields. Applies only to scannable string fields.
Allows null: False
Example: {"type":"include","fields":["message"]}
How to obtain or specify: Select the configuration based on the scope of fields in the target data that need masking.
maskFieldCfg.type string Y all=all fields, include=specified fields, exclude=excluded fields.
Allows null: False
Valid values: ['all', 'include', 'exclude']
Example: include
How to obtain or specify: Choose the corresponding enum based on whether to process all fields, specified fields, or excluded fields.
maskFieldCfg.fields array For include and exclude, a non-empty array of field names is required; omit for all. After joining with commas, the maximum length is 256.
Allows null: False
Example: ['message']
How to obtain or specify: When specifying or excluding fields, enter actual string field names from the target data.
maskFieldCfg.fields[*] string Example: message
How to obtain or specify: Enter a string field name to include or exclude.
maskTypeCfg json Y Processing method after a regex match. When switching processing methods, submit the complete configuration for the new branch.
Allows null: False
Example: {"type":"replace","replaceText":"[已脱敏]"}
How to obtain or specify: Select a branch based on the processing goal after a regex match, and fill in the required fields for that branch.
maskTypeCfg.type string Y universal=universal encryption, part=partial encryption, replace=replacement encryption, md5=MD5 digest. For universal and md5, pass only type.
Allows null: False
Valid values: ['universal', 'part', 'replace', 'md5']
Example: replace
How to obtain or specify: Select universal, partial, replacement, or MD5 as needed.
maskTypeCfg.partMaskCfg json Required only for part. Includes direction and number of masked characters.
Allows null: False
Example: {"type":"front","count":3}
How to obtain or specify: When selecting partial masking, enter the masking direction and number of characters.
maskTypeCfg.partMaskCfg.type string Conditionally required front=mask the first few characters of the matched segment; behind=mask the last few characters. For example, 123456789 with front/3 gives *456789.
Allows null: False
Valid values: ['front', 'behind']
Example: front
How to obtain or specify: Select front or behind based on the direction to mask.
maskTypeCfg.partMaskCfg.count integer Conditionally required Number of masked characters, an integer from 1 to 10.
Allows null: False
$minValue: 1
$maxValue: 10
Example: 3
How to obtain or specify: Enter the number of characters to mask, from 1 to 10.
maskTypeCfg.replaceText string Required only for replace. Maximum length 256. Leading and trailing whitespace is removed. An empty string can be explicitly passed.
Allows null: False
Allows empty string: True
Maximum length: 256
Example: [已脱敏]
How to obtain or specify: When selecting replacement, enter the text that the matched segment is replaced with.
rules array Y Single-element array of custom rules. rules[0].name is required, non-empty, and has a maximum length of 100. regularExpression is required, non-empty, and has a maximum length of 1024; validated according to Go. tags is optional and defaults to []; it is an array of key:value strings; after joining with commas, the maximum length is 256.
Allows null: False
Minimum length: 1
Maximum length: 1
Example: [{'name': 'payment-email', 'regularExpression': '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}', 'tags': ['masked:email']}]
How to obtain or specify: Enter a rule to actually scan, or obtain the regular expression from the built-in rule library.
rules[*] json Example: {"name":"payment-email","regularExpression":"[0-9]{6}"}
How to obtain or specify: Enter a rule name, Go regular expression, and optional tags.
rules[*].name string Y Rule name. Required, non-empty, maximum length 100.
Maximum length: 100
Example: payment-email
How to obtain or specify: Choose an easily identifiable name for the rule.
rules[*].regularExpression string Y Go regular expression. Required, non-empty, maximum length 1024.
Maximum length: 1024
Example: [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}
How to obtain or specify: Enter a Go regular expression that matches the target text, or obtain content[].children[].pattern from the built-in rule library.
rules[*].tags array Array of strings in key:value format. Omit or use [] to indicate no tags.
Example: ["team:payment"]
How to obtain or specify: Enter a key:value tag array based on actual business classification.
rules[*].tags[*] string Example: team:payment
How to obtain or specify: Enter one key:value tag.

Additional Parameter Notes

Adds a custom rule and returns the generated UUID. After being saved, it takes effect through the existing scanning pipeline.

Request Example

curl 'https://openapi.guance.com/api/v1/sensitive_data_scanner/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"dataTypes":["logging"],"filters":[{"name":"service","operation":"in","value":["payment","checkout"],"condition":"or"},{"name":"env","operation":"not_in","value":["test"],"condition":"or"}],"maskFieldCfg":{"type":"include","fields":["message"]},"maskTypeCfg":{"type":"part","partMaskCfg":{"type":"front","count":3}},"rules":[{"name":"payment-email","regularExpression":"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}","tags":["masked:email"]}]}'

Response

HTTP 200, application/json.

Field Type Description
content.data[].uuid string Rule UUID, used to query, modify, enable or disable, or delete.
content.data[].workspaceUUID string UUID of the Workspace to which the rule belongs.
content.data[].name string Rule name.
content.data[].dataTypes array<string> Data types to which the rule applies.
content.data[].filters array<object> Configured filter conditions.
content.data[].conditions string Filter expression derived by the server.
content.data[].regularExpression string Rule regular expression.
content.data[].maskFieldCfg object Scan field configuration.
content.data[].maskTypeCfg object Masking configuration.
content.data[].tags array<string> Rule tags.
content.data[].status integer 0 enabled, 2 disabled.
content.data[].createAt integer Creation time, in Unix seconds.
content.data[].updateAt integer Update time, in Unix seconds; may be -1 if not updated.
content.data[].deleteAt integer Deletion time; -1 for active records.
content.data[].id integer or null Database row ID. Use uuid for integration.
content.data[].creator string Creator identifier.
content.data[].updator string Last updater identifier.
content.ruleUUIDs array<string> UUID of the created rule.
{
    "code": 200,
    "content": {
        "data": [
            {
                "uuid": "sdsr_32cc36108f2c4194a70fc12554583f20",
                "dataTypes": [
                    "logging"
                ],
                "filters": [
                    {
                        "name": "service",
                        "operation": "in",
                        "value": [
                            "payment",
                            "checkout"
                        ],
                        "condition": "or"
                    },
                    {
                        "name": "env",
                        "operation": "not_in",
                        "value": [
                            "test"
                        ],
                        "condition": "or"
                    }
                ],
                "maskFieldCfg": {
                    "type": "include",
                    "fields": [
                        "message"
                    ]
                },
                "maskTypeCfg": {
                    "type": "part",
                    "partMaskCfg": {
                        "type": "front",
                        "count": 3
                    }
                },
                "name": "payment-email",
                "regularExpression": "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}",
                "tags": [
                    "masked:email"
                ],
                "status": 0,
                "creator": "acnt_example",
                "updator": "",
                "createAt": 1795140000,
                "updateAt": -1
            }
        ],
        "ruleUUIDs": [
            "sdsr_32cc36108f2c4194a70fc12554583f20"
        ]
    },
    "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 Resolution
400 ft.ErrorRegularExpression The Go engine rejects the regular expression in the rule Invalid regular expression Correct it using Go regular expression syntax. You can first verify it with Regular Expression Test.
400 ft.JsonFormatError The top level of the request body is not a JSON object JSON format error Submit a JSON object as the request body.
400 ft.RequestJsonFormatError JSON syntax error Request JSON format error Correct the JSON syntax.
403 ft.Forbidden Insufficient API permissions, or the current Workspace version is not supported Forbidden Confirm the Workspace to which the Key belongs, its permissions, and the Workspace version.
406 ft.ParameterValidationFailed / ft.InvalidParameter Missing fields or field values violate validation conditions Invalid parameters Check the JSON fields, types, and value ranges.

Feedback

Is this page helpful?