> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/platform-resources/skill-library/ai-skills/pii-guard.md).

# PII Guard

**PII Guard** detects standard personally identifiable information in raw text and replaces it with generic placeholders — `[SSN]`, `[EMAIL]`, `[PHONE]` — so sensitive data is anonymized before further processing, storage, or transmission.

Use it at the boundary: after data arrives from an external system, and before it reaches somewhere you'd rather it didn't — a log, a less-trusted service, or a model.

## How it works

* **Input resolution** — `$input` (the previous skill's output). `$secret` is available but not typically needed here.
* **Processing** — accepts raw text or JSON-stringified free-form content, identifies standard PII patterns, and returns the text with placeholders inserted:

| Detected      | Replaced with |
| ------------- | ------------- |
| Email address | `[EMAIL]`     |
| SSN           | `[SSN]`       |
| Phone number  | `[PHONE]`     |

* **Execution** — blocking. Completes before the workflow proceeds.
* **Response** — success returns `maskedData` with the redacted text; failure returns an error message and status code.

## Worked example: masking PII from a database query

A workflow queries a customer record — through an API call or a database query — and gets back a text string containing a name, an SSN, and an email address. Before that string reaches a log file or an LLM for analysis, the PII should be gone.

**The problem.** Data retrieved from external systems arrives with sensitive fields you don't want exposed or stored unmasked further downstream.

**The approach.** Put a PII Guard immediately after the step that produces the text. It has one field to configure: **Text to Scan for PII** (`input` in the schema), which you point at the previous skill's output — `$input.data.customerDetailsString`.

<figure><img src="/files/5qvXIoJVZjes2f3QQe2G" alt=""><figcaption><p>Specifying the text input for PII Guard</p></figcaption></figure>

**In:**

> Hello, this is Michael. My SSN is 123-45-6789 and my email is <michael@example.com>. Please call me at (555) 123-4567 or +1-800-555-1212.

**Out:**

> Hello, this is Michael. My SSN is \[SSN] and my email is \[EMAIL]. Please call me at \[PHONE] or \[PHONE].

{% hint style="info" %}
PII Guard masks the **standard patterns** it knows — email, SSN, phone. It is not a general-purpose classifier: a customer name, an account number, or a bank-specific identifier passes through untouched. When you need domain-specific extraction, pair it with [Entity Recognition](/platform-resources/skill-library/ai-skills/entity-recognition.md) and its custom regex rules.
{% endhint %}

## Configuration reference

| Field         | Type   | Required | Description                      |
| ------------- | ------ | -------- | -------------------------------- |
| `input`       | any    | ✅        | Free-form text to scan and mask. |
| `name`        | string | —        | Name for this skill instance.    |
| `description` | string | —        | Description of what it's doing.  |

## Output

The output port (`piiMaskedResult`) always conforms to:

| Field        | Type           | Always | Description                                                 |
| ------------ | -------------- | ------ | ----------------------------------------------------------- |
| `maskedData` | any            | ✅      | The redacted input, PII replaced by placeholders.           |
| `error`      | string \| null | —      | Error message if processing failed; `null` on success.      |
| `statusCode` | number         | ✅      | `200` success · `400` invalid input · `500` internal error. |

**Failure — invalid input:**

```json
{
  "maskedData": null,
  "error": "Invalid input: expected non-empty string.",
  "statusCode": 400
}
```

## Errors

| Message                         | Status | Cause                             |
| ------------------------------- | ------ | --------------------------------- |
| Invalid input                   | `400`  | Null or undefined input.          |
| Masking failed due to exception | `500`  | Internal error during processing. |

## Security

* No `$secret` usage is required.
* **Make sure your logging and debugging tools don't log the unmasked input.** The skill masks in memory before passing data on — but that only protects what happens *after* it.
* Masking is in-memory. No unmasked data is persisted by the skill itself.

<figure><img src="/files/LNukVsUYKzTDiGzCxaTF" alt="" width="563"><figcaption><p>PII Guard's in-memory processing flow</p></figcaption></figure>

## Testing in isolation

* **Path** — `/skill-runtime/workflows/nodes/PIIGuard/execute`
* **Method** — `POST`
* **Body:**

```json
{
  "config": { "input": "I am John. Email: john.doe@example.com. SSN: 123-45-6789" },
  "input": {}
}
```

***

To add this skill to an agent, see [Adding a Skill to the Agent](/agent-builder/build/adding-a-skill-to-the-agent.md). For platform-level PII handling, see [PII Tokenization](broken://pages/ZryZVAnzLvPXJXz1em2n).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.uptiq.ai/platform-resources/skill-library/ai-skills/pii-guard.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
