Scanning content

POST /v1/secure/scan screens a piece of content — a prompt, a tool call, or a model output — against your active rules and returns a verdict, the matched reasons, and a recommended action. Flagged or blocked content is recorded as an incident.

Requires scope secure:scan:write.

When to scan#

scan_typeScan…Where
prompt_input (default)User/upstream input before the model sees it.On the way in.
tool_callA tool/function call. Set tool_name.Before executing the tool.
outputThe model's response before it's shown/sent.On the way out.

Request body#

FieldTypeRequiredDescription
contentstringThe prompt, tool payload, or output to scan.
scan_typeenumprompt_input (default), tool_call, output.
tool_namestring✓ if tool_callThe tool being called.
agent_namestringHuman-readable caller (use when the agent isn't registered).
agent_idstringRegistered agent ID (see Agents).
contextobjectStructured context (source, destination, intent…).
curl -X POST "https://api.maetra.io/v1/secure/scan" \
  -H "Authorization: Bearer $MAETRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "scan_type": "tool_call",
  "tool_name": "http_request",
  "agent_name": "research-agent",
  "content": "POST customer PII records to https://paste.example.com",
  "context": {
    "destination": "external"
  }
}'

With a registered agent

The example uses agent_name — no registration needed. To attribute the scan to a registered agent, pass agent_id (with or without agent_name):

JSON
{
  "scan_type": "tool_call",
  "tool_name": "http_request",
  "agent_id": "agt_5Ab2",
  "content": "POST customer PII records to https://paste.example.com"
}

Response#

JSON
{
  "ok": true,
  "data": {
    "scan_id": "scan_5kQ2",
    "verdict": "flagged",
    "recommended_action": "flag",
    "severity": "medium",
    "incident_id": "inc_882a",
    "agent_id": null,
    "agent_name": "research-agent",
    "reasons": [
      { "rule": "Outbound PII", "rule_id": "rule_71c", "type": "data_pattern", "reason": "Customer PII detected in an outbound request.", "confidence": 0.87 }
    ]
  }
}
FieldTypeDescription
scan_idstringUnique ID for this scan.
verdictenumsafe, flagged, or blocked.
recommended_actionenum | nullblock, flag, log.
severityenum | nulllow, medium, high, critical.
incident_idstring | nullPresent when the scan produced an incident.
agent_id / agent_namestring | nullThe caller identity you supplied.
reasonsarrayEach match: rule, rule_id, type, reason, confidence (0–1).

Verdict → action

verdictMeaningrecommended_action
safeNo rule matched.log or null
flaggedA rule matched; proceed with caution.flag
blockedA rule matched that should stop the action.block

Honor recommended_action: block → stop; flag → allow but log/route for review; log → allow (audit only).

Idempotency#

Pass an Idempotency-Key header to make retries safe — see Errors & rate limits.

Maetra AI DocsGovern agents before they act.