Mask Text
Detect and mask sensitive entities in free-form text synchronously using policy-driven tokenization and adjustable detection effort.
Endpoint
Send a request to the following endpoint to mask personal and sensitive data in short texts and return the results in the same response:
| Method | Route | Headers |
|---|---|---|
| PUT | {baseurl}/vault/mask | Authorization: Bearer YOUR_AUTH_TOKEN |
The API key needs the mask permission.
For longer texts, use Mask Text (Async) with PUT {baseurl}/vault/mask/async.
Request body
Each request masks one or more text items using one policy. Place policy_name, effort, and identify_excluded_entities at the top level of the request, next to mask, not inside its items.
| Field | Type | Required | Description |
|---|---|---|---|
mask | array | Yes | Text items to mask. The array must not be empty. Results keep the same order. |
mask[].value | string | Yes | Text to mask. |
policy_name | string | No | Name of the policy to apply from your namespace. If omitted, the default namespace policy applies. An unknown name is rejected without falling back to the default. |
effort | string (medium, high) | No | How thoroughly to detect sensitive data. Defaults to medium and applies to every item. |
identify_excluded_entities | boolean | No | Whether to report entities excluded by the policy in excluded_entities. Defaults to true and applies to every item. |
Example request
{
"mask": [
{"value": "Arjun is my name here from DataLoop. Our official site is www.dataloop.ai and my email is arjun@gmail.com"}
],
"policy_name": "customer_mask_policy",
"effort": "medium",
"identify_excluded_entities": true
}
Response
A successful call returns HTTP 200 with one result per item in data, in the same order as the request.
| Field | Type | Description |
|---|---|---|
data | array | Results for the text items. |
data[].value | string | The original text. |
data[].token_value | string | The input text with each masked entity replaced by its token between a prefix and suffix, such as <PER>MaExJ</PER>. |
data[].individual_tokens | array | One entry per masked entity. Positions are zero-based offsets in value; end_pos is exclusive. |
data[].individual_tokens[].value | string | The original entity value. |
data[].individual_tokens[].pii_type | string | The entity type. |
data[].individual_tokens[].token | string | The token replacing the entity. |
data[].individual_tokens[].prefix | string | The prefix before the token. |
data[].individual_tokens[].suffix | string | The suffix after the token. |
data[].individual_tokens[].start_pos | integer | The start offset in the original text. |
data[].individual_tokens[].end_pos | integer | The exclusive end offset in the original text. |
data[].toxicity_analysis | object | Scores from 0 to 1 for toxicity, severe_toxicity, obscene, threat, insult, and identity_attack. |
data[].excluded_entities | array | Entities found in the text that the policy excludes. These entities are never masked. The field is present only when excluded entities are found and identify_excluded_entities is true. |
data[].excluded_entities[].value | string | The excluded entity value. |
data[].excluded_entities[].pii_type | string | The entity type. |
data[].excluded_entities[].start_pos | integer | The start offset in the original text. |
data[].excluded_entities[].end_pos | integer | The exclusive end offset in the original text. |
Example response
In this example, the policy excludes URLs, so www.dataloop.ai remains unmasked and appears in excluded_entities.
{
"data": [
{
"value": "Arjun is my name here from DataLoop. Our official site is www.dataloop.ai and my email is arjun@gmail.com",
"token_value": "<PER>MaExJ</PER> is my name here from <ORG>R7Lazrxv</ORG>. Our official site is www.dataloop.ai and my email is <EMAIL>7PHWW@dnZ3r</EMAIL>",
"toxicity_analysis": {"toxicity": 0.0008, "severe_toxicity": 0.0001, "obscene": 0.0002, "threat": 0.0001, "insult": 0.0002, "identity_attack": 0.0001},
"individual_tokens": [
{"value": "Arjun", "pii_type": "PERSON", "token": "MaExJ", "prefix": "<PER>", "suffix": "</PER>", "start_pos": 0, "end_pos": 5},
{"value": "DataLoop", "pii_type": "ORG", "token": "R7Lazrxv", "prefix": "<ORG>", "suffix": "</ORG>", "start_pos": 27, "end_pos": 35},
{"value": "arjun@gmail.com", "pii_type": "EMAIL_ADDRESS", "token": "7PHWW@dnZ3r", "prefix": "<EMAIL>", "suffix": "</EMAIL>", "start_pos": 90, "end_pos": 105}
],
"excluded_entities": [
{"value": "www.dataloop.ai", "pii_type": "URL", "start_pos": 58, "end_pos": 73}
]
}
],
"success": true,
"error": {"message": ""}
}
With identify_excluded_entities set to false, the response is the same except that excluded_entities is omitted. The URL remains unmasked.
Masking behavior
The active policy controls entity detection, tokenization, and entity tags. The tokenized output depends on that policy.
Entities excluded by the policy are never masked, regardless of whether they are reported in the response.
Errors
Invalid requests are rejected immediately with HTTP 500. The error.message field gives the reason.
{"data": {}, "success": false, "error": {"message": "<reason>"}}
A request is rejected when:
maskis empty, or an item has novalue.- An item contains
file_content. effortis notmediumorhigh.identify_excluded_entitiesis nottrueorfalse.policy_namedoes not exist in your namespace, or no policy name is given and the namespace has no default policy.- The API key is invalid or lacks the mask permission.
If sensitive-data detection fails, the call also returns an error and nothing is masked.