Skip to content

Mask / unmask API

Mask and restore text in your own systems.

Your region's gateway address: resolving…

Masking

POST /aitech/v1/mask takes an array of texts and returns the masked texts, the entities found and the decision. All texts of one call share the placeholder numbering. If the policy blocks the request, the response is 403 policy_blocked.

curl https://<gateway>/aitech/v1/mask \
  -H "Authorization: Bearer $AITECH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"texts": ["Договор с ООО «Технологии», ИНН 7701234560"], "return": "token"}'
{
  "texts": ["Договор с [КОМПАНИЯ_1], ИНН [ИНН_1]"],
  "entities": [
    {"text_index": 0, "key": "ORG", "category": "ORG", "placeholder": "[КОМПАНИЯ_1]", "action": "pseudonymize",
     "start": 10, "end": 26, "masked_start": 10, "masked_end": 22, "confidence": 0.93},
    {"text_index": 0, "key": "INN", "category": "INN", "placeholder": "[ИНН_1]", "action": "pseudonymize",
     "start": 32, "end": 42, "masked_start": 28, "masked_end": 35, "confidence": 1}
  ],
  "decision": "masked",
  "warn_reasons": [],
  "instructions": null,
  "restore_token": "rt1.r1.…"
}

Restore token

By default (return: "token") the response contains an encrypted restore_token — we do not store it; it is valid for 24 hours and bound to your key (or to the whole organization with share_scope: "org"). For long-lived indexes (RAG), request return: "mapping" and keep the mapping yourself: it contains the original values.

Restoring

POST /aitech/v1/unmask takes texts and exactly one of restore_token or mapping. For JSON payloads use context: "json" so values are escaped correctly.

curl https://<gateway>/aitech/v1/unmask \
  -H "Authorization: Bearer $AITECH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"texts": ["Ответ для [КОМПАНИЯ_1]"], "restore_token": "rt1.r1.…"}'

Continuing a conversation

To keep placeholder numbers stable across calls, pass continue: {restore_token} or continue: {mapping}: known values keep their placeholders, new ones get the next numbers.

Offsets

start/end point into the original text, masked_start/masked_end into the masked text. They are Unicode code points by default; in JavaScript request offset_unit: "utf16".