Scans a URL for security threats including injection attacks and policy violations. The detector analyzes the provided URL and returns details about any detected threats, including which detectors were triggered and highlights of unsafe content.

Example request:

import requests
import json
import os

url = "https://api.enkryptai.com/guardrails/scan-url"
payload = json.dumps({
    "url": "https://www.digitalocean.com/community/tutorials/how-to-install-poetry-to-manage-python-dependencies-on-ubuntu-22-04",
    "detectors": {
        "injection_attack": {
            "enabled": true
        },
        "policy_violation": {
            "enabled": true,
            "policy_text": "Detect any malicious text or injection attacks"
        }
    }
})
headers = {
    'Content-Type': 'application/json',
    'apikey': os.getenv('ENKRYPTAI_API_KEY')
}
response = requests.post(url, headers=headers, data=payload)
print(response.json())

Example response:

JSON
{
    "url": "https://www.digitalocean.com/community/tutorials/how-to-install-poetry-to-manage-python-dependencies-on-ubuntu-22-04",
    "violations": [
        {
            "unsafe_content": "Report this What is the reason for this report? This undefined is spam This undefined is offensive This undefined is off-topic This undefined is other Submit Tutorial How To Install Poetry to Manage Python Dependencies on Ubuntu 22.04 Published on October 20, 2022 Python Ubuntu 22.04 By Tony Tran Table of contents Popular topics Introduction Poetry is a dependency manager for Python that is also capable of building and packaging your Python projects for distribution. As a dependency manager, it comes with tools for maintaining consistent and contained virtual environments. Additionally, it has tools to integrate with workflows using other",
            "chunk_type": "content_block",
            "triggered_detectors": [
                "injection_attack"
            ],
            "guardrails_result": {
                "injection_attack": {
                    "safe": "0.000020",
                    "attack": "0.999980",
                    "most_unsafe_content": "Report this What is the reason for this report? This undefined is spam This undefined is offensive This undefined is off-topic This undefined is other Submit Tutorial How To Install Poetry to Manage Python Dependencies on Ubuntu 22.04 Published on October 20, 2022 Python Ubuntu 22.04 By Tony Tran Table of contents Popular topics Introduction Poetry is a dependency manager for Python that is also capable of building and packaging your Python projects for distribution. As a dependency manager, it comes with tools for maintaining consistent and contained virtual environments. Additionally, it has tools to integrate with workflows using other"
                },
                "policy_violation": {
                    "policy_violation": {
                        "violating_policy": "No Violation Found",
                        "explanation": "No Violation Found"
                    }
                }
            }
        }
    ],
    "combined_highlight_url": "https://www.digitalocean.com/community/tutorials/how-to-install-poetry-to-manage-python-dependencies-on-ubuntu-22-04#:~:text=Report%20this%20What,workflows%20using%20other"
}