Skip to main content
POST
/
api
/
v1
/
guard
Guard Content
curl --request POST \
  --url https://api.promptguard.dev/api/v1/guard \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {
      "role": "<string>",
      "content": ""
    }
  ],
  "direction": "input",
  "model": "<string>",
  "context": {
    "framework": "<string>",
    "chain_name": "<string>",
    "agent_id": "<string>",
    "session_id": "<string>",
    "tool_calls": [
      {}
    ],
    "metadata": {}
  }
}
'
{
  "decision": "<string>",
  "event_id": "<string>",
  "confidence": 123,
  "latency_ms": 123,
  "threat_type": "<string>",
  "redacted_messages": [
    {
      "role": "<string>",
      "content": ""
    }
  ],
  "threats": [
    {
      "type": "<string>",
      "confidence": 123,
      "details": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

API Key authentication for developer endpoints (/api/v1/*). Use format: 'Bearer pg_api_your_key_here'

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)

Minimum array length: 1
direction
string
default:input

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

model
string | null

Model being used (for logging)

context
GuardContext · object

Optional framework context

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

threat_type
string | null

Primary threat type detected

redacted_messages
GuardMessage · object[] | null

Redacted messages (only present when decision='redact')

threats
ThreatDetail · object[]

Detailed threat breakdown