Agent Security API
The Agent Security API protects AI agents by validating tool calls before execution and detecting anomalous behavior patterns.
Project Scoping: Agent profiles are scoped by project. For the Developer API, project_id is automatically extracted from your API key. For the Consumer API, project_id must be provided in the request body.
Why Agent Security?
AI agents with tool access can be exploited to:
- Execute dangerous commands: Shell injection, file system manipulation
- Escalate privileges: Accessing restricted resources
- Exfiltrate data: Sending data to external endpoints
- Behave erratically: Unusual patterns indicating compromise
Endpoints
Validate a tool call before allowing execution.
Request Body
Note: For Developer API, project_id is automatically extracted from your API key. For Consumer API, include project_id in the request body.
Response (Allowed)
Response (Blocked)
Get Agent Stats
Get statistics for a specific agent.
Response
active_sessions is always 0 and is marked deprecated in the API schema. PromptGuard does not retain agent session state across requests, so there is nothing to count. The field is scheduled for removal in the next API version — do not build on it.
Enforcement is opt-in per project
An agent’s policy — allowed_tools, blocked_tools, require_approval —
decides validate-tool verdicts only while the project’s
agent_policy_enforced setting is on. It is off by default: policies you
write are shown on the dashboard’s Agent Security page and enforce nothing
until you turn enforcement on there, or via the dashboard API:
The project response carries the current value. While enforcement is off,
every agent gets the platform-default tool lists. When it is on, an empty
allowed_tools means no allowlist is configured (the defaults stand), a
non-empty one replaces the default allowlist, and blocked_tools is added to
the platform defaults — a policy can narrow what an agent may do, never
re-enable a dangerous default.
Register Agent
Register a new agent identity and receive a one-time-visible credential.
Request Body
Response
agent_secret is shown only once. Store it securely — it cannot be retrieved again, only rotated.
Rotate Agent Credential
Revoke the agent’s current credential and issue a new one.
Response
An agent has exactly one active credential, enforced by a database constraint. If two rotations race, one wins and the other gets 409 with code CREDENTIAL_ROTATION_CONFLICT — retry it. A 409 never means the credential forked; it means yours did not land.
End Agent Session (deprecated)
This endpoint is a no-op. Server-side agent session state is not retained across requests, so there is no session to end. The route still returns 200 with the same keys as before plus "deprecated": true, and sends Deprecation: true and Sunset: Wed, 09 Dec 2026 00:00:00 GMT. It will be removed on or after that sunset date — stop calling it.
Agent Security Health
Health check for the agent security service. Useful for readiness probes before routing validation traffic.
Get Managed Policy
Get the org-managed update policy for an enrolled device (used by the desktop agent to apply fleet-managed update settings).
This poll doubles as the device’s heartbeat: each call updates the device’s Last seen in the fleet view. A device that shows never has enrolled but has not yet polled — check that the agent is installed and running on that machine.
Response
SDK Usage
Risk Levels
These tools are blocked by default:
execute_shell, run_command, bash, system
delete_file, rm, rmdir
kill_process, terminate
send_email, http_post (without approval)
Project Isolation
Agent profiles are isolated by project. This means:
- The same
agent_id in different projects will have separate behavioral profiles
- Profiles persist across restarts (stored in database)
- Each project maintains its own baseline for anomaly detection
Developer API: project_id is automatically extracted from your API key. Ensure your API key is associated with a project.
Consumer API: Include project_id in your request body. You must have access to the specified project.
Best Practices
- Validate every tool call: Don’t skip validation for “safe” tools
- Use sessions: Group related calls for better behavior analysis
- Review anomalies: Investigate when
anomaly_score is high
- Set up alerts: Monitor for patterns indicating compromise
- Use project-scoped API keys: Ensure your API keys are associated with projects for proper isolation