Detect / redact PII and secrets before LLM use (paid run)
guard_textScan text or document URLs for PII and secrets before sharing with an LLM, then redact findings into placeholders, masks, or hashes.
Instructions
WHAT: The only tool in this server that inspects content. Scans text documents (or public document URLs: txt/md/json/csv/HTML/PDF) for PII (emails, phones, US SSNs, Luhn-valid cards, IBANs, UK NINOs, IPs, optional person names/addresses) and secrets (AWS/GitHub/Slack/Stripe/OpenAI/... keys, JWTs, private keys, URL credentials, high-entropy key=value). mode="detect" reports findings; mode="redact" (default) also returns sanitized text and, on request, the placeholder map that restore_placeholders needs later. WHEN TO USE: before sending prompts, tickets, logs or files to an LLM or third party; to audit text for leaked credentials. Step 2 of the round trip (list_detectors -> guard_text -> [get_run_results] -> LLM -> restore_placeholders). WHEN NOT TO USE: to put originals back into an LLM answer, use restore_placeholders (free, local; mode="restore" here gives the same output but starts a paid run and is only kept for Actor pipelines outside MCP). To see entity types, list_detectors (free). To fetch rows of a run you already started, get_run_results (free; calling guard_text again starts and bills a new run). Not for images/scanned PDFs (text layer only, no OCR) or email deliverability. COST: paid. Runs Apify Actor fairquery/llm-data-guard-pii-secrets with your APIFY_TOKEN; pay-per-event: $0.0015 per document processed + $0.0002 per finding (error rows free). Example: 10 documents with 20 findings ~ $0.02. RETURNS: findings[] hold masked previews only, never raw values; placeholder_map (ORIGINAL values) only with returnPlaceholderMap=true. With waitForFinish=false: items is empty and run.run_id is the input for get_run_results. EXAMPLE: {"texts":["Mail jane@acme.com, key AKIAIOSFODNN7EXAMPLE"],"mode":"redact","redactionStyle":"placeholder"} -> output_text with the email replaced by [EMAIL_1] and the key by a placeholder; findings lists EMAIL and AWS_ACCESS_KEY. PARAMETERS: texts and/or documentUrls: at least one is required although the schema marks both optional (neither -> a free INPUT_EMPTY error row); both may be combined, and every text or URL is one billed document (max 1000 per run; extras get a free MAX_DOCUMENTS_EXCEEDED row). mode decides which other fields apply: "detect" ignores redactionStyle / returnPlaceholderMap; "redact" uses them; "restore" ignores all detector options and only replaces placeholders found in texts with values from placeholderMap (a placeholder missing from the map stays unchanged; restore rows have 0 findings, so they cost the per-document fee only). returnPlaceholderMap only works with mode="redact" + redactionStyle="placeholder" and is what restore_placeholders consumes; placeholders are consistent across all documents of one call ([EMAIL_1] is the same address everywhere) but numbering restarts on every call, so keep each call's map. detectNames / detectAddresses must be true before PERSON / LOCATION / STREET_ADDRESS can be found or used in entityTypes. entityTypes filters findings after detection (unknown names match nothing, no error) and is the main lever to cut per-finding cost. waitForFinish=false returns at once with run.run_id while the run continues in your Apify account (same price, billed once); use it for big batches or many URLs/PDFs that may not finish within this call's 280 s wait, then poll get_run_results with that run_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Optional, one of "detect" | "redact" | "restore", default "redact". "detect" = report findings only; "redact" = also return output_text with values replaced; "restore" = replace placeholders in texts with originals from placeholderMap (paid run; restore_placeholders does the same for free). Example: "detect" | |
| texts | No | Optional if documentUrls is given (at least one of the two is required). One string per document (prompt, chat message, ticket, log, file content), <= 1,000,000 chars each (longer is truncated); one billed document each. Example: ["Hi, I am Jane (jane.doe@acme.com)"] | |
| allowList | No | Optional, default []. Exact values that are never flagged (whole value, case-insensitive; not substrings). Example: ["support@yourcompany.com"] | |
| detectNames | No | Optional boolean, default false. true detects person names (type PERSON) with English NER (lower precision, slightly slower; each finding billed). | |
| entityTypes | No | Optional, default omitted/[] = all enabled detectors. Entity type names (case-insensitive) from list_detectors, without the "(opt-in)" notes. Example: ["EMAIL","CREDIT_CARD","AWS_ACCESS_KEY"] | |
| entropyScan | No | Optional boolean, default false. true also flags unlabeled random-looking tokens of 20+ chars as HIGH_ENTROPY_STRING (catches unknown key formats; may flag hashes/IDs). | |
| documentUrls | No | Optional if texts is given. Absolute public http(s) URLs of txt, md, json, csv, HTML or PDF files (max 10 MB each; PDFs text layer only, no OCR), fetched by the Actor; unreachable URLs give free DOCUMENT_FETCH_FAILED rows. Example: ["https://example.com/report.pdf"] | |
| waitForFinish | No | Optional boolean, default true. true waits up to 280 s and returns the rows; false starts the run and returns immediately with run.run_id (poll get_run_results). Same price either way. Example: false | |
| placeholderMap | No | Optional, default {}; used only with mode="restore". Object mapping placeholder -> original value, as returned in placeholder_map by a previous redact call. Example: {"[EMAIL_1]":"jane@acme.com"} | |
| redactionStyle | No | Optional, one of "placeholder" | "mask" | "hash", default "placeholder"; used in mode="redact" only. "placeholder" = [EMAIL_1], reversible via placeholder map; "mask" = j***@a***.com / **** 1111; "hash" = [EMAIL:3f2a9c0d1b7e] salted sha256 prefix (random salt per run). | |
| detectAddresses | No | Optional boolean, default false. true detects street addresses (STREET_ADDRESS, English formats) and NER place names (LOCATION). | |
| defaultPhoneRegion | No | Optional, default "US". ISO 3166-1 alpha-2 country code (exactly 2 letters, case-insensitive) used to parse phone numbers written without a +country prefix. Examples: "US", "DE", "GB" | |
| returnPlaceholderMap | No | Optional boolean, default false. true (mode="redact" + redactionStyle="placeholder" only) adds placeholder_map {"[EMAIL_1]":"jane@acme.com"} to each row; pass it to restore_placeholders after the LLM step. Contains the ORIGINAL sensitive values. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run | No | Only with waitForFinish=false: run_id, status, dataset_id, console_url | |
| count | Yes | Number of rows in items | |
| items | Yes | Dataset rows: type=document (findings, risk_level, output_text) or type=error |