Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.
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.
When the proxy finds a credit card number in an outbound request body:
Before: "Please charge 4111111111111111 for $50"After: "Please charge [CREDIT_CARD_9f2a3b] for $50"
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.
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.
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.
from declaw import Sandbox, SecurityPolicy, PIIConfigpolicy = SecurityPolicy( pii=PIIConfig( enabled=True, types=["ssn", "credit_card", "email"], action="redact", rehydrate_response=True, ), network={"allow_out": ["*.openai.com"], "deny_out": ["0.0.0.0/0"]},)sbx = Sandbox.create(security=policy)# This script sends user data to OpenAI — PII is redacted before it leaves the sandboxsbx.files.write("/workspace/call_api.py", b"""import openaiclient = openai.OpenAI()response = client.chat.completions.create( model="gpt-4o-mini", messages=[{ "role": "user", "content": "Summarize this customer record: John Smith, SSN 123-45-6789, email john@example.com" }])print(response.choices[0].message.content)""")result = sbx.commands.run("python3 /workspace/call_api.py")# OpenAI received "[PERSON_NAME_x1] [SSN_y2] [EMAIL_z3]"# Response was rehydrated before reaching the agentprint(result.stdout)
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.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Declaw","description":"Declaw is a security-first sandbox platform for AI agents. Run untrusted code in sandbox microVMs with PII redaction, prompt injection defense, and network policy enforcement.","colors":{"primary":"#0D9373","light":"#07C983","dark":"#0D9373"},"logo":{"light":"https://mintcdn.com/declaw/YB_0u8lW6K_x_PnD/logo/light.svg?fit=max\u0026auto=format\u0026n=YB_0u8lW6K_x_PnD\u0026q=85\u0026s=3a1b3b5d14a7c974db1eda0b8d012499","dark":"https://mintcdn.com/declaw/YB_0u8lW6K_x_PnD/logo/dark.svg?fit=max\u0026auto=format\u0026n=YB_0u8lW6K_x_PnD\u0026q=85\u0026s=564cdf5bfb8abed1949842b56312a3ba"},"favicon":"https://mintcdn.com/declaw/8XHgD2oahu7LIUrQ/favicon.svg?fit=max\u0026auto=format\u0026n=8XHgD2oahu7LIUrQ\u0026q=85\u0026s=c8814a2fdcc2cf40add79906afcd7b5b","api":{"openapi":"openapi.yaml","mdx":{"auth":{"method":"key","name":"X-API-Key"},"server":"https://api.declaw.ai"}},"appearance":{"default":"dark"},"navbar":{"links":[{"href":"https://docs.declaw.ai/mcp","label":"MCP"}],"primary":{"type":"button","label":"Get API Key","href":"https://declaw.ai"}},"footer":{"socials":{"x":"https://x.com/declaw_ai"}},"seo":{"indexing":"navigable"},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"Community","icon":"discord","href":"https://discord.gg/bjA5Zs9ZPw"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"declaw","hasAudioNarration":false,"actualSubdomain":"declaw","customDomains":["docs.declaw.ai"],"gitSource":{"type":"github","owner":"declaw-ai","repo":"declaw-cloud","deployBranch":"main","contentDirectory":"declaw/client_docs","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ad8419f3fe31fb23d51dad1","collectionId":"dfe2e9f0-4a4f-4b22-8ebd-61b3d1c12780","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ad8419f3fe31fb23d51dad1"},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ad8419f3fe31fb23d51dad1","clientVersion":"0.0.3971","searchFilterCounts":[{"language":"default","tag":"Cookbook","count":89},{"language":"default","tag":"API Reference","count":52},{"language":"default","tag":"Documentation","count":45},{"language":"default","tag":"SDKs","count":32},{"language":"default","tag":"Volumes API","count":21},{"language":"default","tag":"Sandbox API","count":14},{"language":"default","tag":"OpenAI Agents","count":14},{"language":"default","tag":"Security","count":13},{"language":"default","tag":"Python SDK","count":12},{"language":"default","tag":"Filesystem API","count":11}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-v7-file-tree","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-nav-generations","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"isAtlas":false,"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"security/pii-redaction","slug":"/security/pii-redaction","pageMetadata":{"title":"PII Redaction","sidebarTitle":"PII Redaction","description":"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.","href":"/security/pii-redaction"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Mermaid,Note,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Mermaid)_missingMdxReference(`Mermaid`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`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 `,_jsx(_components.code,{children:`rehydrate_response=True`}),`, the tokens in API responses are transparently replaced back with the original values before they reach your agent code.`]}),`\n`,_jsx(Heading,{level:`2`,id:`basic-configuration`,children:`Basic configuration`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` declaw `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Sandbox, SecurityPolicy, PIIConfig`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`sbx `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Sandbox.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` security`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`SecurityPolicy(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` pii`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`PIIConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` enabled`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` types`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ssn\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"credit_card\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"email\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"phone\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` action`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"redact\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` rehydrate_response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`piiconfig-model`,children:`PIIConfig model`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`enabled`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`bool`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`False`})}),_jsx(_components.td,{children:`Activate PII scanning`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`types`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`list[PIIType]`})}),_jsx(_components.td,{children:`all types`}),_jsx(_components.td,{children:`Which PII categories to detect`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`action`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`RedactionAction`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`\"redact\"`})}),_jsx(_components.td,{children:`What to do when PII is found`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`rehydrate_response`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`bool`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`True`})}),_jsx(_components.td,{children:`Replace redaction tokens in responses with originals`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`detected-pii-types`,children:`Detected PII types`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Value`}),_jsx(_components.th,{children:`Description`}),_jsx(_components.th,{children:`Example`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`ssn`})}),_jsx(_components.td,{children:`US Social Security Numbers`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`123-45-6789`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`credit_card`})}),_jsx(_components.td,{children:`Credit card numbers (Luhn-validated)`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`4111 1111 1111 1111`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`email`})}),_jsx(_components.td,{children:`Email addresses`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`user@example.com`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`phone`})}),_jsx(_components.td,{children:`Phone numbers (E.164 and local formats)`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`+1-555-867-5309`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`person_name`})}),_jsx(_components.td,{children:`Full person names (NER-based)`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`John Smith`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`ip_address`})}),_jsx(_components.td,{children:`IPv4 and IPv6 addresses`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`192.168.1.1`})})]})]})]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`person_name`}),` requires the optional `,_jsx(_components.a,{href:`/security/guardrails-service`,children:`Guardrails Service`}),`. Structured types (SSN, credit card, email, phone) work with the built-in regex scanner.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`redactionaction-enum`,children:`RedactionAction enum`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Value`}),_jsx(_components.th,{children:`Behavior`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`redact`})}),_jsxs(_components.td,{children:[`Replace PII with a `,_jsx(_components.code,{children:`[PII_TYPE_token]`}),` placeholder. Supports response rehydration.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`block`})}),_jsx(_components.td,{children:`Reject the entire outbound request with HTTP 403. Logged to audit trail.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`log_only`})}),_jsx(_components.td,{children:`Pass the request unchanged but write the detection to the audit log.`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`how-redaction-works`,children:`How redaction works`}),`\n`,_jsx(_components.p,{children:`When the proxy finds a credit card number in an outbound request body:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Before: \"Please charge 4111111111111111 for $50\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`After: \"Please charge [CREDIT_CARD_9f2a3b] for $50\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The token `,_jsx(_components.code,{children:`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.`]}),`\n`,_jsx(Mermaid,{chart:`sequenceDiagram\n participant Agent as Agent Code\n participant Proxy as Security Proxy\n participant API as External API\n\n Agent->>Proxy: POST with \"charge 4111111111111111\"\n Proxy->>Proxy: Detect CC number\n Proxy->>Proxy: Store original in session map\n Proxy->>API: POST with \"charge [CREDIT_CARD_9f2a3b]\"\n API-->>Proxy: Response with \"[CREDIT_CARD_9f2a3b] charged\"\n Proxy->>Proxy: Rehydrate token with original\n Proxy-->>Agent: Response with \"4111111111111111 charged\"`}),`\n`,_jsx(Heading,{level:`2`,id:`redact-all-types`,children:`Redact all types`}),`\n`,_jsxs(_components.p,{children:[`Omit `,_jsx(_components.code,{children:`types`}),` or pass an empty list to scan for all supported PII types.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`pii`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`PIIConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` enabled`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` types`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[], `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# or omit entirely — defaults to all types`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` action`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"redact\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`block-on-sensitive-pii`,children:`Block on sensitive PII`}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`action=\"block\"`}),` for the most sensitive types to prevent any transmission.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`pii`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`PIIConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` enabled`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` types`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ssn\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"credit_card\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` action`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"block\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Any request containing an SSN or credit card number will be rejected with HTTP 403. The event is written to the audit log.`}),`\n`,_jsx(Heading,{level:`2`,id:`log-without-redacting`,children:`Log without redacting`}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`action=\"log_only\"`}),` for audit visibility without modifying traffic.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`pii`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`PIIConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` enabled`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` types`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"email\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` action`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"log_only\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`domain-scoping`,children:`Domain scoping`}),`\n`,_jsxs(_components.p,{children:[`Limit PII scanning to specific destination domains using the `,_jsx(_components.code,{children:`domains`}),` field on `,_jsx(_components.code,{children:`PIIConfig`}),` (available via the underlying `,_jsx(_components.code,{children:`SecurityPolicy`}),` JSON). By default, all domains are scanned.`]}),`\n`,_jsx(Heading,{level:`2`,id:`with-the-guardrails-service`,children:`With the Guardrails Service`}),`\n`,_jsxs(_components.p,{children:[`When the `,_jsx(_components.a,{href:`/security/guardrails-service`,children:`Guardrails Service`}),` is deployed and `,_jsx(_components.code,{children:`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:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Person names and locations`}),`\n`,_jsx(_components.li,{children:`Passport numbers and driver’s license numbers`}),`\n`]}),`\n`,_jsx(_components.p,{children:`The fallback to regex detection is automatic if the Guardrails Service is unreachable.`}),`\n`,_jsx(Heading,{level:`2`,id:`example-openai-call-with-pii-redaction`,children:`Example: OpenAI call with PII redaction`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`31`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`31`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` declaw `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Sandbox, SecurityPolicy, PIIConfig`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`policy `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SecurityPolicy(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` pii`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`PIIConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` enabled`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` types`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ssn\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"credit_card\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"email\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` action`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"redact\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` rehydrate_response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ),`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` network`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"allow_out\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"*.openai.com\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`], `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"deny_out\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"0.0.0.0/0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`sbx `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Sandbox.create(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`security`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`policy)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# This script sends user data to OpenAI — PII is redacted before it leaves the sandbox`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`sbx.files.write(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/workspace/call_api.py\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`b`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`import openai`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`client = openai.OpenAI()`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`response = client.chat.completions.create(`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` model=\"gpt-4o-mini\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` messages=[{`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\": \"user\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\": \"Summarize this customer record: John Smith, SSN 123-45-6789, email john@example.com\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`print(response.choices[0].message.content)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` sbx.commands.run(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"python3 /workspace/call_api.py\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# OpenAI received \"[PERSON_NAME_x1] [SSN_y2] [EMAIL_z3]\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Response was rehydrated before reaching the agent`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(result.stdout)`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`PII redaction applies to HTTP and HTTPS request `,_jsx(_components.strong,{children:`bodies`}),` only. PII present in URL query parameters or HTTP headers is not scanned by the body inspector. Use `,_jsx(_components.code,{children:`TransformationRule`}),` patterns to handle header-level PII.`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"PII Redaction","sidebarTitle":"PII Redaction","description":"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.","href":"/security/pii-redaction"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Basic configuration","slug":"basic-configuration","depth":2,"children":[]},{"title":"PIIConfig model","slug":"piiconfig-model","depth":2,"children":[]},{"title":"Detected PII types","slug":"detected-pii-types","depth":2,"children":[]},{"title":"RedactionAction enum","slug":"redactionaction-enum","depth":2,"children":[]},{"title":"How redaction works","slug":"how-redaction-works","depth":2,"children":[]},{"title":"Redact all types","slug":"redact-all-types","depth":2,"children":[]},{"title":"Block on sensitive PII","slug":"block-on-sensitive-pii","depth":2,"children":[]},{"title":"Log without redacting","slug":"log-without-redacting","depth":2,"children":[]},{"title":"Domain scoping","slug":"domain-scoping","depth":2,"children":[]},{"title":"With the Guardrails Service","slug":"with-the-guardrails-service","depth":2,"children":[]},{"title":"Example: OpenAI call with PII redaction","slug":"example-openai-call-with-pii-redaction","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"declaw","siteName":"Declaw","title":"PII Redaction - Declaw","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-06-27T00:49:10.869Z","originalFileLocation":"security/pii-redaction.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Declaw\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"PII Redaction - Declaw\">\u003cmeta data-mint-head property=\"og:description\" content=\"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Declaw\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.declaw.ai/security/pii-redaction\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://declaw.mintlify.app/_mintlify/api/og/v2?division=Security\u0026amp;title=PII+Redaction\u0026amp;description=Configure+automatic+PII+detection+and+redaction+for+outbound+traffic+from+Declaw+sandboxes.\u0026amp;theme=e908f26a500811980d5ccfa6\u0026amp;signature=739862f0534d1ef72450c83f9511b9cb466cebb2082b9384d44d9ad8978fff6e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"PII Redaction - Declaw\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://declaw.mintlify.app/_mintlify/api/og/v2?division=Security\u0026amp;title=PII+Redaction\u0026amp;description=Configure+automatic+PII+detection+and+redaction+for+outbound+traffic+from+Declaw+sandboxes.\u0026amp;theme=e908f26a500811980d5ccfa6\u0026amp;signature=739862f0534d1ef72450c83f9511b9cb466cebb2082b9384d44d9ad8978fff6e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/declaw/5qZO9alYltiMvEad/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Declaw\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0D9373\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.declaw.ai/security/pii-redaction\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/security/pii-redaction.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.declaw.ai/#organization\",\"name\":\"Declaw\",\"url\":\"https://docs.declaw.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/declaw/YB_0u8lW6K_x_PnD/logo/light.svg?fit=max\u0026auto=format\u0026n=YB_0u8lW6K_x_PnD\u0026q=85\u0026s=3a1b3b5d14a7c974db1eda0b8d012499\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.declaw.ai#website\",\"name\":\"Declaw\",\"url\":\"https://docs.declaw.ai\",\"publisher\":{\"@id\":\"https://docs.declaw.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.declaw.ai/security/pii-redaction#webpage\",\"url\":\"https://docs.declaw.ai/security/pii-redaction\",\"name\":\"PII Redaction\",\"description\":\"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.\",\"dateModified\":\"2026-06-27T00:49:10.869Z\",\"isPartOf\":{\"@id\":\"https://docs.declaw.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.declaw.ai/security/pii-redaction#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.declaw.ai/security/pii-redaction#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Security\",\"item\":\"https://docs.declaw.ai/security/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PII Redaction\",\"item\":\"https://docs.declaw.ai/security/pii-redaction\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.declaw.ai/security/pii-redaction#article\",\"headline\":\"PII Redaction\",\"name\":\"PII Redaction\",\"description\":\"Configure automatic PII detection and redaction for outbound traffic from Declaw sandboxes.\",\"url\":\"https://docs.declaw.ai/security/pii-redaction\",\"mainEntityOfPage\":{\"@id\":\"https://docs.declaw.ai/security/pii-redaction#webpage\"},\"dateModified\":\"2026-06-27T00:49:10.869Z\",\"publisher\":{\"@id\":\"https://docs.declaw.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.declaw.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Declaw\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Declaw","nav":{"global":{"anchors":[{"anchor":"Community","icon":"discord","href":"https://discord.gg/bjA5Zs9ZPw"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Getting Started","pages":[{"title":"Introduction","sidebarTitle":"Introduction","href":"/introduction"},{"title":"Quickstart","sidebarTitle":"Quickstart","href":"/quickstart"},{"title":"Installation","sidebarTitle":"Installation","href":"/installation"},{"title":"Concepts","sidebarTitle":"Concepts","href":"/concepts"},{"title":"Error codes","href":"/errors"}]},{"group":"Core Features","pages":[{"title":"Sandboxes","sidebarTitle":"Sandboxes","href":"/features/sandboxes"},{"title":"Commands","sidebarTitle":"Commands","href":"/features/commands"},{"title":"Filesystem","sidebarTitle":"Filesystem","href":"/features/filesystem"},{"title":"PTY (pseudo-terminals)","sidebarTitle":"PTY","href":"/features/pty"},{"title":"Interactive Stdio","sidebarTitle":"Stdio","href":"/features/stdio"},{"title":"Networking","sidebarTitle":"Networking","href":"/features/networking"},{"title":"Port Proxy","sidebarTitle":"Port Proxy","href":"/features/port-proxy"},{"title":"Templates","sidebarTitle":"Templates","href":"/features/templates"},{"title":"Snapshots","sidebarTitle":"Snapshots","href":"/features/snapshots"},{"title":"Volumes","sidebarTitle":"Volumes","href":"/features/volumes"}]},{"group":"CLI","pages":[{"title":"CLI","sidebarTitle":"Overview","href":"/cli/overview"},{"title":"Sandbox Commands","sidebarTitle":"sandbox","href":"/cli/sandbox"},{"title":"Template Commands","sidebarTitle":"template","href":"/cli/template"},{"title":"Volume Commands","sidebarTitle":"volume","href":"/cli/volume"},{"title":"Vault Commands","sidebarTitle":"vault","href":"/cli/vault"},{"title":"Account Commands","sidebarTitle":"account","href":"/cli/account"},{"title":"Auth Commands","sidebarTitle":"auth","href":"/cli/auth"},{"title":"MCP Sandboxing","sidebarTitle":"MCP Sandbox","href":"/cli/mcp"}]},{"group":"Security","pages":[{"title":"Security Overview","sidebarTitle":"Overview","href":"/security/overview"},{"title":"AI Governance Packs","sidebarTitle":"Governance Packs","href":"/security/governance-packs"},{"title":"Custom OPA Policies","sidebarTitle":"Custom Policies","href":"/security/custom-policy"},{"title":"Publishing Custom Policy Bundles","sidebarTitle":"Policy Bundles","href":"/security/policy-bundles"},{"title":"Compliance Reporting","sidebarTitle":"Compliance Reporting","description":"Pull a per-account compliance report: enabled governance packs plus policy-denial counts attributed to framework control IDs (OWASP, NIST, MITRE, EU AI Act) over any time window — audit-ready evidence per framework.","href":"/security/compliance"},{"title":"PII Redaction","sidebarTitle":"PII Redaction","href":"/security/pii-redaction"},{"title":"Prompt Injection Defense","sidebarTitle":"Prompt Injection","description":"Detect and block prompt injection in your agent's outbound requests, with configurable sensitivity and block/log actions.","href":"/security/prompt-injection"},{"title":"Network Policies","sidebarTitle":"Network Policies","href":"/security/network-policies"},{"title":"Transformation Rules","sidebarTitle":"Transformation Rules","href":"/security/transformation-rules"},{"title":"Audit Logging","sidebarTitle":"Audit Logging","href":"/security/audit-logging"},{"title":"Credential Vault","sidebarTitle":"Credential Vault","href":"/security/credential-vault"},{"title":"Environment Secrets","sidebarTitle":"Env Secrets","href":"/security/env-secrets"},{"title":"Guardrails Service","sidebarTitle":"Guardrails Service","href":"/security/guardrails-service"}]},{"group":"Platform","pages":[{"title":"Plans \u0026 Limits","sidebarTitle":"Plans \u0026 Limits","href":"/platform/plans"},{"title":"Billing \u0026 Pricing","sidebarTitle":"Billing \u0026 Pricing","href":"/platform/billing"},{"title":"Usage \u0026 Monitoring","sidebarTitle":"Usage \u0026 Monitoring","href":"/platform/usage"},{"title":"Errors \u0026 Rate Limits","sidebarTitle":"Errors \u0026 Rate Limits","href":"/platform/errors"}]},{"group":"Deployment","pages":[{"title":"Deployment","sidebarTitle":"Overview","href":"/deployment/overview"}]},{"group":"Architecture","pages":[{"title":"Architecture Overview","sidebarTitle":"Overview","href":"/architecture/overview"},{"title":"Firecracker MicroVM","sidebarTitle":"Firecracker","href":"/architecture/firecracker"},{"title":"Security Proxy","sidebarTitle":"Security Proxy","href":"/architecture/security-proxy"},{"title":"Network Packet Flow","sidebarTitle":"Packet Flow","href":"/architecture/packet-flow"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/overview"}]},{"tab":"SDKs","pages":[{"title":"SDKs","href":"/sdks/python/overview"}]},{"tab":"Cookbook","pages":[{"title":"Cookbook","href":"/cookbook/overview"}]}]},"title":"PII Redaction - Declaw","buildId":"dpl_DFJrtvUi8HS5F9nkooKuDJsuD5BM","deploymentId":"dpl_DFJrtvUi8HS5F9nkooKuDJsuD5BM","dynamics":[],"chunks":[]}