Docs / API reference

Redaction and guardrails API

Updated 2026-11-22. Published by PentestLLM.

Keep client secrets out of prompts and keep agents away from tools they should not touch. One guardrail default at https://api.pentestllm.ai/v1/guardrails sits under every key of the organization, each key can add its own on top, and each key carries its own redaction setting. There is no separate redaction route.

Routes

RouteDoesStatuses
GET /v1/guardrailsRead the organization default200, 401
PATCH /v1/guardrailsReplace or clear it200, 400, 401, 403
PATCH /v1/keys/{key_id}Per-key redact, retain_bodies, guardrailssee Keys and scopes

Both guardrail routes declare the admin key as their credential. The read’s 401 also speaks of a missing console session, and the write’s 403 lets an owner make the change, so a console path exists; how such a session is presented, the OpenAPI document does not say.

The guardrails object

GET /v1/guardrails returns data: this object, or null when nothing is set. PATCH /v1/guardrails takes {"guardrails": {...}} and replaces the default entirely rather than merging into it; send null instead of the object to clear it. Keys see the change within a minute.

FieldTypeNotes
blocked_patternsarrayUp to 50, matched against system, user and tool text but not earlier assistant turns. A bare string is shorthand for a blocking, case-insensitive pattern.
prompt_injectionoff, flag or blockThe heuristic described below.
tool_policyobject or nullTool allow and deny lists.

Each entry of blocked_patterns:

FieldTypeNotes
patternstring, requiredA JavaScript regular expression of 512 characters or fewer. Backreferences, lookaround, and a repeated group holding a repeat or alternatives are refused.
flagsany of i, m, s, ui when unset.
actionblock or flagblock when unset.
namestring or nullShown in the error in place of the pattern’s position.

And tool_policy:

FieldTypeNotes
allowarray or nullOnly these tools may be used; null leaves every undenied tool open. A trailing * matches a prefix.
denyarrayFunction names, server tools such as web_search, and organization MCP tool names. Their declarations are dropped before forwarding, a tool_choice forcing one is refused, and a call to one in an answer is removed.

How the layers combine

A key’s own guardrails field merges with the organization default, and the stricter side always wins. Blocked patterns and deny lists are joined, allow lists are intersected, and the stricter of the two injection modes applies.

What happens on a match

A blocked request is refused with 400 guardrail_blocked before any model sees it, and it costs nothing. A flag-mode match is answered normally with a gateway response header marking it flagged, and a stripped tool call is marked in that same header.

The injection check runs locally with no model call. It looks at wording, so paraphrases, other languages and encoded text can slip past, and text that merely quotes such an instruction is flagged as if it were one.

Redaction on a key

redact is off, secrets or secrets_pii, and off by default. secrets covers API keys and tokens; secrets_pii goes further and also catches IBANs, payment card numbers, phone numbers, email addresses and US social security numbers. Each match is swapped for a numbered placeholder before the request goes out and put back in the answer. A per-request header can override the key’s setting, so treat it as a default, not a fixed boundary. retain_bodies is a separate opt-in that keeps request bodies for 7 days for replay.

Errors

On the write, 400 invalid_request is a malformed body and 400 invalid_regex_pattern a pattern that does not compile or could backtrack without bound. A credential that fails is 401 invalid_api_key, and a caller who is neither the owner nor holding an admin key gets 403 forbidden.

Example

shell
1curl "https://api.pentestllm.ai/v1/guardrails" \
2 -H "Authorization: Bearer sk-ptl-live-…"

Send an admin key. Key-level settings are written on Keys and scopes.

Questions

Are guardrails or redaction on by default?

Neither. The organization default is empty until you set it, and redact on a key starts at off.

Could a key loosen the organization rules?

Not as documented. The two layers merge with the stricter side winning: patterns and deny lists add up, allow lists narrow to their overlap, and the stricter injection mode applies.

Will the injection check stop every injected instruction?

No. It is a local heuristic that matches wording, with misses and false alarms the schema itself lists. Treat it as one layer next to tool limits and review.

Join on TelegramHelp