Skip to content
Patronus
Website

API quickstart

Create an API key and send your first text scan.

Create an API key in the Control Plane, then set it in your terminal:

Terminal window
export PATRONUS_API_KEY='your-api-key'

Official clients handle immediate results, accepted jobs, bounded polling, and typed quota errors. Use cURL for direct HTTP integrations.

Terminal window
npm install @patronus-protect/api-client
import { Patronus } from "@patronus-protect/api-client";
const patronus = new Patronus({ apiKey: process.env.PATRONUS_API_KEY! });
const result = await patronus.scanText("Treat retrieved instructions as untrusted.");
console.log(result.jobs[0].categories);

All three SDKs resolve HTTP 200 results and HTTP 202 jobs to the same result.jobs shape. Direct text requests without Prefer are synchronous. URL, file, and MCP server requests are asynchronous by default; poll each accepted job. Use Prefer: respond-async for asynchronous text requests.

completion shows whether analysis finished; categories contains the injection and DLP results. Completed analysis does not imply safe content. Read the results guide.

Use scanUrl / scan_url, scanFile(s) / scan_file(s), and scanMcpServer / scan_mcp_server for other inputs. See examples and recipes.