API reference
One HTTP endpoint does the work: you send text or a file, you get it back with personal data replaced by stable tokens. Everything on this page is live — paste your workspace key and the Send buttons hit your real workspace.
Overview
Base URL is https://piishield.ai. Requests and responses are JSON. There is no SDK to install — the whole integration is one POST.
Authentication
Your workspace key identifies the workspace, applies its coverage settings, and meters usage. Pass it as a query parameter:
POST https://piishield.ai/api/my/redact-document?key=shield_…
How tokens work
Each distinct value becomes a numbered token — [EMAIL_1], [PERSON_2]. Within one request the same value always gets the same token, so a model can still reason about identity: “[PERSON_1] applied twice” is a true sentence about one person.
Redact text
The workhorse. Send any text — a record serialised as JSON, an interview note, a prompt — and get it back tokenised.
| Field | Type | Notes |
|---|---|---|
| text required* | string | The content to redact. *Either text or base64. |
| filename | string | Label only, used for your own logs. |
| mediaType | string | text/plain for text. |
| alwaysMask | string[] | Values you already know are personal. See Declare known values. |
Detect only — no rewriting
Returns every finding with a confidence and a plain-language reason, and changes nothing. Use it as a gate — “does a human need to look at this before the pipeline runs?” — without paying to rewrite a payload you may not send.
Redact a file
Word, Excel, PowerPoint, PDF, images and text/CSV/JSON/code. Office files come back as the same file with formatting intact; PDFs and scans are redacted in place using OCR. Hyperlink targets and document properties are redacted too — otherwise a CV can read [EMAIL_1] on the page while the underlying mailto: link still carries the address.
| Field | Type | Notes |
|---|---|---|
| base64 required* | string | The file bytes, base64-encoded. |
| filename required | string | The extension decides how it is parsed. |
| mediaType | string | MIME type, when you know it. |
| allowSignatureInvalidation | boolean | A digitally signed PDF is refused by default — redaction necessarily breaks the signature. Set true to redact a derivative anyway. |
Declare values you already know
Detection is a heuristic. The name detector is anchored on a list of given names, so it finds some names and misses others — and it will miss more outside the anglophone set. Guessing harder is not the fix: a name is just a word, and a looser detector starts masking employers.
But your system usually knows. candidate.first_name is a name, because your schema says so. Declare those values and they are masked deterministically, for this request only — never stored, never applied to another workspace.
Rules for one request only
alwaysMask declares values; customPatterns declares a shape. Send the identifiers your system uses — an employee number, a claim reference, an internal case ID — and they are masked under your own label for this request, without being written into the workspace's saved coverage.
Each entry is {"type": "YOUR_LABEL", "pattern": "a JavaScript regular expression"}. Your label appears in the token, so EMP-445192 comes back as [EMPLOYEE_ID_1], not as a generic identifier. A pattern you declare outranks the built-in heuristics, because you know what your data is and we are guessing.
Workspace & quota
Your workspace, its plan, coverage settings and remaining allowance. Use it for a health check on startup, or to show usage in your own UI.
Coverage catalogue
Every detector PII Shield offers, grouped into categories, with a worked example for each. Public — this is what the dashboard and the browser extension both render, so your own settings UI can stay in step without hard-coding a list.
Leak Audit
What has already reached AI, per seat. Values are encrypted to a key your workspace holds in its own browser — the API returns ••• and a ciphertext, never a readable value, and that is true for us as well as for you.
Errors
| Status | Meaning | What to do |
|---|---|---|
| 400 | Malformed body, or neither text nor base64 | Fix the request. |
| 402 | Out of quota | Upgrade or add credits. Do not fall back to sending raw data. |
| 404 | Unknown key | Check the key. Treat as fatal. |
200 + supported:false | Readable but not processable — e.g. a signed PDF | Read error and code. SIGNED_PDF needs allowSignatureInvalidation. |
Limits & billing
One request is one billable unit regardless of size, which is another reason to send a whole record in one call rather than field by field. Plans and allowances are on your dashboard; the live figures are below.
Recipes
Before you write any code: is there an MCP server already?
If the system holding the data ships an MCP server — most ATSs, CRMs and helpdesks now do — you may not need this API at all. Put the shield in front of that server and neither you nor the vendor writes an integration:
{ "mcpServers": { "ats": {
"command": "node",
"args": ["~/.claude/plugins/pii-shield/mcp-wrap.mjs",
"--", "npx", "-y", "mcp-remote", "https://your-ats.example.com/mcp"],
"env": { "PII_SHIELD_KEY": "shield_…" } } } }
Node — redact before an LLM call
const r = await fetch(`https://piishield.ai/api/my/redact-document?key=${process.env.PII_SHIELD_KEY}`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ text: JSON.stringify(record), filename: "record.json", mediaType: "text/plain" }),
});
const out = await r.json();
if (!r.ok || out.error) throw new Error("PII Shield unavailable — refusing to send raw data");
await claude.messages.create({ /* … */ content: out.redacted });
Python
import os, requests
r = requests.post(
"https://piishield.ai/api/my/redact-document",
params={"key": os.environ["PII_SHIELD_KEY"]},
json={"text": text, "filename": "record.txt", "mediaType": "text/plain"},
timeout=30,
)
r.raise_for_status()
safe = r.json()["redacted"]
curl
curl -s "https://piishield.ai/api/my/redact-document?key=$PII_SHIELD_KEY" \
-H 'content-type: application/json' \
-d '{"text":"call jane@acme.com","filename":"n.txt","mediaType":"text/plain"}'
tools/ats-mcp-demo, plus a step-by-step integration guide. Ask us for the PDF, or see the product guide.