Skip to main content
Scans a URL 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:

import requests
import json
import os

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

payload = json.dumps({
    "url": "https://example.com"
})

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))

Example response:

JSON
{
    "summary": {
        "injection_attack": 1,
        "bias": 1,
        "policy_violation": 0
    },
    "details": {
        "url": "https://example.com",
        "metadata": {
            "title": "Example Domain",
            "language": "en"
        },
        "total_fragments": 2,
        "fragments_with_detections": 2,
        "detections": [
            {
                "unsafe_content": "Example Domain",
                "chunk_type": "title",
                "triggered_detectors": ["bias"],
                "detector_details": {
                    "injection_attack": {
                        "safe": "0.999417",
                        "attack": "0.000583",
                        "most_unsafe_content": "Example Domain",
                        "compliance_mapping": {}
                    },
                    "bias": {
                        "bias": {
                            "bias_detected": true,
                            "debiased_text": "Example Website"
                        }
                    }
                }
            }
        ]
    },
    "result_message": null
}