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

# Guard Content

> Scan messages for security threats without proxying to an LLM.

This is the primary endpoint for auto-instrumentation and framework
callback integrations. It runs the same policy engine, ML ensemble,
preset configuration, custom rules, and entitlements checks as the
proxy pipeline.

Use ``direction="input"`` before sending messages to the LLM and
``direction="output"`` after receiving a response.

Returns a decision of ``allow``, ``block``, or ``redact`` along with
detailed threat information and optional redacted messages.

Guide: [Guard API](https://docs.promptguard.co/api-reference/guard)



## OpenAPI

````yaml /api-reference/openapi-developer.json post /api/v1/guard
openapi: 3.1.0
info:
  title: PromptGuard Developer API
  description: >-
    Public API for developers to integrate PromptGuard security into their
    applications
  version: 1.0.0
servers:
  - url: https://api.promptguard.co
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/v1/guard:
    post:
      tags:
        - guard
      summary: Guard Content
      description: |-
        Scan messages for security threats without proxying to an LLM.

        This is the primary endpoint for auto-instrumentation and framework
        callback integrations. It runs the same policy engine, ML ensemble,
        preset configuration, custom rules, and entitlements checks as the
        proxy pipeline.

        Use ``direction="input"`` before sending messages to the LLM and
        ``direction="output"`` after receiving a response.

        Returns a decision of ``allow``, ``block``, or ``redact`` along with
        detailed threat information and optional redacted messages.

        Guide: [Guard API](https://docs.promptguard.co/api-reference/guard)
      operationId: guard_content_api_v1_guard_post
      parameters:
        - name: X-End-User
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Your end user's id. Attributes the event to them on the End Users
              page, and with context.session_id names one session.
            title: X-End-User
          description: >-
            Your end user's id. Attributes the event to them on the End Users
            page, and with context.session_id names one session.
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GuardRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuardResponse'
              example:
                decision: block
                event_id: 74d7d17b-eef7-4431-be48-cbb3e2392584
                confidence: 0.81
                weighted_score: null
                threat_type: data_exfiltration
                redacted_messages: null
                threats:
                  - type: data_exfiltration
                    confidence: 0.81
                    details: >-
                      Data exfiltration attempt: Data exfiltration attempt
                      detected (rule d763c3b4)
                    weighted_score: null
                    technique: context-exfiltration.system-prompt-leak
                    rule:
                      detector: exfiltration
                      id: show_system_prompt
                      suppressible: true
                    segment: null
                    status: active
                    threshold: null
                    flagged: false
                    match_sha256: >-
                      2fb2b1a07e62a8a9fab2e923f0dc5e49f6595905da4b7d4c27b66b030fa5bdde
                flagged: false
                detectors_agreeing: 3
                basis: detectors
                latency_ms: 116.28
                unscanned: []
                unavailable: []
                entitlement:
                  plan: pro
                  seats: 1
                  scans_used: 345
                  scan_allowance: 100000
                  mode: full
                  as_of: '2026-10-31T15:50:30.863343Z'
        '401':
          description: Missing, malformed, unknown, disabled or expired API key
          content:
            application/json:
              examples:
                missing_api_key:
                  summary: No X-API-Key header
                  value:
                    error:
                      message: >-
                        PromptGuard API key required. Please provide via
                        X-API-Key header.
                      type: authentication_error
                      code: missing_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#missing_api_key
                malformed_api_key:
                  summary: Not a pg_live_ key
                  value:
                    error:
                      message: Invalid API key format
                      type: authentication_error
                      code: invalid_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#invalid_api_key
                unknown_api_key:
                  summary: No such key
                  value:
                    error:
                      message: Invalid API key
                      type: authentication_error
                      code: invalid_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#invalid_api_key
                disabled_api_key:
                  summary: Key disabled
                  value:
                    error:
                      message: API key is disabled
                      type: authentication_error
                      code: disabled_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#disabled_api_key
                expired_api_key:
                  summary: Key expired
                  value:
                    error:
                      message: API key has expired
                      type: authentication_error
                      code: expired_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#expired_api_key
              schema:
                $ref: '#/components/schemas/AuthErrorEnvelope'
        '403':
          description: >-
            Refused by the key's scopes or the IP allowlist, or by a project
            access list
          content:
            application/json:
              examples:
                scope_denied:
                  summary: The key's scopes exclude this endpoint
                  value:
                    error:
                      message: >-
                        This endpoint needs the `scan:write` scope, which this
                        API key does not hold. Create a key that includes it, or
                        use an unrestricted key.
                      type: insufficient_scope
                      code: scope_denied
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#scope_denied
                scan_only_credential:
                  summary: A scan-only device credential
                  value:
                    error:
                      message: This credential is scan-only; endpoint not permitted.
                      type: insufficient_scope
                      code: scope_denied
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#scope_denied
                read_only_key:
                  summary: A SIEM export key
                  value:
                    error:
                      message: >-
                        This is a read-only export key. It may only GET
                        /api/v1/alerts, /api/v1/audit-events,
                        /api/v1/audit-events/stream, /api/v1/interactions and
                        /api/v1/interactions/stream.
                      type: insufficient_scope
                      code: read_only_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#read_only_key
                ip_not_allowed:
                  summary: Caller IP outside the allowlist
                  value:
                    error:
                      message: Request IP is not in the organization's allowlist
                      type: permission_error
                      code: ip_not_allowed
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#ip_not_allowed
                ip_allowlist_error:
                  summary: Allowlist could not be checked
                  value:
                    error:
                      message: IP allowlist validation failed
                      type: permission_error
                      code: ip_allowlist_error
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#ip_allowlist_error
                access_list_block:
                  summary: access_list_block
                  value:
                    error:
                      message: Blocked by access list (ip=203.0.113.7)
                      type: access_denied
                      code: access_list_block
                      rule_id: 5b0c9a7e-2f1d-4c3b-9a8e-6d7f1e2a3b4c
                      target_type: ip
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#access_list_block
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorEnvelope'
        '429':
          description: >-
            Rate limit, monthly quota, the key's own monthly cap, spending
            limit, or an inactive subscription (branch on `error.code`)
          content:
            application/json:
              examples:
                rate_limit_exceeded:
                  summary: Per-minute limit reached
                  value:
                    error:
                      message: >-
                        Rate limit exceeded: your plan allows 60 requests per
                        minute. Please retry later.
                      type: rate_limit_exceeded
                      code: rate_limit_exceeded
                      retry_after: 42
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#rate_limit_exceeded
                api_key_request_cap_exceeded:
                  summary: This key's own monthly request cap reached
                  value:
                    error:
                      message: >-
                        This API key's monthly cap of 10,000 requests is
                        reached. It resets on December 1 (UTC). Raise or remove
                        the cap in the dashboard, or use another key.
                      type: quota_exceeded
                      code: api_key_request_cap_exceeded
                      requests_limit: 10000
                      resets_at: '2026-12-01T00:00:00+00:00'
                      retry_after: 1209600
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#api_key_request_cap_exceeded
                monthly_quota_exceeded:
                  summary: Monthly request quota spent
                  value:
                    error:
                      message: Monthly quota of 100,000 requests exceeded.
                      type: quota_exceeded
                      code: monthly_quota_exceeded
                      current_plan: pro
                      requests_used: 100000
                      requests_limit: 100000
                      upgrade_url: https://app.promptguard.co/dashboard/billing
                      retry_after: 1209600
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#monthly_quota_exceeded
                spending_limit_exceeded:
                  summary: Monthly spending limit reached
                  value:
                    error:
                      message: Monthly spending limit of $500.00 exceeded.
                      type: spending_limit_exceeded
                      code: spending_limit_exceeded
                      current_plan: scale
                      current_spending: 500.12
                      spending_limit: 500
                      settings_url: https://app.promptguard.co/dashboard/spending
                      retry_after: 1209600
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#spending_limit_exceeded
                subscription_inactive:
                  summary: Subscription not active; never retry
                  value:
                    error:
                      message: 'Your pro subscription is not active (status: past_due).'
                      type: subscription_inactive
                      code: subscription_inactive
                      current_plan: pro
                      subscription_status: past_due
                      reactivate_url: https://app.promptguard.co/dashboard/billing
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#subscription_inactive
              schema:
                anyOf:
                  - $ref: '#/components/schemas/RateLimitErrorEnvelope'
                  - $ref: '#/components/schemas/QuotaErrorEnvelope'
                  - $ref: '#/components/schemas/KeyRequestCapErrorEnvelope'
                  - $ref: '#/components/schemas/SubscriptionInactiveErrorEnvelope'
                title: Response 429 Guard Content Api V1 Guard Post
      externalDocs:
        description: 'Guide: Guard API'
        url: https://docs.promptguard.co/api-reference/guard
components:
  schemas:
    GuardRequest:
      properties:
        messages:
          items:
            $ref: '#/components/schemas/GuardMessage'
          type: array
          maxItems: 512
          minItems: 1
          title: Messages
          description: >-
            Messages to scan (OpenAI-style message array). When their text is
            more than one scan can read, the newest messages that fit are
            scanned and every older one is listed in `unscanned` as
            `over_size_budget`; only a newest message too large on its own is
            refused with 413.
        direction:
          type: string
          pattern: ^(input|output)$
          title: Direction
          description: 'Scan direction: ''input'' (pre-LLM) or ''output'' (post-LLM)'
          default: input
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: Model being used (for logging)
        context:
          anyOf:
            - $ref: '#/components/schemas/GuardContext'
            - type: 'null'
          description: Optional framework context
        retrieved_context:
          anyOf:
            - items:
                $ref: '#/components/schemas/ContextDoc'
              type: array
              maxItems: 32
            - type: 'null'
          title: Retrieved Context
          description: >-
            RAG-retrieved documents to scan for knowledge poisoning. Each
            document is scanned individually; the first poisoned one blocks the
            request, and its position and source are returned in the event
            metadata so you know which document to drop. Scanning stops at that
            point, so a request with several poisoned documents reports the
            first. Optional; backwards-compatible.
        media:
          anyOf:
            - items:
                $ref: '#/components/schemas/MediaPartSchema'
              type: array
              maxItems: 8
            - type: 'null'
          title: Media
          description: >-
            Media attachments to scan for steganographic payloads, adversarial
            patches, and font injection. Optional.
        images:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 8
            - type: 'null'
          title: Images
          description: >-
            Image URLs or `data:` URIs to scan, as LiteLLM's PromptGuard
            guardrail sends them. Scanned like an `image_url` block on a
            message.
        override:
          anyOf:
            - $ref: '#/components/schemas/GuardOverride'
            - type: 'null'
          description: >-
            A Shadow AI Device reporting an **Override**: the person sent a
            prompt the Device coached (a block that rested on one detector)
            anyway, with a reason. Sent with every message empty and nothing
            else to scan; any content is refused with 422. Recorded as an event
            with the decision `override`, its threat type and the reason,
            alerted on like a block and delivered to the SIEM, and not metered.
            The answer is `allow`: nothing was scanned.
        agreement:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Agreement
          description: >-
            Count how many independent detectors agree on a `block`. With
            `true`, a confident finding is put to the rest of the detectors for
            a second opinion and `detectors_agreeing` counts them, at the cost
            of the ML layer's latency on every such block. With `false`, the
            scan stops at its first detection and asks no second opinion, so
            `detectors_agreeing` counts only the detectors that had found the
            threat when the scan decided. The decision, threat type and deciding
            rule are the same either way. Left out (or `null`), agreement is
            counted, and the response carries `Deprecation` and `Sunset`
            headers: from 2027-02-11 leaving it out means `false`. A Shadow AI
            Device's credential always counts.
        device_findings:
          anyOf:
            - items:
                $ref: '#/components/schemas/DeviceFinding'
              type: array
              maxItems: 37
            - type: 'null'
          title: Device Findings
          description: >-
            What the calling Device's own masker caught before sending, as
            `{category, count}` pairs, never the values. `category` is one of
            the threat types this API returns (e.g. `api_key_leak`, `pii_leak`)
            and appears at most once; `count` is a positive integer. Any other
            key is rejected with 422. Recorded on this request's event,
            attributed to the Device, and shown in the fleet views; it does not
            change the decision. A block an injection model decided on a request
            whose findings include a secret is reported as that secret
            (`threat_type` `secret_key_leak` or `api_key_leak`), with the
            model's verdict kept as a finding that did not decide. Optional;
            clients that omit it are unaffected.
      type: object
      required:
        - messages
      title: GuardRequest
      description: Request body for the guard endpoint.
    GuardResponse:
      properties:
        decision:
          type: string
          title: Decision
          description: 'Policy decision: ''allow'', ''block'', or ''redact'''
        event_id:
          type: string
          title: Event Id
          description: Unique event identifier for tracking
        dashboard_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Dashboard Url
          description: >-
            The dashboard page of the event this decision recorded, in its
            project: the page the proxy names in `x-promptguard-dashboard-url`.
            Null when no event was recorded (a `pgshadow doctor` probe is
            answered but not recorded), so there is no page to open.
        confidence:
          type: number
          title: Confidence
          description: Confidence score of the decision
        weighted_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Weighted Score
          description: >-
            Aggregate decision-driving score (severity * confidence, clamped to
            [0, 1]) when a severity-carrying detector decided the verdict; null
            otherwise. Raw confidence stays in the `confidence` field.
        threat_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Threat Type
          description: Primary threat type detected
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
          description: >-
            Why the decision was reached, in the words the event records: the
            reason the dashboard shows for it (unless the project keeps no
            content, when the event keeps only the threat type). Free text, and
            it may quote what was found. A client that tells a person why a
            request was stopped names this and `threat_type`, not a finding of
            its own, so the person and the dashboard give one explanation. Null
            on an `allow` that found nothing, and on any response from an Engine
            older than this field.
        redacted_messages:
          anyOf:
            - items:
                $ref: '#/components/schemas/GuardMessage'
              type: array
            - type: 'null'
          title: Redacted Messages
          description: >-
            Redacted messages (only present when decision='redact'). Always the
            TEXT projection: a message sent as content blocks comes back as a
            string. Attachments are never rewritten, we do not re-encode a PDF
            with the secret removed, and returning one that looked redacted
            would be worse than returning none. A message listed in `unscanned`
            as `over_size_budget` was not read, so it comes back as its text,
            unredacted.
        threats:
          items:
            $ref: '#/components/schemas/ThreatDetail'
          type: array
          title: Threats
          description: Detailed threat breakdown
        flagged:
          type: boolean
          title: Flagged
          description: >-
            True when a finding flagged: allowed, reported, not enforced. The
            flagged findings are in `threats` with `flagged: true`, each with
            its threat type and rule. `decision` stays `allow` for a flag that
            decided, so a client that does not read this field lets the traffic
            through as before; on a `block` or `redact` it says a flag was also
            found. The event is stored with the decision `flag`.
          default: false
        detectors_agreeing:
          type: integer
          title: Detectors Agreeing
          description: >-
            On a `block`, how many independent detectors found the threat that
            decided it: 1 when one detector's verdict alone decided, 2 or more
            when others agreed. Counted by detector, not rule. 0 on anything but
            a `block`. A Shadow AI Device coaches rather than blocks a block
            resting on one detector (`basis` `detectors` and 1 here): the person
            may send it anyway, with a reason.
          default: 0
        basis:
          anyOf:
            - type: string
              enum:
                - secret
                - organisation_rule
                - detectors
            - type: 'null'
          title: Basis
          description: >-
            On a `block`, what it rests on: `secret` (a credential),
            `organisation_rule` (a policy, rule or pattern the organisation
            wrote), or `detectors` (the built-in detectors, as many as
            `detectors_agreeing` says). Null on anything but a `block`.
        latency_ms:
          type: number
          title: Latency Ms
          description: Processing time in milliseconds
        unscanned:
          items:
            $ref: '#/components/schemas/UnscannedAttachment'
          type: array
          title: Unscanned
          description: >-
            Parts that reached us and were not read: they produced nothing to
            scan, or the scan budget was spent first. An `allow` with a
            non-empty `unscanned` is NOT 'this content is clean', it is 'the
            text was clean and these parts were never read'. Reasons: url_only
            (we do not fetch caller-supplied URLs, that would be an SSRF
            primitive), file_id_unsupported, encrypted, no_text_extracted (a
            scanned/rasterised document), too_large, undecodable,
            unsupported_type, extractor_unavailable, unsupported_block,
            unsupported_tool_call (a tool call in none of the shapes we can
            read: `index` is its position among the request's tool calls),
            over_size_budget (a message older than the newest ones that filled
            the scan budget: `index` is its position in `messages`; it was not
            read on this call, and was the newest turn of an earlier one).
        unavailable:
          items:
            $ref: '#/components/schemas/UnavailableCheck'
          type: array
          title: Unavailable
          description: >-
            Unavailable checks: detectors this scan would have run but the
            deployment cannot, because their backing service (an ML inference
            endpoint, an LLM judge, a bundled model) is not configured. An
            `allow` with a non-empty `unavailable` is NOT 'every check passed',
            these detectors never looked. A detector that ran and found nothing
            is not listed, and neither is one the project's plan or guardrail
            settings leave out.
        skipped:
          items:
            $ref: '#/components/schemas/SkippedMatch'
          type: array
          title: Skipped
          description: >-
            Matches deliberately not redacted, one entry per match, in the order
            found; an empty list when there were none. The text of a skipped
            match is left as it was. Reported for the text the scan's PII pass
            read; empty when the Project's guardrails run none.
          examples:
            - - reason: reserved_domain
                type: email
        requests_counted:
          type: integer
          title: Requests Counted
          description: >-
            How many Requests this call counted as toward the monthly allowance:
            1 for a scan, whatever its length. 0 for a call that is not a scan:
            a findings-only report, a doctor probe or an Override.
          default: 0
        billed_tokens:
          type: integer
          title: Billed Tokens
          description: >-
            The tokens of content this call scanned, counted with the
            `cl100k_base` tokenizer whatever model the content is for: each
            scanned text is encoded on its own and the counts are added. What is
            scanned is the messages read with their tool calls, retrieved
            context and Tool definitions; for a Shadow AI Device, the Current
            turn, the Instructions and the Tool definitions not already checked,
            never an Earlier turn. Reported, not yet charged for. 0 for a call
            that is not a scan.
          default: 0
        detection_level:
          type: string
          const: deep
          title: Detection Level
          description: >-
            The Detection level this call ran at: always `deep`, every detector
            including the LLM judges. Every plan runs the full engine and is
            billed at one list price, per call and per Billed token.
          default: deep
        entitlement:
          anyOf:
            - $ref: '#/components/schemas/GuardEntitlement'
            - type: 'null'
          description: >-
            What this account is entitled to, at the instant this scan was
            answered. Null when the engine cannot say, an account with no
            subscription row, an admin key that bypasses the counter, or a row
            it could not read. Null is 'unknown', NOT 'unentitled': a client
            that reads it as a limit has invented a refusal the engine never
            made.
      type: object
      required:
        - decision
        - event_id
        - confidence
        - latency_ms
      title: GuardResponse
      description: Response from the guard endpoint.
    AuthErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
          examples:
            - code: missing_api_key
              message: >-
                PromptGuard API key required. Please provide via X-API-Key
                header.
              type: authentication_error
      type: object
      required:
        - error
      title: AuthErrorEnvelope
    ErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
      title: ErrorEnvelope
    ValidationErrorEnvelope:
      description: The developer API's 422 (`shared/infrastructure/framework_errors.py`).
      properties:
        error:
          $ref: '#/components/schemas/ValidationErrorDetail'
        detail:
          deprecated: true
          description: >-
            The same list as `error.details`, in FastAPI's old shape. Removed on
            2027-02-11; read `error.details`
          items:
            $ref: '#/components/schemas/ValidationErrorField'
          title: Detail
          type: array
      required:
        - error
        - detail
      title: ValidationErrorEnvelope
      type: object
      example:
        error:
          message: 'The request is invalid: body.messages: Field required'
          type: invalid_request_error
          code: invalid_request
          details:
            - type: missing
              loc:
                - body
                - messages
              msg: Field required
              input:
                direction: input
          error_id: 3f0b8c1e-6a0e-4d52-9a57-0c2a9a7f5b11
          doc_url: >-
            https://docs.promptguard.co/production/error-handling#invalid_request
        detail:
          - type: missing
            loc:
              - body
              - messages
            msg: Field required
            input:
              direction: input
    RateLimitErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/RateLimitErrorDetail'
      type: object
      required:
        - error
      title: RateLimitErrorEnvelope
    QuotaErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/QuotaErrorDetail'
      type: object
      required:
        - error
      title: QuotaErrorEnvelope
    KeyRequestCapErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/KeyRequestCapErrorDetail'
      type: object
      required:
        - error
      title: KeyRequestCapErrorEnvelope
    SubscriptionInactiveErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/SubscriptionInactiveErrorDetail'
      type: object
      required:
        - error
      title: SubscriptionInactiveErrorEnvelope
    GuardMessage:
      properties:
        role:
          type: string
          title: Role
          description: >-
            Message role: system, user, assistant, tool. On an input scan a tool
            (or function) message is also scanned as a tool's result, and an
            instruction planted in it blocks as prompt_injection.
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Content
          description: >-
            Message text, or an OpenAI/Anthropic content-block array.
            Attachments carried in blocks are extracted and scanned like any
            other text; blocks we cannot read are listed in `unscanned`.
          default: ''
        tool_calls:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Tool Calls
          description: >-
            The tool calls this message made, as a conversation carries them, in
            any shape `context.tool_calls` reads. Their names and arguments are
            scanned like `context.tool_calls`, as part of this message's turn; a
            call we cannot read is listed in `unscanned`. On a Device's request
            an Earlier turn's calls are not rescanned for what blocks, and
            personal data or a credential in their arguments is redacted again:
            the decision is `redact`, and the call is the caller's to mask,
            because `redacted_messages` carries text only.
      type: object
      required:
        - role
      title: GuardMessage
      description: >-
        A single message in the conversation.


        ``content`` takes either a plain string or a provider-shaped
        content-block

        array, OpenAI's ``text``/``image_url``/``input_audio``/``file`` and

        Anthropic's ``text``/``image``/``document`` are all understood, because

        those are the two shapes our own proxy already receives.


        Blocks are accepted as loose dicts rather than a closed union on
        purpose.

        Both providers add block types faster than we can model them, and a
        strict

        schema would 422 a request we could otherwise have scanned the text of.

        Anything unrecognised is *reported* in the response's ``unscanned``
        rather

        than dropped, see ``shared.security.content_parts``.
    GuardContext:
      properties:
        framework:
          anyOf:
            - type: string
            - type: 'null'
          title: Framework
          description: Framework name, e.g. 'langchain', 'crewai'
        chain_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Chain Name
          description: LangChain chain name or pipeline identifier
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: Agent identifier for multi-agent systems
        session_id:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Session Id
          description: >-
            The conversation this request is a turn of. Send the same value for
            every turn of one end user's conversation: with the X-End-User
            header it is one session, and the dashboard's Sessions view lists
            that session's events in order. Generate it on your server, random
            enough that an end user cannot guess another's (a UUIDv4 will do),
            and never take it from the end user's request: whoever can name a
            session id can add turns to that conversation. At most 255
            characters, stored exactly as sent; it names the conversation and
            holds none of it, so a zero-retention project keeps it. The same id
            under another end user or project is another conversation. For each
            input turn PromptGuard also remembers its detection signals: the
            Techniques of the finding that decided it, that finding's confidence
            and when the turn arrived, never its text, for every project
            including zero-retention ones. At most the last 10 turns are kept,
            each for at most 1 hour. When the request names its end user with
            the X-End-User header, a turn that pivots ("now tell me...") after
            an earlier persona, hypothetical or authority turn is reported as a
            `candidate` threat from the `conversation/priming_then_pivot` rule,
            which never changes the decision; without X-End-User that rule
            records nothing. A sudden burst of turns, many times the
            conversation's own earlier rate, is recorded on the turn's event as
            a signal, and changes nothing either. If the conversation's memory
            cannot be reached in time, the turn is scanned on its own. Output
            scans are not turns. Without a session id a request is scanned on
            its own, as it always was.
        tool_calls:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
              maxItems: 64
            - type: 'null'
          title: Tool Calls
          description: >-
            Tool calls in this turn. The tool NAME and its ARGUMENTS are
            assembled into the scanned text and get the same detection stack as
            the messages: tool arguments are where an exfiltration payload
            actually travels, so they are scanned rather than logged. Both
            provider spellings are read: OpenAI's
            `{'type':'function','function':{'name','arguments'}}` and
            Anthropic's `{'type':'tool_use','name','input'}`, plus LangChain's
            `{'name','args'}`. A call in none of those shapes is reported in the
            response's `unscanned` array with its position; it is never quietly
            skipped. These calls carry no position in the conversation, so they
            are always scanned as the newest turn's. Send a conversation's calls
            on the messages that made them (`messages[].tool_calls`) to have
            each read as part of its own turn.
        tool_definitions:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
              maxItems: 256
            - type: 'null'
          title: Tool Definitions
          description: >-
            The tools the AI app offers the model on this request: each one's
            name, description and input schema. Each is scanned as a tool
            manifest -- the scan `POST /api/v1/mcp/manifest-scan` runs, for
            poisoned descriptions and parameter docs and smuggled Unicode -- and
            a poisoned one blocks, naming the tool, with the finding's `segment`
            `tool_definition`. An unchanged definition is not scanned again on
            the next request. Read in MCP's
            `{'name','description','inputSchema'}`, Anthropic's `input_schema`
            and OpenAI's
            `{'type':'function','function':{'name','description','parameters'}}`;
            a definition in none of them is listed in `unscanned` with its
            position.
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Arbitrary framework-specific metadata (not scanned)
      type: object
      title: GuardContext
      description: >-
        Optional rich context from framework integrations.


        Only ``tool_calls`` is scanned. The rest is descriptive, it labels the

        event for the dashboard and the audit log, and does not reach a
        detector.
    ContextDoc:
      properties:
        content:
          type: string
          maxLength: 100000
          title: Content
          description: Document text content
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
          description: Source identifier (URL, doc ID, etc.)
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Extra metadata
      type: object
      required:
        - content
      title: ContextDoc
      description: A document retrieved by a RAG pipeline to be scanned for poisoning.
    MediaPartSchema:
      properties:
        type:
          type: string
          pattern: ^(image|audio|document)$
          title: Type
          description: 'Media type: ''image'', ''audio'' or ''document'''
        mime_type:
          type: string
          title: Mime Type
          description: MIME type, e.g. 'image/png', 'audio/wav'
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
          description: URL to fetch the media from
        base64:
          anyOf:
            - type: string
            - type: 'null'
          title: Base64
          description: Base64-encoded media data
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Extra metadata
      type: object
      required:
        - type
        - mime_type
      title: MediaPartSchema
      description: >-
        A media attachment to be scanned for steganographic/adversarial
        payloads.
    GuardOverride:
      properties:
        reference:
          type: string
          pattern: ^C-[0-9A-F]{8}$
          title: Reference
          description: The Device's coaching reference for the prompt, e.g. `C-1A2B3C4D`.
        reason:
          type: string
          maxLength: 500
          title: Reason
          description: >-
            The reason the person gave, masked on the Device and masked again
            here like a preview. Empty when the Device's Disclosure sends no
            prompt content.
          default: ''
        threat_type:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Threat Type
          description: >-
            What the coached block was for, as this API names threat types. One
            it does not know is not stored.
        engine_event_id:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Engine Event Id
          description: >-
            The event the coached block was recorded as, when the Engine decided
            it.
      type: object
      required:
        - reference
      title: GuardOverride
      description: A Shadow AI Device's report that a person sent a coached prompt anyway.
    DeviceFinding:
      properties:
        category:
          $ref: '#/components/schemas/ThreatType'
          description: The Engine's threat category, e.g. 'api_key_leak' or 'pii_leak'.
        count:
          type: integer
          maximum: 100000
          minimum: 1
          title: Count
          description: How many values of this category the masker replaced.
      additionalProperties: false
      type: object
      required:
        - category
        - count
      title: DeviceFinding
      description: One category the Device's masker caught, and how many times.
    ThreatDetail:
      properties:
        type:
          type: string
          title: Type
        confidence:
          type: number
          title: Confidence
        details:
          type: string
          title: Details
        weighted_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Weighted Score
          description: >-
            severity_score * confidence, clamped to [0, 1]. The decision-driving
            number when a severity-carrying detector (e.g. structural
            heuristics) fired; null when confidence alone is the signal.
        technique:
          anyOf:
            - type: string
            - type: 'null'
          title: Technique
          description: >-
            The attack technique an injection or jailbreak finding belongs to,
            as ATR names it: a dotted category and subcategory such as
            `prompt-injection.persona-hijacking`. When several findings
            disagree, the highest-scoring one names it. Null for a finding that
            is not an attack, such as redacted PII.
        rule:
          anyOf:
            - $ref: '#/components/schemas/FindingRule'
            - type: 'null'
          description: >-
            The detector and rule that made this finding, the pair a Suppression
            is keyed on. On a block, the rule that decided.
        segment:
          anyOf:
            - type: string
            - type: 'null'
          title: Segment
          description: >-
            The part of the request the finding came from. On a Shadow AI
            Device's scan: `current_turn` (the person's new message, its tool
            results and the tool calls they answer), `earlier_turn` (a turn
            already sent, redacted again because the app resends it), or
            `instructions` (the app's system or developer prompt, scanned for
            secrets only). On any caller's scan: `tool_definition`, for an entry
            of `context.tool_definitions`. Null otherwise.
        status:
          $ref: '#/components/schemas/FindingStatus'
          description: >-
            Whether this finding decides. `active`: it does, and is what
            `decision`, `confidence` and `threat_type` report. `candidate`: a
            Candidate rule matched. It is recorded so the rule can be measured
            on live traffic, and it never changes the decision, the score or the
            threat type; a `candidate` threat can appear on an `allow`.
            `suppressed`: one of the project's Suppressions silenced the rule,
            so it is recorded and decides nothing, and another rule may decide
            instead. Decide on `decision`, never on whether `threats` is empty.
          default: active
        threshold:
          anyOf:
            - $ref: '#/components/schemas/AppliedThreshold'
            - type: 'null'
          description: >-
            The warn and block thresholds this finding's score was compared
            with, when the project set them for its detector (#970): which band
            it fell in, both thresholds and the score. A `warn` band finding
            appears on an `allow`: it was reported, not enforced. Null when the
            detector has no thresholds configured and decided as it always has,
            and on a finding that did not decide.
        flagged:
          type: boolean
          title: Flagged
          description: >-
            True when this finding flagged: it was reported and not enforced. A
            warn band raised it (`threshold` says so), a custom policy rule or
            LLM guard whose action is `flag`, an agentic judge's `flag`, or a
            detector in `flag` mode. A flagged finding can sit beside the
            `block` or `redact` that decided; it never changes `decision`.
          default: false
        match_sha256:
          anyOf:
            - type: string
            - type: 'null'
          title: Match Sha256
          description: >-
            Lowercase hex SHA-256 of the UTF-8 text this finding's rule matched:
            the `match_sha256` a Suppression names to silence the rule for that
            text only. Null when the rule cannot be suppressed, or the finding
            has no one matched text (a redaction by type).
      type: object
      required:
        - type
        - confidence
        - details
      title: ThreatDetail
      description: Individual threat found during scanning.
    UnscannedAttachment:
      properties:
        index:
          type: integer
          title: Index
          description: >-
            Position within the list the reason names, the combined attachment
            list; the request's tool calls for `unsupported_tool_call`
            (`context.tool_calls` first, then each message's in order);
            `messages` for `over_size_budget`. -1 when the part has no position,
            which is every `unsupported_block`.
        reason:
          type: string
          title: Reason
          description: Stable machine-readable code
        detail:
          type: string
          title: Detail
          description: Reason with any extra qualifier, e.g. 'no_text_extracted:pages=3'
      type: object
      required:
        - index
        - reason
        - detail
      title: UnscannedAttachment
      description: One part of the request we could not read, and why.
    UnavailableCheck:
      properties:
        detector:
          type: string
          title: Detector
          description: Stable detector name, e.g. 'jailbreak_judge'.
        reason:
          type: string
          title: Reason
          description: >-
            Why it cannot run: ml_inference_off (ML_INFERENCE_MODE=off),
            ml_inference_not_configured (no inference endpoint or token),
            ml_inference_mode_unsupported (a mode this detector does not
            implement), llm_judge_not_configured (no LLM judge endpoint),
            model_not_bundled (an in-process model artifact is missing).
      type: object
      required:
        - detector
        - reason
      title: UnavailableCheck
      description: One detector the deployment cannot run, and why.
    SkippedMatch:
      properties:
        type:
          type: string
          title: Type
          description: The detector type of the match, e.g. `email`.
        reason:
          type: string
          title: Reason
          description: >-
            Why it was left in the text, a stable code. `reserved_domain`: an
            email at a domain reserved for documentation and testing by RFC 2606
            and RFC 6761 (`example.com`, `example.net`, `example.org`, and any
            domain ending `.example`, `.test`, `.invalid` or `.localhost`),
            which cannot be a person's address. Test redaction with an address
            at a real-looking domain. A client that does not recognise a code
            must still treat the match as left in the text.
          examples:
            - reserved_domain
      type: object
      required:
        - type
        - reason
      title: SkippedMatch
      description: One match a detector found and deliberately did not act on.
    GuardEntitlement:
      properties:
        plan:
          type: string
          title: Plan
          description: Plan identifier, e.g. 'free', 'shadow_team'
        seats:
          type: integer
          title: Seats
          description: >-
            Seats on the subscription, mirrored from the Stripe quantity. Always
            1 on a flat-rate Plan, which does not bill per seat.
        scans_used:
          type: integer
          title: Scans Used
          description: >-
            Scans counted against the org's pool this month, INCLUDING the one
            being answered.
        scan_allowance:
          type: integer
          title: Scan Allowance
          description: >-
            The month's pool. The enforced figure, not one recomputed from the
            Plan grid, so it carries a per-contract override where one exists.
        mode:
          type: string
          title: Mode
          description: >-
            How the client should run: 'full' while the engine arbitrates, or
            'redact_only' once the entitlement is spent or lapsed, where an
            on-device detection masks rather than refuses. A client that does
            not recognise the value must treat it as unknown and keep running as
            it was, never as a default.
        as_of:
          type: string
          format: date-time
          title: As Of
          description: When this reading was taken (UTC). Not the scan's timestamp.
      type: object
      required:
        - plan
        - seats
        - scans_used
        - scan_allowance
        - mode
        - as_of
      title: GuardEntitlement
      description: >-
        What the calling account is entitled to, as the engine knew it here.


        Composed from the same subscription row the scan was just counted
        against,

        so it cannot be stale while a scan is in flight. Why it rides the scan

        response rather than an endpoint of its own, and why it carries no
        price,

        are ADR-0018; the reasoning lives there and not in four docstrings.
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error description
        type:
          type: string
          title: Type
          description: Error category, e.g. 'authentication_error'
        code:
          type: string
          title: Code
          description: Machine-readable error code
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
      title: ErrorDetail
    ValidationErrorDetail:
      properties:
        message:
          description: The failed fields, one line
          title: Message
          type: string
        type:
          description: '''invalid_request_error'''
          title: Type
          type: string
        code:
          description: '''invalid_request'''
          title: Code
          type: string
        details:
          description: Each field that failed
          items:
            $ref: '#/components/schemas/ValidationErrorField'
          title: Details
          type: array
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Equals the X-Request-ID header
          title: Error Id
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
          title: Doc Url
      required:
        - message
        - type
        - code
        - details
      title: ValidationErrorDetail
      type: object
    ValidationErrorField:
      description: One field that failed validation, as FastAPI reports it.
      properties:
        loc:
          description: The field's path, e.g. ['body', 'messages']
          items:
            anyOf:
              - type: string
              - type: integer
          title: Loc
          type: array
        msg:
          description: What is wrong with it
          title: Msg
          type: string
        type:
          description: The kind of failure, e.g. 'missing'
          title: Type
          type: string
        input:
          default: null
          description: The value that was sent
          title: Input
        ctx:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          description: The limit it broke, where there is one
          title: Ctx
      required:
        - loc
        - msg
        - type
      title: ValidationErrorField
      type: object
    RateLimitErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''rate_limit_exceeded'''
        code:
          type: string
          title: Code
          description: '''rate_limit_exceeded'''
        retry_after:
          type: integer
          title: Retry After
          description: Seconds until the window resets; also `Retry-After`
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - retry_after
      title: RateLimitErrorDetail
    QuotaErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''quota_exceeded'' or ''spending_limit_exceeded'''
        code:
          type: string
          title: Code
          description: '''monthly_quota_exceeded'' or ''spending_limit_exceeded'''
        current_plan:
          type: string
          title: Current Plan
        requests_used:
          type: integer
          title: Requests Used
        requests_limit:
          anyOf:
            - type: integer
            - type: 'null'
          title: Requests Limit
          description: >-
            The month's Request allowance; null on a Plan sold in usage credit
            (ADR-0041), which reports `credit_*` instead
        credit_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Credit Usd
          description: The month's usage credit at list prices, in US dollars
        credit_used_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Credit Used Usd
          description: What this month's Requests cost at list prices, in US dollars
        credit_remaining_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Credit Remaining Usd
          description: The month's usage credit not yet spent, in US dollars
        upgrade_url:
          type: string
          title: Upgrade Url
        retry_after:
          anyOf:
            - type: integer
            - type: 'null'
          title: Retry After
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - current_plan
        - requests_used
        - requests_limit
        - upgrade_url
      title: QuotaErrorDetail
    KeyRequestCapErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''quota_exceeded'''
        code:
          type: string
          title: Code
          description: '''api_key_request_cap_exceeded'''
        requests_limit:
          type: integer
          title: Requests Limit
          description: The key's monthly Request cap
        resets_at:
          type: string
          title: Resets At
          description: 'When the cap resets: the first of next month, UTC'
        retry_after:
          type: integer
          title: Retry After
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - requests_limit
        - resets_at
        - retry_after
      title: KeyRequestCapErrorDetail
      description: >-
        One key past its own monthly Request cap (#1111), not the account's
        quota.


        Deliberately not ``QuotaErrorDetail``: nothing about the Plan was
        exceeded,

        so it names no Plan and offers no upgrade. The account's other keys are

        still served.
    SubscriptionInactiveErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''subscription_inactive'''
        code:
          type: string
          title: Code
          description: '''subscription_inactive'''
        current_plan:
          type: string
          title: Current Plan
        subscription_status:
          type: string
          title: Subscription Status
          description: >-
            e.g. 'cancelled', 'past_due', 'paused'; 'none' where no plan covers
            the key's organization at all
        reactivate_url:
          type: string
          title: Reactivate Url
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - current_plan
        - subscription_status
        - reactivate_url
      title: SubscriptionInactiveErrorDetail
      description: >-
        A refusal for the subscription's state, not for a spent quota.


        Deliberately not ``QuotaErrorDetail``: it carries no ``requests_used`` /

        ``requests_limit`` (nothing was exceeded -- reporting them beside this

        message is the contradiction #565 was filed for), no ``retry_after``

        (waiting does not fix it), and no ``on_demand_url`` (pay-as-you-go on a
        dead

        subscription is refused by design). One door, and it works.
    ThreatType:
      type: string
      enum:
        - prompt_injection
        - pii_leak
        - data_exfiltration
        - toxicity
        - api_key_leak
        - system_prompt_leak
        - policy_violation
        - fraud_abuse
        - malware
        - secret_key_leak
        - url_violation
        - malicious_entity
        - off_topic
        - mcp_violation
        - insecure_code
        - gibberish
        - language_violation
        - multi_turn_escalation
        - html_obfuscation
        - syntactic_masking
        - image_stego
        - image_adversarial
        - audio_stego
        - font_injection
        - dynamic_cloaking
        - framing_bias
        - critic_evasion
        - persona_hyperstition
        - rag_poisoning
        - memory_poisoning
        - few_shot_poisoning
        - sub_agent_spawning
        - compositional_fragment
        - sybil_attack
        - systemic_cascade
        - tacit_collusion
        - approval_fatigue
      title: ThreatType
      description: |-
        Types of threats detected.

        Originals (block 1) cover prompt injection, PII, toxicity, exfiltration,
        fraud, and malicious tool/MCP invocation.

        Block 2 (added 2026-04) covers the AI Agent Traps framework
        (Franklin et al., Google DeepMind 2025) -- six categories of
        environment-driven attacks against autonomous agents. Cross-link
        to the per-category remediation pages under apps/docs/security/.
    FindingRule:
      properties:
        detector:
          type: string
          title: Detector
          description: >-
            The detector that made the finding, e.g. `injection_regex`, `pii`,
            `ml_injection_classifier`. Stable across releases.
        id:
          type: string
          title: Id
          description: >-
            The rule of that detector that fired. Stable across releases: a
            detector that reports by type uses the type (`email` for `pii`), a
            pattern rule its declared name (`ignore_previous_instructions`), an
            ATR rule ATR's own id, and a detector with one verdict its own name.
        suppressible:
          type: boolean
          title: Suppressible
          description: >-
            Whether a Suppression may target this rule. False for the ML
            injection classifier and every model or LLM judge of injection, the
            secret detectors, canary tokens, and the project's own rules and MCP
            configuration. Other judges, such as content safety, can be.
      type: object
      required:
        - detector
        - id
        - suppressible
      title: FindingRule
      description: Which rule of which detector a finding is, as the API returns it.
    FindingStatus:
      type: string
      enum:
        - active
        - candidate
        - suppressed
      title: FindingStatus
      description: Whether a finding decides. Returned on every guard API threat.
    AppliedThreshold:
      properties:
        band:
          type: string
          enum:
            - warn
            - block
          title: Band
          description: >-
            `block`: the score reached `block`, and the finding blocked. `warn`:
            the score reached `warn` but not `block`, so the finding was
            reported and the request allowed (the event is stored as `flag`).
        warn:
          anyOf:
            - type: number
            - type: 'null'
          title: Warn
          description: >-
            The detector's warn threshold, or null when it has only a block
            band.
        block:
          type: number
          title: Block
          description: The detector's block threshold.
        score:
          type: number
          title: Score
          description: >-
            The score compared with the thresholds: the weighted score where the
            detector reports one, otherwise its confidence.
      type: object
      required:
        - band
        - warn
        - block
        - score
      title: AppliedThreshold
      description: The threshold a finding was decided against (#970).
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        PromptGuard API key for developer endpoints. Keys start with pg_live_
        and are created in the dashboard.

````

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