n8n and Make
Redact documents inside an n8n or Make workflow with plain HTTP requests to the /v1 API: create a job, poll it, download the result, delete the job. No community node is needed.
Files for this page: https://github.com/dambuchs/redact-pdf-mcp/tree/main/examples/n8n.
Credential
In n8n, create a Header Auth credential with Name X-API-Key and your API key as Value (Dashboard → Settings → API keys). Every HTTP Request node below uses Authentication → Generic Credential Type → Header Auth → this credential.
Redact before a document leaves the company
| # | Node | Settings |
|---|---|---|
| 1 | Any trigger that yields a binary file (Gmail, Google Drive, Webhook, Read/Write Files from Disk) | The file in the binary field data |
| 2 | HTTP Request "Create job" | POST https://www.redact-pdf.ai/v1/jobs. Send Body on, Body Content Type Form-Data. Parameters: files = n8n Binary File, Input Data Field Name data; mode = Form Data, redact; retention = Form Data, ephemeral; pii_categories = Form Data, ["Person","Email","PhoneNumber","Address","Organization","Date","IBAN","CreditCard"]; pii_excluded_terms = Form Data, [] |
| 3 | Wait | Resume After Time Interval, 5 seconds |
| 4 | HTTP Request "Job status" | GET https://www.redact-pdf.ai/v1/jobs/{{ $('Create job').item.json.job_id }} |
| 5 | IF "Done?" | Boolean condition {{ $json.documents.length > 0 && $json.documents.every(d => ['redacted','error'].includes(d.status)) }} is true. Connect the false output to node 5b |
| 5b | IF "Waited too long?" | Boolean condition {{ $runIndex >= 60 }} is true (about 5 minutes). true → a Stop and Error node; false → back to node 3 |
| 6 | HTTP Request "Download" | GET https://www.redact-pdf.ai/v1/documents/{{ $json.documents[0].id }}/output. Options → Response → Response Format File, Put Output in Field data |
| 7 | Your send step (email, Drive, Slack) | Attach the binary data |
| 8 | HTTP Request "Delete job" | DELETE https://www.redact-pdf.ai/v1/jobs/{{ $('Create job').item.json.job_id }} |
Keep the pii_categories and pii_excluded_terms fields: without them the account's saved dashboard categories and "never redact" terms apply. After node 5, a document with status: "error" failed; error_message says why. A job can hold several files: loop over documents if you upload more than one.
A webhook that would replace the polling loop is not available yet; this page will say so when it is.
Pseudonymize → LLM → restore names
Use the same nodes 1–5 with mode set to pseudonymize, then:
- HTTP Request GET
/v1/documents/{{ id }}/output.md, Response Format Text, Options → Response → Include Response Headers and Status on. Thex-text-versionheader identifies this text. - Your LLM node (AI Agent, OpenAI, Anthropic, …) gets that text only. Detected names are tags such as
[Person 1]; anything the detection missed, and everything that is not personal data, stays as written. Ask it to keep the tags exactly as written. - HTTP Request GET
/v1/documents/{{ id }}/correspondence?text_version={{ version }}, Response Format Text. This CSV holds the real names: never connect it to the LLM node. - Edit Fields sets
text(the LLM output) andcorrespondence(the CSV) on one item, then a Code node (JavaScript, Run Once for Each Item) with the snippet below returnsrestoredandreplacements. Stop the workflow whenreplacementsis 0: the LLM dropped or reworded every tag. The CSV starts with a byte-order mark for spreadsheets; the snippet drops it. - Delete job, as in node 8 above.
// Paste into an n8n Code node ("Run Once for Each Item", JavaScript): puts the real names
// back into text an LLM wrote from a pseudonymized document.
//
// Expects on the item:
// $json.text the LLM's output, with tags such as [Person 1]
// $json.correspondence the CSV from GET /v1/documents/{id}/correspondence
// Returns $json.restored and $json.replacements. The restored text contains real
// names: send it to a person or your own storage, never back to an LLM.
function parseCsv(csv) {
const rows = [];
let row = [], field = '', quoted = false;
for (let i = 0; i < csv.length; i++) {
const c = csv[i];
if (quoted) {
if (c === '"' && csv[i + 1] === '"') { field += '"'; i++; }
else if (c === '"') quoted = false;
else field += c;
} else if (c === '"') quoted = true;
else if (c === ',') { row.push(field); field = ''; }
else if (c === '\n') { row.push(field); rows.push(row); row = []; field = ''; }
else if (c !== '\r') field += c;
}
if (field || row.length) { row.push(field); rows.push(row); }
return rows;
}
// The API prefixes a leading = + - @ with ' so spreadsheets don't run it.
const unescape = (v) => (v.length > 1 && v[0] === "'" && '=+-@\t\r'.includes(v[1]) ? v.slice(1) : v);
function restoreNames(text, csv) {
// The API sends the CSV with a byte-order mark (for spreadsheets): drop it.
const [header, ...rows] = parseCsv(csv.replace(/^\ufeff/, ''));
const col = (name) => header.indexOf(name);
const lookup = new Map();
const ambiguous = new Set();
for (const r of rows) {
const original = unescape(r[col('original')] ?? '');
if (!original) continue;
for (const tag of [r[col('placeholder')], r[col('label')]].map((t) => unescape(t ?? ''))) {
if (!tag) continue;
if (lookup.has(tag) && lookup.get(tag) !== original) ambiguous.add(tag);
else lookup.set(tag, original);
}
}
for (const tag of ambiguous) lookup.delete(tag);
if (lookup.size === 0) return { restored: text, replacements: 0 };
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// A bracketed tag also matches with Markdown escaping: \[Person 1\] or \[Person 1].
const piece = (tag) =>
tag.length > 2 && tag.startsWith('[') && tag.endsWith(']') ? `\\\\?\\[${escape(tag.slice(1, -1))}\\\\?\\]` : escape(tag);
const pattern = new RegExp([...lookup.keys()].sort((a, b) => b.length - a.length).map(piece).join('|'), 'g');
let replacements = 0;
const restored = text.replace(pattern, (match) => {
replacements++;
return lookup.get(match.replace(/\\([[\]])/g, '$1'));
});
return { restored, replacements };
}
// replacements is 0 when the LLM dropped or reworded every tag: check it before sending.
return { json: restoreNames($json.text, $json.correspondence) };
The same restore in Python, with the full REST flow, is in https://github.com/dambuchs/redact-pdf-mcp/tree/main/examples/rest.
n8n AI Agent with MCP
n8n's MCP Client Tool node can connect an AI Agent node to the hosted server: Endpoint https://mcp.redact-pdf.ai/mcp, Server Transport HTTP Streamable (node version 1.1 or later), Authentication Header Auth with X-API-Key. The hosted server cannot read n8n's binary data or local paths: it takes a file as file_base64 (under 1 MB) or through an upload link meant for a person. For files flowing through a workflow, the HTTP Request nodes above are the reliable route.
Make
The same pattern works in Make:
- HTTP → Make a request with Body content type multipart/form-data and the file from the previous module in a field named
files, plusmode,retention,pii_categoriesandpii_excluded_termsas text fields, and a headerX-API-Key. - A Repeater followed by Tools → Sleep and a status request, with a filter that stops once the job status is
redactedorerror, as the polling loop. - HTTP → Download a file (same header) for
/v1/documents/{id}/output.
Retention
The Delete job node removes the job's files and detected text from Redact PDF AI right away; it fails with 409 while a document is still processing. Without it, the original of an ephemeral job is deleted right after a successful redaction and the outputs when your account's retention window ends (14 days by default). See Retention.
n8n keeps its own copy: each execution's data, the correspondence CSV and the restored text included, stays in the execution history. Turn off saving successful executions for this workflow (Workflow settings), or prune the history, if the names must not stay there.