Use CasesProtect PII in GenAI / LLM Prompts

Protect PII in GenAI / LLM Prompts

Auto-detect and mask sensitive data before sending text to an LLM, then optionally restore original values after the model responds.

curl -X PUT https://protecto-trial.protecto.ai/api/vault/mask \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mask": [
      {
        "value": "My name is John Doe and my email is john.doe@example.com"
      }
    ]
  }'
{
  "data": [
    {
      "value": "My name is John Doe and my email is john.doe@example.com",
      "token_value": "My name is <PERSON>VJYe 03W</PERSON> and my email is <EMAIL>0gN3SkjL@0ffM3CDS</EMAIL>"
    }
  ],
  "success": true,
  "error": {
    "message": ""
  }
}
curl -X PUT https://protecto-trial.protecto.ai/api/vault/unmask \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "unmask": [
      {
        "token_value": "My name is <PERSON>VJYe 03W</PERSON> and my email is <EMAIL>0gN3SkjL@0ffM3CDS</EMAIL>"
      }
    ]
  }'
{
  "data": [
    {
      "value": "My name is John Doe and my email is john.doe@example.com",
      "token_value": "My name is <PERSON>VJYe 03W</PERSON> and my email is <EMAIL>0gN3SkjL@0ffM3CDS</EMAIL>"
    }
  ],
  "success": true,
  "error": {
    "message": ""
  }
}

What this solves

When users enter text, it often contains sensitive data like names, emails, or dates. Sending raw text to an LLM exposes private information and creates compliance risks.

This pattern shows you how to:

  • Automatically detect and mask PII before sending text to an LLM
  • Send only masked text outside your system
  • Optionally restore the original text when required

How it works

StepWhat happensAPI
1Detect and mask sensitive dataMask API (Auto-Detect)
2Send masked text to LLMExternal (your LLM provider)
3Restore original text (optional)Unmask API

Auto-detect and mask user input

Send the raw user input to Protecto. The active policy determines which entities are detected and how they are tokenized — no entity types or token names required in the request.

Send the token_value string to the LLM — not the original value. No raw PII leaves your system.

Send masked text to the LLM

Pass the token_value from the previous step as the prompt to your LLM provider. The text still reads naturally, sensitive values are replaced with tokens, and entity tags provide type context if needed.

Protecto is not involved in this step.

Unmask the response (optional)

If your application needs to restore original values from the LLM's response, submit the masked text back to Protecto.

When to use which approach

ScenarioRecommended
LLM promptsAuto-Detect and Mask
Logs and messagesAuto-Detect and Mask
Known sensitive fieldsMask with Token
Structured identifiersMask with Format
Central governancePolicy-based masking

Key takeaways:

  • Auto-detect masking is the fastest way to protect LLM prompts
  • Tokens are wrapped with entity tags that preserve semantic meaning
  • Masked text remains readable and usable by the LLM
  • Unmasking is optional and permission-controlled