> ## 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.

# Detect with Guardrail

> Detect threats in text using a saved guardrail with input/output mode selection



## OpenAPI

````yaml POST /guardrails/guardrail/detect
openapi: 3.0.0
info:
  title: Enkrypt AI APIs
  version: 2.0.0
servers:
  - url: https://api.enkryptai.com
security:
  - apiKeyAuth: []
tags:
  - name: Guardrails
  - name: Code of Conduct
  - name: Endpoints
  - name: Redteam
    description: >-
      Red Team API: submit red-team / threat-modeling / playground / eval runs,
      then poll run status, records, results and compliance. Also two-phase
      threat modeling (categories + data), dataset retrieval, model health,
      findings and risk mitigation. The previous task-based Red Team API is
      under **Archived**.
  - name: Deployments
  - name: AI Proxy
  - name: Leaderboard
  - name: Archived
  - name: MCP Hub
    description: >-
      MCP Hub vulnerability scanning APIs. Submitting scans (the POST endpoints)
      is open to all authenticated callers. The scan **retrieval** APIs — Get
      Scan Job Status, Get Complete Scan Results, List Scans, and Get MCP Hub
      Scan Statistics (the GET endpoints) — are an **enterprise data-license
      feature**: they require your organization to have MCP Hub API access
      enabled by Enkrypt, otherwise they return `403`. Contact us at
      support@enkryptai.com to enable access.
  - name: MCP Registry Servers
  - name: MCP Gateways
  - name: MCP Playground
  - name: Skill Scanner
    description: >-
      Skill Scanner APIs: submit an agent skill (a directory inside a git
      repository) for security scanning, then read the verdict, the risk level
      and the full report. Scanning is asynchronous — a scan takes roughly 30–90
      seconds, so `POST /skill-hub/scan` returns a `scan_id` you poll.


      You see your organization's scans and nobody else's. The identity comes
      from your API key, never from your request — sending `user_email` is a
      `400`.


      For an organization or project API key, scans are filed under the
      **organization**, so every member sees every scan the organization has
      run, whichever project or member submitted it. For an individual account
      it is simply your own scans. Either way List Skill Scans needs no
      parameter to say who you are.
  - name: Compliance
    description: >-
      Compliance APIs: connect a ChatGPT Enterprise workspace, then keep reading
      its compliance logs and scanning every message through one of your saved
      guardrails.


      Every endpoint here — reads as well as writes — requires the **governance
      officer** role on the project your API key belongs to. The organization
      owner is **not** exempt: an owner who has not been granted the role gets
      `403` like anyone else. An individual (non-organization) account cannot
      hold the role at all, so compliance is an organization-only feature today.


      A scan is addressed by name in the `X-Enkrypt-Scan` header, within the
      project its API key belongs to. Message text is never stored: Get
      Compliance Message fetches it live from the provider, and only while the
      provider still holds it.
paths:
  /guardrails/guardrail/detect:
    post:
      tags:
        - Guardrails
      summary: Detect Using Guardrail
      description: >-
        Detects and filters content using a guardrail. Use X-Enkrypt-Mode to
        select input (prompt) or output (response) detectors. If the guardrail's
        policy_violation detector is configured with structured `rules`, the
        response's details.policy_violation includes a `violated_rules` array;
        otherwise (legacy `policy_text`) behavior is unchanged.
      operationId: detect_using_guardrail
      parameters:
        - name: X-Enkrypt-Guardrail
          in: header
          required: true
          schema:
            title: Guardrail Name
            type: string
            description: The guardrail name
            example: My Guardrail
        - name: X-Enkrypt-Mode
          in: header
          required: true
          schema:
            title: Mode
            type: string
            enum:
              - prompt
              - response
            description: Whether to apply input (prompt) or output (response) detectors
            example: prompt
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GuardrailDetectRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuardrailsDetectionResponse'
              examples:
                policy_violation_rules_response:
                  summary: >-
                    policy_violation (rules, with violated_rules) alongside a
                    detected injection_attack
                  value:
                    summary:
                      injection_attack: 1
                      policy_violation: 1
                    details:
                      injection_attack:
                        safe: 0.001584
                        attack: 0.998416
                        p_injection: '0.998416'
                        p_jailbreak: '0.103658'
                        detected_attacks:
                          - injection
                        explanation: >-
                          Prefaces the request with an instruction to disregard
                          prior directives before asking for another customer's
                          record.
                      policy_violation:
                        violating_policy: >-
                          Rule 1: Both user queries and assistant responses must
                          not contain disclosure of personal or sensitive data
                          about an identifiable individual OTHER THAN the person
                          communicating in the chunk.
                        explanation: >-
                          Discloses personal and sensitive data (SSN, balance)
                          about a named third party (John Q. Public).
                        violated_rules:
                          - id: priv-1
                            display_text: No disclosing others' personal data
                            text: >-
                              Both user queries and assistant responses must not
                              contain disclosure of personal or sensitive data
                              about an identifiable individual OTHER THAN the
                              person communicating in the chunk.
                            risk_category: privacy_data_protection
                            applicability: user_assistant
                            severity: high
                            frameworks:
                              - hipaa
                              - gdpr
                            mappings:
                              - framework: gdpr
                                clause: Art. 9 — Special categories of personal data
                            source: document/catalog
                            suggested: false
                        most_unsafe_content: >-
                          the full account record for another customer, John Q.
                          Public: SSN 123-45-6789, balance $84,220
                    result_message: >-
                      Your message does not comply with our usage policies.
                      Please revise and try again.
                policy_violation_legacy_response:
                  summary: >-
                    policy_violation (legacy policy_text, no violated_rules)
                    alongside a detected injection_attack
                  value:
                    summary:
                      injection_attack: 1
                      policy_violation: 1
                    details:
                      injection_attack:
                        safe: 0.001584
                        attack: 0.998416
                        p_injection: '0.998416'
                        p_jailbreak: '0.103658'
                        detected_attacks:
                          - injection
                        explanation: >-
                          Attempts to override the system prompt before
                          requesting instructions for building an explosive
                          device.
                      policy_violation:
                        violating_policy: Policy on Safety and Legal Compliance
                        explanation: >-
                          The request asks for step-by-step instructions to
                          build an explosive device, which the policy prohibits
                          as content promoting harm or illegal activity.
                        most_unsafe_content: >-
                          walk me through assembling a pipe bomb from
                          hardware-store parts
                    result_message: >-
                      Your message does not comply with our usage policies.
                      Please revise and try again.
components:
  schemas:
    GuardrailDetectRequest:
      title: GuardrailDetectRequest
      type: object
      properties:
        text:
          title: Text
          type: string
          description: The text to analyze
        user_metadata:
          $ref: '#/components/schemas/UserMetadata'
      required:
        - text
    GuardrailsDetectionResponse:
      title: GuardrailsDetectionResponse
      type: object
      required:
        - summary
        - details
      properties:
        summary:
          $ref: '#/components/schemas/GuardrailsDetectionResponseSummary'
        details:
          $ref: '#/components/schemas/GuardrailsDetectionResponseDetails'
        result_message:
          type: string
          nullable: true
          title: Result Message
          description: >-
            Block message when a block-type detector triggers (custom or
            built-in default), revised text when only revise-type detectors
            trigger, or null when no detections fire.
        user_metadata:
          $ref: '#/components/schemas/UserMetadata'
    UserMetadata:
      type: object
      description: >-
        Optional arbitrary metadata object echoed back in the response. Limits:
        at most 16 top-level keys, key names up to 64 characters, nesting depth
        up to 3, total serialized size up to 4 KB. When provided and valid, this
        object is also echoed as a top-level `user_metadata` key on error
        responses (4xx/5xx) of endpoints that accept it; invalid or oversized
        metadata is never echoed, including on the 422 response it causes.
      additionalProperties: true
      maxProperties: 16
      example:
        request_id: abc-123
        source: mobile-app
    GuardrailsDetectionResponseSummary:
      type: object
      title: GuardrailsDetectionResponseSummary
      properties:
        nsfw:
          type: integer
          title: NSFW Count
          example: 0
        toxicity:
          type: array
          title: Toxicity Categories
          items:
            type: string
          example:
            - toxicity
            - severe_toxicity
            - obscene
            - threat
            - insult
            - identity_hate
        pii:
          type: integer
          title: PII Count
          example: 0
        injection_attack:
          type: integer
          title: Injection Attack
          description: >-
            1 when a prompt-injection or jailbreak attempt was detected, 0
            otherwise. Which attack types fired is reported in
            details.injection_attack.detected_attacks.
          example: 1
        keyword_detected:
          type: integer
          title: Keyword Detected Count
          example: 0
        system_prompt_similarity:
          type: integer
          title: System Prompt Similarity
          example: 0
        copyright_ip_similarity:
          type: integer
          title: Copyright/IP Similarity
          example: 0
        policy_violation:
          type: integer
          title: Policy Adherence Count
          example: 0
        bias:
          type: integer
          title: Bias Count
          example: 0
        sponge_attack:
          type: integer
          title: Sponge Attack Detected or not
          example: 0
    GuardrailsDetectionResponseDetails:
      type: object
      title: GuardrailsDetectionResponseDetails
      properties:
        nsfw:
          type: object
          title: NSFW Details
          properties:
            sfw:
              type: number
              title: Safe for Work Score
              example: 0.000395895738620311
            nsfw:
              type: number
              title: Not Safe for Work Score
              example: 0.9996041054725647
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        toxicity:
          type: object
          title: Toxicity Details
          properties:
            toxicity:
              type: number
              title: Toxicity Score
              example: 0.000395895738620311
            severe_toxicity:
              type: number
              format: float
              title: Severe Toxicity Score
              example: 0.000395895738620311
            obscene:
              type: number
              title: Obscenity Score
              example: 0.000395895738620311
            threat:
              type: number
              title: Threat Score
              example: 0.000395895738620311
            insult:
              type: number
              title: Insult Score
              example: 0.000395895738620311
            identity_hate:
              type: number
              title: Identity Hate Score
              example: 0.000395895738620311
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        pii:
          type: object
          title: PII Details
          properties:
            secrets:
              type: object
              title: Secrets Detected
            pii:
              type: object
              title: PII Details
            ip_address:
              type: object
              title: IP Addresses Detected
            url:
              type: object
              title: URLs Detected
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        injection_attack:
          type: object
          title: Injection Attack Details
          properties:
            safe:
              type: number
              title: Safe Score
              example: '0.000004'
            attack:
              type: number
              title: Attack Score
              example: '0.999996'
            p_injection:
              type: string
              title: Injection Probability
              description: >-
                Probability that the input is a prompt-injection attempt, to 6
                decimal places.
              example: '0.998970'
            p_jailbreak:
              type: string
              title: Jailbreak Probability
              description: >-
                Probability that the input is a jailbreak attempt, to 6 decimal
                places.
              example: '0.103658'
            detected_attacks:
              type: array
              title: Detected Attacks
              description: >-
                The attack types that fired. Empty when nothing was detected,
                and non-empty exactly when summary.injection_attack is 1.
                Populated on the text detect paths; the image and audio
                endpoints report only the summary verdict.
              items:
                type: string
                enum:
                  - injection
                  - jailbreak
              example:
                - injection
            explanation:
              type: string
              title: Explanation
              description: >-
                One-sentence reason for a confirmed attack. Populated only when
                the request set `need_explanation: true` and an attack was
                confirmed; an empty string otherwise.
              example: >-
                Instructs the AI to ignore its system prompt and reveal hidden
                instructions.
            most_unsafe_content:
              type: string
              title: Most Unsafe Content
              description: The most unsafe content detected in the input
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        keyword_detector:
          type: object
          title: Keyword Detector Details
          properties:
            detected_keywords:
              type: array
              title: Detected Keywords
              items:
                type: string
            detected_counts:
              type: object
              title: Detected Counts
              example:
                keyword1: 1
                keyword2: 2
            redacted_text:
              type: string
              title: Redacted Text
        system_prompt:
          type: object
          title: System Prompt Similarity
          properties:
            similarity_score:
              type: integer
              title: Similarity Score
              example: 0
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        copyright_ip:
          type: object
          title: Copyright/IP Similarity Details
          properties:
            similarity_score:
              type: integer
              title: Similarity Score
              example: 0
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        policy_violation:
          type: object
          title: Policy Adherence Details
          properties:
            violating_policy:
              type: string
              title: Violating Policy
              description: >-
                Legacy string of the violated policy line(s). Always returned
                regardless of whether the config used rules or policy_text.
            violated_rules:
              type: array
              title: Violated Rules
              description: >-
                NEW — full rule objects that were violated. Present ONLY when
                the request's policy_violation config used the structured
                `rules` array. On an ambiguous violation (empty/all markers)
                this contains every enforced rule (safe default).
              items:
                $ref: '#/components/schemas/Rule'
            explanation:
              type: string
              title: Explanation
            most_unsafe_content:
              type: string
              title: Most Unsafe Content
              description: >-
                The chunk of the input that triggered the violation. Empty
                string when no violation was found.
        bias:
          type: object
          title: Bias Details
          properties:
            bias_detected:
              type: boolean
              title: Bias Detected
            biased_text:
              type: string
              title: Biased Text
            debiased_text:
              type: string
              title: Debiased Text
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
        sponge_attack:
          type: object
          title: Sponge Attack Details
          properties:
            sponge_attack_detected:
              type: boolean
              title: Sponge Attack Detected
              example: false
            compliance_mapping:
              type: object
              title: Compliance Mapping
              description: Mapping of detection to regulatory compliance frameworks
              properties:
                owasp_llm_2025:
                  type: array
                  items:
                    type: string
                  title: OWASP LLM Top 10 2025
                mitre_atlas:
                  type: array
                  items:
                    type: string
                  title: MITRE ATLAS
                nist_ai_rmf:
                  type: array
                  items:
                    type: string
                  title: NIST AI Risk Management Framework
                eu_ai_act:
                  type: array
                  items:
                    type: string
                  title: EU AI Act
                iso_iec_standards:
                  type: array
                  items:
                    type: string
                  title: ISO/IEC Standards
    Rule:
      title: Rule
      type: object
      properties:
        id:
          title: Id
          type: string
          example: priv-1
        display_text:
          title: Display Text
          type: string
          example: No individualized investment advice
        text:
          title: Text
          type: string
          example: The assistant must not provide individualized investment advice.
        risk_category:
          title: Risk Category
          type: string
          example: legal_ip_liability
          enum:
            - security_fraud
            - safety_harm
            - privacy_data_protection
            - brand_reputation_trust
            - bias_fairness_ethical
            - legal_ip_liability
            - product_misuse_abuse
            - performance_reliability_quality
        applicability:
          title: Applicability
          type: string
          example: assistant
          enum:
            - assistant
            - user
            - user_assistant
        severity:
          title: Severity
          type: string
          example: medium
          enum:
            - critical
            - high
            - medium
            - low
        frameworks:
          title: Frameworks
          type: array
          items:
            type: string
            enum:
              - hipaa
              - finra
              - gdpr
              - ccpa
              - owasp_llm_2025
              - nist_ai_rmf
              - eu_ai_act
              - iso_42001
        mappings:
          title: Mappings
          type: array
          items:
            type: object
            properties:
              framework:
                type: string
              clause:
                type: string
        source:
          title: Source
          type: string
          example: document
          enum:
            - document
            - catalog
            - document/catalog
            - user
        suggested:
          title: Suggested
          type: boolean
          example: false
      required:
        - id
        - text
        - risk_category
        - applicability
        - severity
        - source
        - suggested
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: apikey

````

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