Fortress Shield: scan text for PII and secrets (free, on this Worker)
pii_scan_textWHAT: Fortress Shield (agent I/O PII protection). Detect PII (emails incl. "jane [at] acme [dot] com" and "jane at acme dot com" forms, phones, US SSNs/ITINs, Luhn-valid cards, mod-97 IBANs, UK NINOs, IPv4 and full or compressed IPv6, MAC addresses, labelled dates of birth / passports / driver's licences / MRNs / health-plan ids / ABA routing numbers, Canadian SIN, NPI/DEA/MBI, VIN, Bitcoin/Ethereum wallets, ES DNI/NIE, IT codice fiscale, FR NIR, IN Aadhaar/PAN, ZIP/postcodes in a residence or ZIP context) and credential-shaped strings (common provider token formats, signed web tokens, PEM key blocks incl. a header without its END line, user:pass in URLs, key=value assignments; full list from pii_list_detectors) in text, plus your own customDetectors. Text is normalized first (NFKC, zero-width characters removed, Cyrillic/Greek look-alike letters folded), so hidden characters do not split a match. Detection only: matches are masked in the output and nothing is sent anywhere. WHEN: Before sending prompts, tickets, logs or files to an LLM or third party; to audit text for leaked credentials. Findings are paged across all documents. WHEN NOT: To get sanitized text use pii_redact_text. For unlabelled person names (NER), or to fetch PDFs and remote documents, use pii_guard_documents (paid). http(s) URLs in text you already have are detected here for free. Not for images (no OCR). COST: Free. Regex and validators on this Worker; no APIFY_TOKEN. RETURNS: Paged findings across all documents, each with a masked preview and, when a label raised it, context; raw values are never returned. meta.documents[] has context_lowered (matches kept at low confidence because of a negative context word), context_suppressed (matches left out with contextMode "drop") and typed_placeholders (placeholder-shaped text such as "[EMAIL_1]" already in the input), below_threshold and context_report (which context word lowered or skipped which type; no values). JSON input: findings carry json_path. meta.audit (counts only), meta.secret_guidance (provider + revoke URL per detected credential type), meta.compliance (HIPAA Safe Harbor identifiers seen). Errors: INPUT_TOO_LARGE, INVALID_PATTERN. BEHAVIOR: Runs on this Fairquery-hosted Worker (Cloudflare), not on the caller's machine; inputs leave the client. This Worker's code is designed not to store inputs, results, or an Apify token. No further network call; the text is not forwarded to another service. Milliseconds. PARAMETERS: texts: one array element per document; each finding carries doc_index = the element's 0-based position, and the 500,000-char cap applies to the SUM of all elements (over it -> INPUT_TOO_LARGE; split into several calls). start/end are offsets in your ORIGINAL text. entityTypes: filters built-in findings after detection; names are case-insensitive, unknown names silently match nothing, NER-only types (PERSON, LOCATION) never match here and STREET_ADDRESS needs detectAddresses=true; customDetectors always run. allowList: whole matched value, case-insensitive; allowDomains: email domains incl. subdomains (allow "yourco.com" to exempt support@yourco.com); allowPatterns: regular expressions tested against the value. entropyScan: only adds HIGH_ENTROPY_STRING findings; it never removes others. defaultPhoneRegion: affects only national-format numbers such as "030 1234567" (needs "DE"); "+49 ..." numbers parse with any region. limit/offset page the flat findings list across all documents, while meta.documents always summarises every document; fetch the next page with offset = nextOffset until hasMore is false. EXAMPLE: {"texts":["Mail jane@acme.com, key AKIAIOSFODNN7EXAMPLE"]} -> 2 findings: EMAIL (masked "j***@a***.com"), AWS_ACCESS_KEY; risk_level "critical".
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"texts": "<texts>"
},
"name": "pii_scan_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Optional page size: items to return, integer 1-1000 (default 100). Example: 50 | |
| texts | Yes | Required. 1-50 documents (prompt, chat message, log, file content), each <= 200,000 chars, total <= 500,000 chars. Example: ["Mail jane@acme.com, key AKIAIOSFODNN7EXAMPLE"] | |
| offset | No | Optional zero-based number of items to skip, integer 0-1000000 (default 0); pass nextOffset from the previous response, e.g. 100 | |
| allowList | No | Optional, default [] (nothing exempt). 0-500 exact values (<= 500 chars each) that are never flagged; whole-value, case-insensitive match, not substring. Example: ["support@yourco.com","192.0.2.1"] | |
| contextMode | No | Optional, "lower" | "drop", default "lower". What happens to a match that only a negative context word argues against: "lower" still flags/redacts it with confidence "low" and context "negative:<reason>" (counted in context_lowered); "drop" (strict precision) leaves it untouched (counted in context_suppressed). | lower |
| detectNames | No | Optional. Omit to keep labelled person names (Dear, Patient, sign-off). false turns those labelled hits off. true keeps them; full person-name NER runs only in the Apify Actor (pii_guard_documents). | |
| entityTypes | No | Optional, default omitted = every free-tool detector (pii_list_detectors rows with local:true). 0-40 detector type names (<= 40 chars, case-insensitive), e.g. ["EMAIL","CREDIT_CARD","AWS_ACCESS_KEY"]. Valid values: the "type" field of those rows; unknown names match nothing (no error) | |
| entropyScan | No | Optional boolean, default false. true also flags unlabeled random-looking tokens of 20-200 chars as HIGH_ENTROPY_STRING (catches unknown key formats; may flag hashes/UUIDs). Example: true | |
| allowDomains | No | Optional, default []. 0-200 email domains whose addresses are never flagged; subdomains included. Example: ["yourco.com"] exempts support@yourco.com and a@eu.yourco.com | |
| allowPatterns | No | Optional, default []. 0-50 JavaScript regular expressions (<= 200 chars; no backreferences or nested quantifiers -> INVALID_PATTERN); a finding whose value matches any of them is not flagged. Example: ["^192\.0\.2\.","@example\.(com|org)$"] | |
| minConfidence | No | Optional, "low" | "medium" | "high", default "low" (everything). Findings below this confidence are left in the text and counted per document as below_threshold (types only); combine with failClosed on pii_redact_text to withhold documents that contain them. | low |
| contextScoring | No | Optional boolean, default true. true uses the words around a match: labels like "SSN:", "phone:", "my cell", "call me" raise confidence, and a label earlier on the same line wins over a negative word. "version"/"v" before an IPv4 or phone-shaped number and "invoice"/"order"/"ticket"/"ref" before a bare phone-shaped number lower it (see contextMode). Phones with +country code, parentheses or two separators, and IPv4 with a port, CIDR suffix or 3-digit octet are never lowered. false = format-only scoring. | |
| customDetectors | No | Optional, default []. 0-20 of your own detectors (regex pattern and/or terms dictionary) for account IDs, ticket formats or member numbers; findings use your type name with category "custom" and are redacted and restored like built-in types. | |
| detectAddresses | No | Optional boolean, default false. true also runs the street-address patterns on this Worker (STREET_ADDRESS: house number + street, PO Box, units, trailing city/state/ZIP or postcode; US/UK/FR/DE-style forms). Pattern-based, medium confidence; place-name NER (LOCATION) and person names stay Actor-only. Example: true | |
| destinationPolicy | No | Optional preset for where the text goes: "llm_public" | "llm_private" | "internal" | "logs" | "analytics". It sets minConfidence, contextMode, entropyScan, excludeEntityTypes and (pii_redact_text) failClosed / leakCheck; meta.destination_policy shows what was applied. Omit to use the individual parameters. | |
| defaultPhoneRegion | No | Optional, default "US". ISO 3166-1 alpha-2 code (2 letters, pattern ^[A-Za-z]{2}$, case-insensitive) used only for phone numbers written without a +country prefix. Examples: "US", "DE", "GB" | US |
| excludeEntityTypes | No | Optional, default []. 0-40 detector type names to switch off (case-insensitive), e.g. ["IP_ADDRESS","POSTAL_CODE"]; applied after entityTypes. customDetectors always run. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| meta | No | Tool-specific context (summary counts, cost notes, ...) | |
| count | Yes | Number of items in this page | |
| items | Yes | Result rows for this page | |
| total | Yes | Total items before paging | |
| offset | Yes | Offset of the first item in this page | |
| hasMore | Yes | True if more items exist after this page | |
| nextOffset | Yes | Offset to pass for the next page, or null |