What You’ll Learn
- Creating a sandbox with
rehydrate_response=True(transparent mode) - Creating a sandbox with
rehydrate_response=False(strict mode) - The five-step flow: send, redact, process, restore, receive
- When to use each mode
How Rehydration Works
Whenrehydrate_response=True, the MITM proxy maintains a per-request token mapping:
- Send — Code in the sandbox sends an HTTP request containing PII (e.g.,
john@example.com) - Redact — Proxy replaces PII with a token:
[REDACTED_EMAIL_1]and stores the mapping - Process — The external API receives the sanitized request and responds (possibly echoing the token)
- Restore — Proxy scans the response, finds
[REDACTED_EMAIL_1], and restoresjohn@example.com - Receive — Sandbox code receives the response with the original PII value — completely transparent
rehydrate_response=False, step 4 is skipped and redaction tokens remain in the response.
PII scanning via the guardrails service is rolling out. This example demonstrates the SDK API for configuring PII rehydration — the policy is accepted and stored today.
Prerequisites
This example is available in Python. TypeScript version coming soon.
Code Walkthrough
Rehydration enabled — sandbox code sees the original PII in responses:Choosing a Mode
| Mode | rehydrate_response | Use When |
|---|---|---|
| Transparent | True | Application must work as if PII was never redacted; best for most LLM workflows |
| Strict | False | Sandbox code must never see original PII in responses; maximum privacy isolation |