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:

MethodRouteHeaders
PUT{baseurl}/vault/maskAuthorization: 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.

FieldTypeRequiredDescription
maskarrayYesText items to mask. The array must not be empty. Results keep the same order.
mask[].valuestringYesText to mask.
policy_namestringNoName 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.
effortstring (medium, high)NoHow thoroughly to detect sensitive data. Defaults to medium and applies to every item.
identify_excluded_entitiesbooleanNoWhether 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.

FieldTypeDescription
dataarrayResults for the text items.
data[].valuestringThe original text.
data[].token_valuestringThe input text with each masked entity replaced by its token between a prefix and suffix, such as <PER>MaExJ</PER>.
data[].individual_tokensarrayOne entry per masked entity. Positions are zero-based offsets in value; end_pos is exclusive.
data[].individual_tokens[].valuestringThe original entity value.
data[].individual_tokens[].pii_typestringThe entity type.
data[].individual_tokens[].tokenstringThe token replacing the entity.
data[].individual_tokens[].prefixstringThe prefix before the token.
data[].individual_tokens[].suffixstringThe suffix after the token.
data[].individual_tokens[].start_posintegerThe start offset in the original text.
data[].individual_tokens[].end_posintegerThe exclusive end offset in the original text.
data[].toxicity_analysisobjectScores from 0 to 1 for toxicity, severe_toxicity, obscene, threat, insult, and identity_attack.
data[].excluded_entitiesarrayEntities 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[].valuestringThe excluded entity value.
data[].excluded_entities[].pii_typestringThe entity type.
data[].excluded_entities[].start_posintegerThe start offset in the original text.
data[].excluded_entities[].end_posintegerThe 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:

  • mask is empty, or an item has no value.
  • An item contains file_content.
  • effort is not medium or high.
  • identify_excluded_entities is not true or false.
  • policy_name does 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.