> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Safety

> Refuse pages that try to instruct your AI model, hide personal data in the text you get back, or answer only from pages Stophy already stored.

Three fields make a scrape safer to feed to a model. `checkPromptInjection` refuses a page that tries to give instructions to an AI. `redactPII` hides personal data in the text. `lockdown` never reads a page live, so it can answer only from pages Stophy already stored. The first two need an API key.

## Make a request

Get an API key in the [Quickstart](https://docs.stophy.dev/quickstart). This request scans a page for prompt injection and hides names, emails and phone numbers in the text.

```bash cURL theme={null}
curl -X POST https://api.stophy.dev/v1/scrape \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.w3.org/People/Berners-Lee/",
    "checkPromptInjection": true,
    "redactPII": { "entities": ["PERSON", "EMAIL", "PHONE"], "replaceStyle": "tag" },
    "maxChars": 900
  }'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.stophy.dev/v1/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.STOPHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://www.w3.org/People/Berners-Lee/",
    checkPromptInjection: true,
    redactPII: { entities: ["PERSON", "EMAIL", "PHONE"], replaceStyle: "tag" },
    maxChars: 900,
  }),
});
const body = await response.json();
console.log(body.costUsd);
```

```python Python theme={null}
import os

import requests

response = requests.post(
    "https://api.stophy.dev/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['STOPHY_API_KEY']}"},
    json={
        "url": "https://www.w3.org/People/Berners-Lee/",
        "checkPromptInjection": True,
        "redactPII": {"entities": ["PERSON", "EMAIL", "PHONE"], "replaceStyle": "tag"},
        "maxChars": 900,
    },
)
print(response.json()["costUsd"])
```

## Read the response

The page had no injected instructions, so it comes back as usual. The scan cost \$0.0025 on top of the page, and `redactPII` cost nothing. This real response is cut. The Markdown is shortened.

```json theme={null}
{
  "success": true,
  "data": {
    "markdown": "|  | **Contents** | See also |\n| --- | --- | --- |\n| ![Tim BL](https://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg) | [Short biography](https://www.w3.org/People/Berners-Lee/#Bio)<br>…",
    "nextOffset": 900,
    "warning": "The page text was cut short. Send offset 900 to read on.",
    "metadata": {
      "title": "Tim Berners-Lee",
      "sourceURL": "https://www.w3.org/People/Berners-Lee/",
      "url": "https://www.w3.org/People/Berners-Lee/",
      "statusCode": 200,
      "contentType": "text/html",
      "cacheState": "miss",
      "costUsd": 0.0035
    }
  },
  "id": "0e6ca452-2d91-4ba3-9768-1386b9cf1af1",
  "costUsd": 0.0035,
  "requestId": "0e6ca452-2d91-4ba3-9768-1386b9cf1af1"
}
```

## Prompt injection

`checkPromptInjection: true` scans the page text for instructions aimed at an AI model before anything is built from it. A page that has them is refused with `403 promptInjectionDetected`, and the message quotes the text as evidence. Nothing is returned and nothing is charged. Send `checkPromptInjection` as `false` to read that page anyway.

The scan reads the first 150,000 characters of the page. A longer page, or one the scan cannot finish, comes back with a `warning` that it was not fully checked, and the scan is not charged.

## Redact personal data

`redactPII` hides personal data in the Markdown and in everything made from it: `summary`, `question`, `highlights` and `json`. Links, `html` and `rawHtml` are not changed. Send `true` for the defaults, or an object. This request body hides names and emails on a plain text page. The real response is cut.

```json theme={null}
{
  "url": "https://www.rfc-editor.org/rfc/rfc2606.txt",
  "redactPII": { "entities": ["PERSON", "EMAIL"], "replaceStyle": "tag" },
  "maxChars": 1500
}
```

```json theme={null}
{
  "success": true,
  "data": {
    "markdown": "Network Working Group                                     <PERSON>\nRequest for Comments: 2606                                  <PERSON>\nBCP: 32                                                     June 1999\nCategory: Best Current Practice\n\n\n                    Reserved Top Level DNS Names\n\n…",
    "nextOffset": 1495,
    "warning": "The page text was cut short. Send offset 1495 to read on.",
    "metadata": {
      "contentType": "text/plain",
      "statusCode": 200,
      "costUsd": 0.001
    }
  },
  "id": "c256a33f-55f8-44c5-befc-48e9902b1876",
  "costUsd": 0.001,
  "requestId": "c256a33f-55f8-44c5-befc-48e9902b1876"
}
```

## Read only what is stored

`lockdown: true` answers only from a stored copy of the page, of any age, and never reads it live. Use it when nothing must reach the site. A page with no stored copy returns `404 notFound`.

```json theme={null}
{
  "url": "https://example.com/never-stored-page-1",
  "lockdown": true
}
```

```json theme={null}
{
  "success": false,
  "error": "Stophy has no stored copy of that page. Remove minAge or lockdown to read the page live.",
  "code": "notFound",
  "retryable": false,
  "requestId": "d5f47618-b79e-4033-9d0e-895ca91e7c40"
}
```

On a page that is stored, the same call returns the page with `cacheState` `hit` and costs \$0.001.

## Options

| Field | Type | Default | Effect |
| - | - | - | - |
| `checkPromptInjection` | `boolean` | `false` | Scan the page text for instructions aimed at an AI model. Needs an API key. |
| `redactPII` | `boolean` or `object` | `false` | Hide personal data. `true` uses the defaults below. Needs an API key. |
| `redactPII.mode` | `string` | `"accurate"` | `accurate` finds names and places with a model and the rest by pattern. `aggressive` adds guesses that catch more and may hide a little too much. `fast` uses patterns only, so it finds no ordinary names or places. |
| `redactPII.entities` | `array of string` | all six | What to hide: `PERSON`, `EMAIL`, `PHONE`, `LOCATION`, `FINANCIAL`, `SECRET`. |
| `redactPII.replaceStyle` | `string` | `"tag"` | `tag` writes `<EMAIL>`, `mask` writes `*` for each character, and `remove` deletes the text. |
| `lockdown` | `boolean` | `false` | Answer only from a stored copy and never read live. The same as `minAge: 0`. |

## Limits and errors

* A page the model cannot scan is refused, not returned unredacted. This happens for `PERSON` and `LOCATION` on a page longer than 300,000 characters. The call returns `503 sourceUnavailable`, and nothing is charged. Use `mode: "fast"`, or leave those two out of `entities`.
* `checkPromptInjection`, `redactPII` and `onlyCleanContent` without an API key return `401 apiKeyRequired`.
* `lockdown` on a page with no stored copy returns `404 notFound`.

## Price

`checkPromptInjection` adds $2.50 per 1,000 pages when the scan runs. `redactPII` and `lockdown` add nothing. The page itself is $1 per 1,000 pages. A page that is refused as injected, and a page that cannot be read, cost nothing.

## Related

* [Freshness and caching](https://docs.stophy.dev/scrape/freshness-and-caching.md) covers `minAge` and stored copies.
* [Content filtering](https://docs.stophy.dev/scrape/content-filtering.md) removes banners and prompts with `onlyCleanContent`.
* [Responsible use](https://docs.stophy.dev/production/responsible-use.md) covers what Stophy reads and what it does not.
* [Zero data retention](https://docs.stophy.dev/production/zero-data-retention.md) keeps nothing from a call.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.