Mask text
Detects personal data in the given text and masks it according to the
selected transform. The default transform is placeholder (a reversible
placeholder).
POST
/maskRequest body
requiredapplication/jsontextstringrequiredThe raw text to mask.
transformstring`placeholder` (reversible `<CATEGORY_N>`),
`mask` (length-preserving `####`, irreversible).
default: "placeholder"
Allowed:
placeholdermaskmask_charstringFill character for transform=mask.
default: "#"
return_vaultbooleanReturns the placeholder to original value mapping (sensitive! off by
default, never logged).
default: false
categoriesobjectCategory filtering: `{preset, enable:[...], disable:[...]}`.
preset values: ALL, IDENTITY, IDENTIFIERS, KVKK, KVKK_SENSITIVE.
(KVKK = full scope; KVKK_SENSITIVE = only the Article 6 special
categories.)
allow_patternsstring[]A list of regular expressions (Python `re` syntax) that exempt matches
from masking (an allowlist). If the surface text of a detected field
matches one of the patterns, that field is NOT masked. Use it when a
public value such as an organization name is mistakenly taken for
personal data. An invalid pattern returns 422.
**Limits:** at most 25 patterns, at most 200 characters per pattern.
There is a time budget for scanning. If an exemption pattern exceeds
the budget it is NOT applied and the request completes normally: a
rule that reduces masking should not take effect under uncertainty.
block_patternsstring | object[]A list of regular expressions; every matching piece of text is
FORCE-masked even if the model did not detect it. Use it to guarantee
identifiers specific to you, such as an internal registry or file
number. A plain string gets the category `custom`; a `{pattern,
category}` object assigns the category. A match that overlaps an
existing detection is skipped (the detection wins). An invalid pattern
returns 422.
**Limits:** at most 25 patterns, at most 200 characters per pattern.
There is a time budget for scanning; if the budget is exceeded the
request returns 422. We prefer rejecting the request over silently
masking less than we should.
**Organization patterns:** the patterns defined for your organization
in the panel are ADDED to the ones in this request and cannot be
dropped by the request body. The result can only increase masking.
Show propertiesHide properties
Array of
string | objectOne of:
string
stringobject
patternstringrequiredRegular expression (Python `re` syntax).
categorystringCategory to assign to the forced field (default `custom`).
Responses
200Masking result
masked_textstringThe masked text.
transformstringspansSpan[]Show propertiesHide properties
Array of
Spancategorystringstartintegerendintegerscorenumbertimings_msobjectTotal processing time (ms): only { total }.
vaultobjectIf return_vault=true, the placeholder to original mapping (sensitive).
401Missing or invalid virtual key
detailstring413Text exceeded the maximum length (split it or use /mask/batch)
422Invalid request body
detailValidationError[]Show propertiesHide properties
Array of
ValidationErrorlocstring | integer[]Show propertiesHide properties
Array of
string | integerAny of:
string
stringinteger
integermsgstringtypestringRequest
import requests
response = requests.post(
"https://gw-tr.gurubase.io/mask",
headers={
"Content-Type": "application/json"
},
json={
"text": "Ahmet Yılmaz, TC 10000000214.",
"transform": "placeholder",
"mask_char": "#",
"return_vault": False,
"categories": {},
"allow_patterns": [
"\\bDemo Kurum\\b"
],
"block_patterns": [
"\\bPRJ-\\d{4}\\b",
{
"pattern": "\\bSICIL-\\d{6}\\b",
"category": "custom"
}
]
},
)curl -X POST "https://gw-tr.gurubase.io/mask" \
-H "Content-Type: application/json" \
-d '{
"text": "Ahmet Yılmaz, TC 10000000214.",
"transform": "placeholder",
"mask_char": "#",
"return_vault": false,
"categories": {},
"allow_patterns": [
"\\bDemo Kurum\\b"
],
"block_patterns": [
"\\bPRJ-\\d{4}\\b",
{
"pattern": "\\bSICIL-\\d{6}\\b",
"category": "custom"
}
]
}'const response = await fetch("https://gw-tr.gurubase.io/mask", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "Ahmet Yılmaz, TC 10000000214.",
"transform": "placeholder",
"mask_char": "#",
"return_vault": false,
"categories": {},
"allow_patterns": [
"\\bDemo Kurum\\b"
],
"block_patterns": [
"\\bPRJ-\\d{4}\\b",
{
"pattern": "\\bSICIL-\\d{6}\\b",
"category": "custom"
}
]
})
});Response
{
"masked_text": "string",
"transform": "string",
"spans": [
{
"category": "person",
"start": 0,
"end": 0,
"score": 0.85
}
],
"timings_ms": {},
"vault": {}
}{
"detail": "string"
}Text exceeded the maximum length (split it or use /mask/batch)
{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}