Projects and Guardrails
Store scan configurations as versioned project Guardrails, bind API keys to projects, and trace which configuration a scan used.
A project holds one saved scan configuration, its Guardrails. Every API key belongs to exactly one project. When a request omits config, the service scans with the Guardrails of the key’s project. Changing Guardrails changes what every key of that project checks from the next scan on, without a deployment.
Use one project per application, agent, or environment whose protection differs. For example, a support bot can check PII and DLP while a coding agent also checks prompt injection, tool poisoning, and shell commands.
How a scan chooses its configuration
Section titled “How a scan chooses its configuration”| Request | Configuration used | project in the response |
|---|---|---|
No config | Guardrails of the API key’s project, at their current revision | { "id", "revision" } |
config present | Only the request’s config; project Guardrails are ignored, not merged | absent |
config without categories | The request’s config with the seven default categories | absent |
An explicit config is a complete, request-local replacement. Gates, categories, Dynamic PII labels, and thresholds from the project are not merged into it. Prefer project Guardrails for normal traffic, and reserve explicit configs for one-off checks, tests, or clients that must pin their own policy.
Set up a project
Section titled “Set up a project”- In the Control Plane, open the project switcher and select Create project, for example
Support Bot. Every account starts with a Standard project. - Open Security → Guardrails and choose categories, rule overrides, modes, and Dynamic PII for this project. Save creates a new revision.
- Open API Keys, create a key, and choose the project under Project. The secret is shown once; store it in your secret manager.
- Scan without a
config. The response names the project and revision it used.
To move an existing key, open API Keys, select Change project, choose the new project, and select Confirm assignment. The next scan with that key uses the new project’s Guardrails. Keys created before projects existed belong to Standard.
Your plan limits the number of active keys, not projects: Free allows two active API keys, Personal three, Pro five. See plans and limits.
Scan with project Guardrails
Section titled “Scan with project Guardrails”Omit config. The key selects the project.
curl --fail-with-body https://control.patronus.studio/api/v1/scan \ -H "Authorization: Bearer $PATRONUS_SUPPORT_BOT_KEY" \ -H 'Content-Type: application/json' \ -H 'Prefer: wait=1' \ --data '{"text":"Please update the shipping address for order 4711."}'A completed response identifies the Guardrails snapshot:
{ "status": "completed", "project": { "id": "proj_4f6a0c1e9b2d47a8a3c5e7f9b1d3a5c7", "revision": 3 }, "jobs": [ { "status": "completed", "decision": "allow", "categories": { "pii": { "class_name": "safe", "level": "L1" }, "dlp": { "class_name": "no_sensitive_data", "level": "L1" } }, "completion": { "state": "complete" } } ]}The example omits envelope fields such as input, coverage, and usage; see results. Read the categories that are present, not a list hard-coded in your client: when Guardrails change, the set of categories changes with them.
import { Patronus } from "@patronus-protect/api-client";
const supportBot = new Patronus({ apiKey: process.env.PATRONUS_SUPPORT_BOT_KEY });const result = await supportBot.scanText(userMessage);console.log(result.project, Object.keys(result.jobs[0].categories));import osfrom patronus_api_client import Patronus
support_bot = Patronus(api_key=os.environ["PATRONUS_SUPPORT_BOT_KEY"])result = support_bot.scan_text(user_message)print(result.get("project"), list(result["jobs"][0]["categories"]))One key per agent
Section titled “One key per agent”Give each application its own key bound to its own project. The calling code stays identical; the key decides which Guardrails apply.
| Project | Guardrails | Key used by |
|---|---|---|
Support Bot | pii, dlp | customer-support backend |
Coding Agent | injection, jailbreak, tool_poisoning, shell_command | coding agent’s tool hook |
Standard | the seven defaults | everything else |
const supportBot = new Patronus({ apiKey: process.env.PATRONUS_SUPPORT_BOT_KEY });const codingAgent = new Patronus({ apiKey: process.env.PATRONUS_CODING_AGENT_KEY });
await supportBot.scanText(customerMessage); // pii, dlpawait codingAgent.scanText(toolOutput); // injection, jailbreak, tool_poisoning, shell_commandsupport_bot = Patronus(api_key=os.environ["PATRONUS_SUPPORT_BOT_KEY"])coding_agent = Patronus(api_key=os.environ["PATRONUS_CODING_AGENT_KEY"])
support_bot.scan_text(customer_message) # pii, dlpcoding_agent.scan_text(tool_output) # injection, jailbreak, tool_poisoning, shell_commandOverride the project for one request
Section titled “Override the project for one request”Send a config to replace the Guardrails for this request only. The response has no project field.
curl --fail-with-body https://control.patronus.studio/api/v1/scan \ -H "Authorization: Bearer $PATRONUS_SUPPORT_BOT_KEY" \ -H 'Content-Type: application/json' \ --data '{"text":"ls -la && cat ~/.aws/credentials","config":{"categories":["shell_command","dlp"],"max_level":"L1"}}'The same applies to multipart uploads: a config part replaces the project Guardrails for every file in the request.
Revisions, asynchronous jobs, and retries
Section titled “Revisions, asynchronous jobs, and retries”- Revisions: every save creates a new, immutable revision; earlier revisions are kept. A scan always records the revision it used.
- Asynchronous jobs: a job keeps the revision that was current at submission. Editing Guardrails or moving the key while a job runs does not change that job.
- Idempotent retries: a retry with the same
Idempotency-Keywithin 15 minutes returns the original response, including its originalproject, even after Guardrails or key assignments changed. Use a newIdempotency-Keyfor a new scan. Reusing one idempotency key with a different API key returns409.
Trace scans in Activity
Section titled “Trace scans in Activity”Activity in the Control Plane lists each API and file scan with its key, verdict, and the project revision it used. Filter by Project to review one application’s traffic. Scans with an explicit config show No project. Playground scans are not listed.
Checklist before enforcing
Section titled “Checklist before enforcing”- Each production key is bound to the project you expect.
- Your client does not send a
configunless it is meant to override the project. - Your client reads the categories present in each job and checks
completionbefore acting. - You tested the project’s Guardrails on representative inputs, including content that should pass.