Redacting PHI from n8n HTTP Request Node Responses Before the AI Agent Reads Them
Place redaction between the HTTP Request node and the AI Agent node, and make it the only path to the agent. Request only the fields the agent needs, apply a field allow-list, add pattern and context-aware detection for free text, and make sure no raw payload persists in execution data. Record what was detected, what was redacted and which policy applied for every tool call. Redaction reduces exposure but does not by itself guarantee privacy.
Map where PHI enters the agent path
- 1
1. API response
Names, MRNs, dates of birth, diagnoses and contact details arrive as nested JSON and free-text notes.
- 2
2. Workflow items
The response becomes item data that any downstream node can read.
- 3
3. Agent context
Whatever reaches the AI Agent node can enter the prompt and tool results the model reads.
- 4
4. Connected tools and memory
Tool outputs and stored conversation state can carry PHI forward into later steps.
- 5
5. Execution data and logs
If the workflow saves execution data, raw node output can sit in that record.
- 6
6. Model provider request
Anything in context may be sent to a third-party model provider.
Evidence a redaction step should produce
- Tool-call identifier and workflow identifier, with timestamp
- Policy name and version applied to the call
- Detected PHI categories and the fields or text spans affected
- Action taken: allowed, redacted or blocked
- Confirmation of what was passed to the agent, in redacted form
- Retention and export path for the evidence itself
Compare redaction placement options
There are three common places to remove PHI. They differ in how quickly they can be built, how consistently they apply, and what evidence they leave behind. None is correct in every case, and the choice depends on how many workflows call PHI-bearing APIs and who owns the policy.
- In-workflow Code or Function node: Fast to build and easy to see in the canvas. Works well for known, structured fields. Limits: regex-style detection misses PHI in free text, the logic gets copied across workflows and drifts, and the raw response has already passed through the workflow before the code runs.
- Separate sanitizing service: One implementation shared by many workflows, and it can use NER or a de-identification service for free text. Limits: you own its availability, latency, versioning and tests, and the workflow must be built so no branch skips the call.
- Policy enforcement in the execution path: A policy is defined once and applied at runtime to each tool call: allow, redact or block. Evidence is produced by the enforcement itself. Limits: it introduces a component in the path that must be deployed, operated and tuned against your payloads.
Implement response redaction before the agent step
Apply minimum necessary at the request first. The Privacy Rule applies the standard to requests for PHI as well as uses and disclosures, so configure the HTTP Request node to ask only for the fields the agent needs. Fields you never request cannot leak.
Next, filter the response with a field-level allow-list rather than a block-list. Keep named fields that the task requires and drop everything else. This is more reliable than trying to enumerate every sensitive field, and it handles new fields added to an API later.
Then handle free text. Notes, messages and reason-for-visit fields cannot be controlled by an allow-list alone. Run detection over them with patterns for structured identifiers such as MRNs, phone numbers and dates, and add context-aware detection for names and clinical terms. Replace matches with typed placeholders so the agent can still reason about the record without the underlying values. If a response cannot be processed reliably, block it rather than pass it through.
Finally, make the redaction step unavoidable. Route the HTTP Request node output only to the redaction step, and give the AI Agent node no other route to the raw data. Test with realistic payloads, including nested JSON and long notes, and record false negatives. Treat the false-negative rate as a measurable quantity you tune against a threshold your compliance team sets.
Account for execution data and the limits of redaction
Redaction that runs after a raw payload has been stored does not remove the stored copy. If the workflow saves execution data, the HTTP Request node's raw output may be retained in that record, regardless of what the agent later sees. Review execution-saving settings, error-handling output and any log shipping for the workflows in scope, and keep raw PHI out of them. HHS breach guidance states that redaction is specifically excluded as a means of data destruction, so do not describe retained raw data as secured or destroyed because a redacted copy exists elsewhere.
Be equally careful about what redaction proves. NIST describes redaction as suppression-based de-identification and notes that it is generally insufficient to provide formal privacy guarantees. It also notes that removal-only approaches have been defeated by re-identification attacks. For agent workflows, this supports layering: minimum-necessary requests, allow-lists, detection tested against free text, and controls on what is retained. Have legal and compliance confirm how the Safe Harbor identifiers apply to your payloads, rather than treating a pattern list as a de-identification determination.
Enforcing policy in the execution path
In-workflow code is a sound starting point for a single workflow. It becomes harder to defend as the number of workflows grows: each copy needs its own tests, changes must be applied everywhere, and evidence depends on whatever each author remembered to record. Execution-path enforcement addresses this by moving the decision out of individual workflows. The policy is enforced at runtime, not reviewed after the fact, so a response is allowed, redacted or blocked before the model reads it.
Trussed takes this approach. It enforces policy in the execution path across models, agents and tools, at the level of individual interactions and tool calls, with actions that include allow, redact and block. The enforcement generates audit-ready evidence mapped to HIPAA, and it can be deployed self-managed in the customer cloud with configurable retention and data residency. Trussed runs in production with healthcare and pharma organizations.
Whichever option you choose, the evaluation questions are the same. Where does raw PHI persist? What detection method is used and how are false negatives measured? Is policy defined once or duplicated? What evidence exists for each tool call? Is enforcement applied before the model sees the data? The proposed Security Rule NPRM from January 2025 remains a proposal as of November 2026, so design to current requirements and track it separately.
Data path from API response to model
HTTP Request node
EHR, claims, scheduling or portal payload with raw PHI
Redaction point
Allow, redact or block before the agent sees the response
AI Agent node
Receives only minimum-necessary, redacted content
Evidence record
Detections, redactions, policy and tool-call ID retained for audit
Review your agent data path with a specialist
Walk through where PHI enters your n8n workflows and what evidence your redaction step needs to produce.
Explore Agent and Tool-Call EnforcementHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.