Skip to main content
POST
Guard Content

Authorizations

X-API-Key
string
header
required

PromptGuard API key for developer endpoints. Keys start with pg_live_ and are created in the dashboard.

Headers

x-api-key
string | null

Body

application/json

Request body for the guard endpoint.

messages
GuardMessage · object[]
required

Messages to scan (OpenAI-style message array)

Required array length: 1 - 512 elements
direction
string
default:input

Scan direction: 'input' (pre-LLM) or 'output' (post-LLM)

Pattern: ^(input|output)$
model
string | null

Model being used (for logging)

context
GuardContext · object | null

Optional framework context

retrieved_context
ContextDoc · object[] | null

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.

Maximum array length: 32
media
MediaPartSchema · object[] | null

Media attachments to scan for steganographic payloads, adversarial patches, and font injection. Optional.

Maximum array length: 8

Response

Successful Response

Response from the guard endpoint.

decision
string
required

Policy decision: 'allow', 'block', or 'redact'

event_id
string
required

Unique event identifier for tracking

confidence
number
required

Confidence score of the decision

latency_ms
number
required

Processing time in milliseconds

weighted_score
number | null

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
string | null

Primary threat type detected

redacted_messages
GuardMessage · object[] | null

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.

threats
ThreatDetail · object[]

Detailed threat breakdown

unscanned
UnscannedAttachment · object[]

Parts that reached us and produced nothing to scan. 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 (an entry in context.tool_calls in none of the shapes we can read — index is its position in that list).