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

# Guardrail Scan Pdf

Scans a PDF file for security threats using a saved guardrail. Use `X-Enkrypt-Mode` to select between input and output detectors.

* `X-Enkrypt-Mode: prompt` — applies the guardrail's **input** detectors
* `X-Enkrypt-Mode: response` — applies the guardrail's **output** detectors

## Example request:

```python Python theme={"system"}
import requests
import json
import os
import base64

# Read and encode PDF file
with open("document.pdf", "rb") as f:
    file_base64 = base64.b64encode(f.read()).decode("utf-8")

url = "https://api.enkryptai.com/guardrails/guardrail/scan-pdf"

payload = json.dumps({
    "file": file_base64
})

headers = {
    'Content-Type': 'application/json',
    'apikey': os.getenv('ENKRYPTAI_API_KEY'),
    'X-Enkrypt-Guardrail': 'My Guardrail',
    'X-Enkrypt-Mode': 'prompt'
}

response = requests.post(url, headers=headers, data=payload)
print(json.dumps(response.json(), indent=4))
```

```shell cURL theme={"system"}
curl -X POST "https://api.enkryptai.com/guardrails/guardrail/scan-pdf" \
  -H "Content-Type: application/json" \
  -H "apikey: YOUR_API_KEY" \
  -H "X-Enkrypt-Guardrail: My Guardrail" \
  -H "X-Enkrypt-Mode: prompt" \
  -d '{ "file": "BASE64_ENCODED_PDF_CONTENT" }'
```

## Example response:

```json JSON theme={"system"}
{
    "summary": {
        "policy_violation": 0,
        "injection_attack": 0
    },
    "details": {
        "total_pages": 1,
        "pages_with_detections": 0,
        "detections": []
    }
}
```


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