Skip to main content
When PII redaction is enabled, the security proxy scans outbound HTTP and HTTPS request bodies for sensitive data before they reach external APIs. Detected PII is replaced with opaque tokens. If rehydrate_response=True, the tokens in API responses are transparently replaced back with the original values before they reach your agent code.

Basic configuration

PIIConfig model

Detected PII types

person_name requires the optional Guardrails Service. Structured types (SSN, credit card, email, phone) work with the built-in regex scanner.

RedactionAction enum

How redaction works

When the proxy finds a credit card number in an outbound request body:
The token CREDIT_CARD_9f2a3b is stored in the per-sandbox session map. When the API responds and the response body contains that token, it is replaced back with the original value before your code sees it.

Redact all types

Omit types or pass an empty list to scan for all supported PII types.

Block on sensitive PII

Use action="block" for the most sensitive types to prevent any transmission.
Any request containing an SSN or credit card number will be rejected with HTTP 403. The event is written to the audit log.

Log without redacting

Use action="log_only" for audit visibility without modifying traffic.

Domain scoping

Limit PII scanning to specific destination domains using the domains field on PIIConfig (available via the underlying SecurityPolicy JSON). By default, all domains are scanned.

With the Guardrails Service

When the Guardrails Service is deployed and GUARDRAILS_URL is set, PII scanning uses Microsoft Presidio (ML-based NER) instead of the built-in regex engine, for higher accuracy and a few additional entity types:
  • Person names and locations
  • Passport numbers and driver’s license numbers
The fallback to regex detection is automatic if the Guardrails Service is unreachable.

Example: OpenAI call with PII redaction

PII redaction applies to HTTP and HTTPS request bodies only. PII present in URL query parameters or HTTP headers is not scanned by the body inspector. Use TransformationRule patterns to handle header-level PII.