DLP
Redact PII
Detects PII and secrets using your policy, replaces each match with a token, and stores the originals in a time-limited vault. Returns the redacted messages plus a vault_id you pass to /v1/pii/unredact to restore them.
/v1/pii/redactPIIConfig
| Field | Type | Default | Description |
|---|---|---|---|
vault_ttl | integer | 3600 | Seconds the originals remain restorable. Tokens can't be restored after this. |
hash_seed | string | — | Makes tokens deterministic: the same value + label + seed always yields the same token (consistent pseudonyms across calls). Without it, every occurrence gets a fresh random token. |
threshold | number | policy | Overrides the policy's PII sensitivity for this call: 0.9 L1 Lenient, 0.8 L2 Default, 0.7 L3 Broad, 0.6 L4 Strict. |
Tokens
Every token has the form [<LABEL>_<8 hex chars>], e.g. [GOVERNMENT_ID_3F9A1B2C]. The label is the detector group that matched. Where two matches overlap, the longest wins.
| Label | Covers |
|---|---|
PERSON_NAME | Person names, date of birth. |
CONTACT | Email addresses, phone numbers. |
ADDRESS | Street, city, state, postal code / CEP, country. |
GOVERNMENT_ID | CPF, CNPJ, RG, SSN, passport, driver license, tax IDs. CPF and CNPJ are checksum-validated, with or without punctuation. |
PAYMENT | Card numbers, expiry, CVV, bank / account / routing numbers, IBAN. |
DIGITAL_ID | Usernames, IP addresses, account IDs, UUIDs, keys, crypto addresses. |
PASSWORD | Passwords, secrets, API keys, access tokens, recovery codes. |
DATE | Sensitive, document, expiration and transaction dates. |
COMPANY | Company and organization names. |
SECRET_<TYPE> | Credentials matched by pattern when the policy enables Password/Credentials checks, e.g. SECRET_AWS_ACCESS_KEY, SECRET_GITHUB_TOKEN, SECRET_JWT. |
Only the groups enabled in the policy's detector are redacted; a policy without a PII detector redacts all groups at the default sensitivity. See PII & DLP model for detection details.
Errors
| Status | When |
|---|---|
401 | Missing or invalid API key. |
404 | Policy '<slug>' not found in the key's account. |
422 | Invalid body (e.g. policy or messages missing). |
429 | Rate limit exceeded. |
500 | Internal error during redaction. |
If detection is temporarily unavailable, the call still succeeds and returns redacted: false for model-based entities. If you must never forward unredacted content, add your own fail-closed check on critical paths. To integrate this into an MCP gateway, see DLP in your own MCP gateway.
Headers
AuthorizationstringrequiredBearer <GUARDION_API_KEY>.
Content-Typestringrequiredapplication/json.
Body Parameters
policystringrequiredPolicy slug. Its PII / Data-Protection detector decides which entity groups are redacted and at what sensitivity. Also scopes the vault — use the same policy on /unredact.
messagesMessage[]requiredMessages to scan ({ role, content }). content may be a string or an array of parts; OpenAI tool_calls and Anthropic tool_use / tool_result blocks are scanned too. Structure is preserved.
vault_idstringReuse an existing vault and append new tokens to it (e.g. your session id). Omit to create a new vault.
configPIIConfigOptional redaction settings — see PIIConfig below.
Response
messagesMessage[]The input messages with sensitive values replaced by tokens.
vault_idstring | nullVault holding the originals. Pass it to /v1/pii/unredact. null when nothing was redacted.
redactedbooleantrue if at least one value was replaced.
entities_foundintegerNumber of values replaced.
spansSpan[]One entry per replacement: { index, start, end, label, token }. index is the message index; start/end are character offsets into the original text.
curl https://api.guardion.ai/v1/pii/redact \
-H "Authorization: Bearer $GUARDION_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"policy": "data-protection",
"vault_id": "sess_42",
"config": { "vault_ttl": 1800 },
"messages": [
{ "role": "user", "content": "Meu CPF é 419.815.118-06 e meu email maria@example.com" }
]
}'
{
"messages": [
{
"role": "user",
"content": "Meu CPF é [GOVERNMENT_ID_3F9A1B2C] e meu email [CONTACT_77E0C1D2]",
"tool_calls": null,
"tool_call_id": null
}
],
"vault_id": "sess_42",
"redacted": true,
"entities_found": 2,
"spans": [
{ "index": 0, "start": 10, "end": 24, "label": "GOVERNMENT_ID", "token": "[GOVERNMENT_ID_3F9A1B2C]" },
{ "index": 0, "start": 37, "end": 54, "label": "CONTACT", "token": "[CONTACT_77E0C1D2]" }
]
}