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.

POST/v1/pii/redact

PIIConfig

FieldTypeDefaultDescription
vault_ttlinteger3600Seconds the originals remain restorable. Tokens can't be restored after this.
hash_seedstring—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.
thresholdnumberpolicyOverrides 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.

LabelCovers
PERSON_NAMEPerson names, date of birth.
CONTACTEmail addresses, phone numbers.
ADDRESSStreet, city, state, postal code / CEP, country.
GOVERNMENT_IDCPF, CNPJ, RG, SSN, passport, driver license, tax IDs. CPF and CNPJ are checksum-validated, with or without punctuation.
PAYMENTCard numbers, expiry, CVV, bank / account / routing numbers, IBAN.
DIGITAL_IDUsernames, IP addresses, account IDs, UUIDs, keys, crypto addresses.
PASSWORDPasswords, secrets, API keys, access tokens, recovery codes.
DATESensitive, document, expiration and transaction dates.
COMPANYCompany 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

StatusWhen
401Missing or invalid API key.
404Policy '<slug>' not found in the key's account.
422Invalid body (e.g. policy or messages missing).
429Rate limit exceeded.
500Internal 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

Authorizationstringrequired

Bearer <GUARDION_API_KEY>.

Content-Typestringrequired

application/json.

Body Parameters

policystringrequired

Policy 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[]required

Messages 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_idstring

Reuse an existing vault and append new tokens to it (e.g. your session id). Omit to create a new vault.

configPIIConfig

Optional redaction settings — see PIIConfig below.

Response

messagesMessage[]

The input messages with sensitive values replaced by tokens.

vault_idstring | null

Vault holding the originals. Pass it to /v1/pii/unredact. null when nothing was redacted.

redactedboolean

true if at least one value was replaced.

entities_foundinteger

Number 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" }
    ]
  }'
Response
{
  "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]" }
  ]
}