Validate outbound content¶
POST /api/v1/filter/outbound
Scans AI-generated responses against your firewall configuration before they reach the user. Use it to catch data leakage, PII and policy violations on the way out.
Request body¶
Schema: OutboundFilterRequest.
| Field | Type | Required | Description |
|---|---|---|---|
content |
string |
No | The AI-generated content to validate (1–1,000,000 bytes). |
config_id |
string |
No | UUID of the firewall configuration to use. |
ip_address |
string |
No | Ignored. MATVIS records the IP address of the connection instead. |
tool_call |
ToolCallInput |
No | Tool call to scan before execution. Accepts OpenAI (function object) or Anthropic (name + input) format. |
tool_config_id |
string |
No | UUID of the tool-call scan configuration. |
session_id |
string |
No | Beta. Groups calls into one chat session. See Sessions (beta). |
session_end |
boolean |
No | Beta. End the session once this call has succeeded (requires session_id). |
stream |
boolean |
No | Beta. Append content to the session's streamed reply (requires session_id). |
stream_end |
boolean |
No | Beta. Append content if given, then scan the rest of the streamed reply and end it (requires session_id). |
Field combinations
Fields are paired. Send content with config_id to scan content, and/or tool_call with tool_config_id to scan a tool call. At least one complete pair is required. Under a session_id, every call carries config_id, and a tool call is sent on its own, without content.
Example request¶
export MATVIS_URL="https://<your-matvis-host>"
export MATVIS_API_KEY="<your-firewall-api-key>"
export CONFIG_ID="824a67ff-0605-4abe-8c8d-c5592fbfdb97"
curl -X POST "$MATVIS_URL/api/v1/filter/outbound" \
-H "Authorization: $MATVIS_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"config_id": "$CONFIG_ID",
"content": "Life is a continuous journey of learning, growing, and connecting with others."
}
EOF
Sessions (beta)¶
Sessions are in beta and may change without notice.
Calls to /inbound and /outbound that carry the same session_id form one chat session. Use an unguessable id, for example a UUID; it has at most 128 characters from A-Z a-z 0-9 . _ : -.
- PII round trip. When the session's inbound configuration masks PII (Pseudonymization) and its outbound configuration has De-pseudonymization on,
/outboundputs the original values back where the reply carries the placeholders/inboundcreated, then scans the restored text. The responsecontentis that restored text, and a delivered reply whose placeholders were restored reportsresult.modified: truewith the restored text incontent_modifiedas well; a reply without a placeholder reportsmodified: false. A tool call sent under the session has its arguments restored the same way. - Streamed replies. Send each part of the LLM's reply with
stream: trueas it arrives, and end the reply withstream_end: true. MATVIS scans the reply in windows of about 256 characters; each response carries the verdict and the restored text of what it scanned, and an emptycontentwhile text is still being collected. Forwardcontentwhenresult.actionisallow. After a block, the rest of that reply gets the same block. End every reply withstream_end, also a blocked or stopped one: until then, the next part continues it. A call withoutstreamorstream_endis a complete message, scanned on its own; it also ends a reply left open. - Stream limits. A part is answered
422when the text still waiting to be scanned plus that part is over 1,000,000 bytes: sendstream_endfirst. An open stream holds at most 10,000,000 bytes by default; past that the part is answered422. Sendstream_endwithoutcontentto close it, then continue in a new stream. - One configuration per endpoint. The first call with a
config_idbinds it for that endpoint; anotherconfig_idis answered422. When the bound configuration is changed or deleted, the next call is answered409and the session ends: start a new one. - Ending a session.
session_end: trueon a call that succeeds,DELETE /api/v1/filter/session/{session_id}(answers204), or 30 minutes without a call (the default). Sessions are held in the Firewall API's memory, so a restart ends them too. At 10,000 open sessions by default, a new session ends the least recently used one. - Firewall events. A streamed reply is recorded once, when it ends. Firewall Analytics, syslog and Splunk HEC events carry
session_id, which isnullfor calls without a session.
These session field combinations are answered 422:
stream,stream_endorsession_endwithoutsession_id.- Under a
session_id: a call withoutconfig_id. - Under a
session_id: a tool call that also carriescontent,streamorstream_end. session_endwithstreambut withoutstream_end. Sendstream_endtoo, so the stream is scanned before the session ends.- Under a
session_id: a call withoutcontent, unless it sendsstream_end.
Responses¶
Act on result.action: allow means you may deliver the content, block means you must not. It already takes monitoring mode into account.
- When
result.modifiedistrue, delivercontent_modified. On this endpoint that only happens under a session, when placeholders were restored. Outbound scans never mask PII, soresult.handlingnever containspseudonymizedhere. result.validisfalsewhen a filter found something it would block. In monitoring mode you getvalid: falsewithaction: allow, andresult.monitoring_modeistrue.result.handlingcan containallowlisted.bypassedis inbound only, because the prompt-injection bypass tag applies to user input.block_reasonnames the filter that blocked,sourcesays whether it was the content scan (chat) or the tool scan (tool), andblock_messageis the text you can show the user.
200 OK¶
Content topics are abridged: a real response lists every topic your configuration checks.
Nothing triggered. result.action is allow: deliver content to the user.
{
"timestamp": "2026-10-15T14:02:37.052751",
"content": "Life is a continuous journey of learning, growing, and connecting with others.",
"content_modified": null,
"config_id": "e771d869-3ccd-5a3f-a12b-8dc67b3a890e",
"session_id": null,
"result": {
"valid": true,
"block_reason": null,
"severity": 0.22,
"severity_level": 0,
"block_message": null,
"action": "allow",
"monitoring_mode": false,
"modified": false,
"handling": [],
"source": null,
"highest_severity_filter": null
},
"filters": {
"Content": {
"valid": true,
"score": 0.22,
"monitoring_mode": false,
"severity_level": 0,
"details": {
"Fraud Schemes": { "score": 0.22, "severity_level": 0 },
"Phishing Attacks": { "score": 0.22, "severity_level": 0 }
}
},
"Language": {
"valid": true,
"score": 0.0,
"monitoring_mode": false,
"severity_level": 0,
"details": {
"label": "en",
"score": 0.99
}
},
"PII": {
"valid": true,
"score": 0.0,
"monitoring_mode": false,
"severity_level": 0,
"details": {}
}
}
}
A filter blocked the response. result.action is block: do not deliver the content. Here the Content filter flagged it, so block_reason is Content.
{
"timestamp": "2026-10-15T14:02:37.052751",
"content": "This is how you can commit fraud.",
"content_modified": null,
"config_id": "e771d869-3ccd-5a3f-a12b-8dc67b3a890e",
"session_id": null,
"result": {
"valid": false,
"block_reason": "Content",
"severity": 0.95,
"severity_level": 10,
"block_message": "Message flagged for a Content violation (severity: 0.95, severity level: 10). Please revise your chat history.",
"action": "block",
"monitoring_mode": false,
"modified": false,
"handling": [],
"source": "chat",
"highest_severity_filter": "Content"
},
"filters": {
"Content": {
"valid": false,
"score": 0.95,
"monitoring_mode": false,
"severity_level": 10,
"details": {
"Fraud Schemes": { "score": 0.95, "severity_level": 10 },
"Phishing Attacks": { "score": 0.41, "severity_level": 1 }
}
},
"Language": {
"valid": true,
"score": 0.0,
"monitoring_mode": false,
"severity_level": 0,
"details": {
"label": "en",
"score": 0.98
}
},
"PII": {
"valid": true,
"score": 0.0,
"monitoring_mode": false,
"severity_level": 0,
"details": {}
}
}
}
An allowlist entry in your configuration matched, so nothing is blocked. result.action is allow and result.handling contains allowlisted.
{
"timestamp": "2026-10-15T14:02:37.052751",
"content": "You can reach our team at support@matvis.com.",
"content_modified": null,
"config_id": "e771d869-3ccd-5a3f-a12b-8dc67b3a890e",
"session_id": null,
"result": {
"valid": true,
"block_reason": null,
"severity": 0.2,
"severity_level": 0,
"block_message": null,
"action": "allow",
"monitoring_mode": false,
"modified": false,
"handling": ["allowlisted"],
"source": null,
"highest_severity_filter": null
},
"filters": {
"Content": {
"valid": true,
"score": 0.2,
"monitoring_mode": false,
"severity_level": 0,
"details": {
"Fraud Schemes": { "score": 0.2, "severity_level": 0 },
"Phishing Attacks": { "score": 0.2, "severity_level": 0 }
}
},
"Language": {
"valid": true,
"score": 0.0,
"monitoring_mode": false,
"severity_level": 0,
"details": {
"label": "en",
"score": 0.98
}
},
"PII": {
"valid": true,
"score": 0.0,
"monitoring_mode": false,
"severity_level": 0,
"details": {}
}
}
}
Status codes¶
| Code | Meaning |
|---|---|
200 |
The response was scanned. Act on result.action. |
400 |
The config_id names a configuration of the wrong type for this endpoint, for example an inbound configuration. |
403 |
The API key is missing or unknown, the key is a configuration management (admin) key, or the license is not valid. |
404 |
The config_id is unknown. |
409 |
MATVIS refused the named configuration when it loaded it. Under a session: the session ended, or its configuration was changed or deleted. Start a new session. |
422 |
Validation error, including the session rules above. An unknown tool_config_id is also answered 422. |
503 |
The response was not fully scanned, or API keys or configurations are not loaded yet. The second case carries a Retry-After header. |
503 Not fully scanned¶
MATVIS could not complete the scan: a filter was unavailable, the scanner was saturated, or the scan failed for another reason. The request was not blocked. MATVIS returns no verdict here rather than a verdict about content it did not measure, so your own policy decides what to do with the request.
In most cases the response does not name the cause. It is in the MATVIS application logs, as a
scan_unavailable record carrying the request's correlation id, the config, and the filter
involved. Nothing is written to Firewall Analytics for a request that could not be scanned, so
an outage never appears there as a detection.
One cause is yours to fix rather than ours: a pattern you saved that takes too long to match.
It is capped, and the response says so: its detail tells you that one of your saved patterns
took too long to match. The scan_unavailable record names the pattern, so an operator can find
it and change it. Saving a pattern that cannot be matched in time is refused, so this applies to
patterns saved before that check existed.
503 examples
422 Validation error¶
The request body was malformed or the field combinations above were not met. See HTTPValidationError. Body validation errors come as a list in detail. Some checks made after validation, such as the session limits or an unknown tool_config_id, return detail as a single string instead.