Docs / API reference
Redaction and guardrails API
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
| Route | Does | Statuses |
|---|---|---|
GET /v1/guardrails | Read the organization default | 200, 401 |
PATCH /v1/guardrails | Replace or clear it | 200, 400, 401, 403 |
PATCH /v1/keys/{key_id} | Per-key redact, retain_bodies, guardrails | see 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.
| Field | Type | Notes |
|---|---|---|
blocked_patterns | array | Up 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_injection | off, flag or block | The heuristic described below. |
tool_policy | object or null | Tool allow and deny lists. |
Each entry of blocked_patterns:
| Field | Type | Notes |
|---|---|---|
pattern | string, required | A JavaScript regular expression of 512 characters or fewer. Backreferences, lookaround, and a repeated group holding a repeat or alternatives are refused. |
flags | any of i, m, s, u | i when unset. |
action | block or flag | block when unset. |
name | string or null | Shown in the error in place of the pattern’s position. |
And tool_policy:
| Field | Type | Notes |
|---|---|---|
allow | array or null | Only these tools may be used; null leaves every undenied tool open. A trailing * matches a prefix. |
deny | array | Function 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
curl "https://api.pentestllm.ai/v1/guardrails" \ -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.
Read next
- MCP servers
- Log export
- Invoices
- Billing details
- Statement signing key
- Keys and scopes
- Usage and signed receipts
- Spend limits and balance
- Sessions
- Embeddings, rerank and moderation
- Batch files
- Batches
- Status and proof feeds
- Count tokens
- Usage by app
- App sign-in keys
- Webhook deliveries
- Docs: connect in two minutes
- Files and redaction