Policy Examples
Every example on this page is a complete HYPR AgentPass™ policy in miniature. It gives the intent, the phase and action to choose on the form, the condition to paste, and what to watch for before you promote it from Observe.
The page has three kinds of example:
- The built-in example chips on the policy form
- The AI wizard's starter guardrails, which you reach by describing a goal instead of pasting an expression
- Recipes for the attributes the AI does not write
Save every one of these in Observe first, and read its matches on the connector's Policies tab. See Observe First, Then Enforce.
The Built-In Example Chips
The Add Policy form offers these eleven conditions as clickable chips above the editor. Click a chip to load it, then adjust it.
| Chip | Intent | Phase · Action | Condition | Watch for |
|---|---|---|---|---|
| Block DELETEs | Stop any HTTP DELETE through a REST connector | Pre-Request · DENY | request.method == "DELETE" | Scope it to the connector you mean. Unscoped, it applies to every connector |
| Large token requests | Cap how much a model may be asked to generate | Pre-Request · DENY | has(request.body.max_tokens) && request.body.max_tokens > 50000 | A body with no max_tokens is a non-match either way. The has() guard makes that intent explicit |
| Specific path | Govern one part of an API | Pre-Request · DENY or REQUIRE_APPROVAL | request.path.startsWith("/v1/admin") | Paths are compared as sent. Check the Request Log for the exact prefix |
| Error responses | Record backend failures | Post-Response · ALLOW | response.status >= 500 | response.* is empty during Pre-Request, so this must be a Post-Response rule |
| Specific agent | Apply a rule to one agent | Pre-Request · any | request.agent.name == "my-agent" | request.agent is empty when the caller is unauthenticated, so this never matches anonymous traffic |
| Slow responses | Record slow backends | Post-Response · ALLOW | response.latency_ms > 10000 | Post-Response only, as for error responses |
| Bedrock: unattributed caller | Block a Bedrock call the gateway could not attribute to a named developer | Pre-Request · DENY | connector.template == "AWS_BEDROCK" && connector.aws.bedrock.identity_source != "CLOUDTRAIL" | Safe by construction: identity_source is always present on a Bedrock request |
| Bedrock: no MFA | Flag identified sessions that were not MFA-backed | Pre-Request · DENY | connector.aws.bedrock.mfa_authenticated == false | mfa_authenticated is present only when the caller was identified. Pair it with the unattributed-caller chip to catch the unidentified |
| M365: Copilot Studio agents only | Apply a rule to turns with a Copilot Studio agent | Pre-Request · any | connector.m365.copilot.surface == "copilot_studio" | surface is the one Copilot attribute that is always present. Lead every Copilot rule with it |
| Files: confidential attachment | Stop a document marked confidential from reaching an agent | Pre-Request · DENY | request.files.exists(f, f.text.contains("CONFIDENTIAL")) | text holds at upload and on the send, so you can enforce it at either |
| Files: over 10 MB | Refuse large attachments | Pre-Request · DENY | request.files.exists(f, f.size_bytes > 10485760) | Size is the gateway's own measurement only at upload. On the send, it is what the caller says. Enforce at upload |
The AI Starter Guardrails
The wizard offers these six under Start from a common guardrail when you author a policy with AI on an inference connector. They are goals, not expressions. Picking one fills the goal box, and the drafted rule is compiled, checked and backtested like any other.
The expression the AI writes adapts to the tools and models in use on your connector, so none is reproduced here.
| Guardrail | Goal, as the wizard words it | Phase · Action |
|---|---|---|
| Block destructive shell commands | Stop the agent from running destructive shell commands such as rm -rf, mkfs, dd if= writing to a device, or a fork bomb. | Post-Response · DENY |
| Block writes outside the project | Stop the agent from writing to files outside the project directory, such as anything under /etc, ~/.ssh, or system configuration paths. | Post-Response · DENY |
| Block reads of credential files | Stop the agent from reading credential files. Match the path the tool was asked to open — anything named .env, aws/credentials, id_rsa, id_ed25519, or a keychain file. | Post-Response · DENY |
| Block production system access | Stop the agent from connecting to production systems — production hostnames, production database connection strings, or a prod kubeconfig context. | Post-Response · DENY |
| Flag secrets pasted into a prompt | Block a request when the most recent message contains a secret — a private key header, an AWS secret access key, or a bearer token. | Pre-Request · DENY |
| Flag personal data in prompts | Block a request when the most recent message contains personal data such as a national insurance or social security number, or a payment card number. | Pre-Request · DENY |
The first four are caught in the reply. The agent runs tools on its own machine, so the command appears only in the model's request to run it. Enforcing one of them cuts the reply short at that tool call. See Governing Inference Traffic.
Attached Files
Files reach the gateway through the Agent Portal, and are checked twice: at upload, and again on the message that sends them. Name, type, size and checksum are the gateway's own measurement at upload only. text is the content that actually reaches the agent, so it holds on both.
request.files.exists(f, f.mime_type == "application/pdf" && f.size_bytes > 1000000)
request.file_count > 0
request.file_count is always present, so it is the safe way to ask whether a request carried a file at all. request.files itself is absent when there are none. That makes request.files.exists(…) a non-match on ordinary traffic, which is correct, and worth knowing.
Sensitivity Labels
request.files[].sensitivity_label carries the Microsoft Purview sensitivity label an uploaded document holds, as AgentPass read it from the document itself. It is present on an Agent Portal upload, and absent on the message that sends a file onward. Every rule in this group therefore acts at upload. See The Document's Sensitivity Label.
Block documents marked Highly Confidential. The first form reads clearly. Enforce the second, because a label can be renamed in Microsoft Purview and an identifier cannot.
request.files.exists(f, f.sensitivity_label.name == "Highly Confidential")
request.files.exists(f, f.sensitivity_label.id == "00000000-0000-0000-0000-000000000000")
Require every Office document to be classified. state is present on every upload, and not_applicable covers the formats that cannot carry a label at all. This rule therefore reaches unclassified Word, Excel and PowerPoint documents, without touching a text file, a CSV or a PDF.
request.files.exists(f, f.sensitivity_label.state == "unlabeled")
Block a whole branch of your label taxonomy. parent_id is set on a sub-label. One rule on the parent's identifier covers every sub-label under it, and needs no editing when the taxonomy grows.
request.files.exists(f, f.sensitivity_label.parent_id == "00000000-0000-0000-0000-000000000000")
Insist on Microsoft Purview's own stamp. source separates a label Purview applied from a plain sensitivity name some other tool wrote, which has no identifier and nothing to verify it against.
request.files.exists(f,
f.sensitivity_label.state == "labeled" && f.sensitivity_label.source != "msip_properties")
Save each of these in Observe first. Run it for a few days, and read the matches to see which of your documents actually carry which labels, before a rule starts refusing uploads.
The Signed-In Person
request.user is the email of the person the gateway verified at sign-in, never a value the caller asserted. It is absent when nobody signed in.
request.user.endsWith("@example.com")
!request.user.endsWith("@example.com")
This blocks the outsiders it names, and allows every request that carried no identity, because a condition on a missing attribute is never true. Make the missing case match too, and say which traffic the rule governs:
connector.template == "M365_COPILOT" && (!has(request.user) || !request.user.endsWith("@example.com"))
The !has(request.user) branch is what catches a request that carried no identity.
Requiring a sign-in in the first place is the connector's job, not the policy's.
The Connector
Every request carries connector.name, connector.template and connector.onboarding_mode. Lead a template-specific rule with the template, so the intent is clear to whoever reads it next:
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.mfa_authenticated == false
connector.name == "prod-anthropic" && request.path.startsWith("/v1/messages")
The Connectors field on the form scopes the policy the same way. The guard in the expression states the scope in the rule itself.
The AWS Caller Behind a Bedrock Request
On an AWS Bedrock connector, connector.aws.bedrock.* describes the developer behind the call, as far as the gateway could identify them. Only identity_source, credential_type and has_security_token are always present, so build a block on those. Bedrock Caller Policies explains the attribution and the safe pattern.
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.identity_source != "CLOUDTRAIL"
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.mfa_authenticated == false
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.credential_type == "LONG_TERM"
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.credential_type != "TEMPORARY"
connector.template == "AWS_BEDROCK"
&& connector.aws.bedrock.identity_source == "CLOUDTRAIL"
&& !connector.aws.bedrock.user_email.endsWith("@example.com")
The last acts only on callers the gateway identified. Pair it with the first, so the unidentified are caught too.
Approval-based onboarding on a Bedrock connector holds SSO sign-ins only. The fourth rule is therefore how you reach API-key callers. A policy is evaluated on every Bedrock request, whichever credential it carried.
Microsoft 365 Copilot
On a Microsoft 365 Copilot connector, connector.m365.copilot.surface is always present. The Copilot Studio agent attributes arrive on copilot_studio turns only. Microsoft 365 Copilot Policies explains the surfaces.
connector.template == "M365_COPILOT"
&& connector.m365.copilot.surface == "copilot_studio"
&& connector.m365.copilot.agent_id == "00000000-0000-0000-0000-000000000000"
connector.template == "M365_COPILOT" && connector.m365.copilot.surface == "default_copilot"
connector.template == "M365_COPILOT"
&& connector.m365.copilot.surface == "copilot_studio"
&& !connector.m365.copilot.user_email.endsWith("@example.com")
connector.template == "M365_COPILOT"
&& connector.m365.copilot.surface == "attachment_upload"
&& request.files.exists(f, f.text.contains("CONFIDENTIAL"))
connector.template == "M365_COPILOT" && inference.completion.text.contains("CONFIDENTIAL")
Prefer agent_id to agent_name in a rule you enforce. The name changes if someone renames the agent, and a rule on the old name quietly stops matching.
The last example is a reply-side rule. On a Copilot connector, any enabled reply-side rule makes replies arrive complete instead of streaming, for every conversation on that connector.
Recipes Across Namespaces
One agent, one part of an API. Combine the calling agent with the path so the rule is about a specific agent doing a specific thing:
request.agent.name == "deploy-agent" && request.path.startsWith("/v1/prod/")
Guard an inference rule with the connector. An inference.* condition is a non-match on a connector that reaches no model, so scoping is already safe. The guard makes the intent readable:
connector.template == "ANTHROPIC" && inference.latest_turn.text.contains("Project Redwood")
Reading inference.latest_turn.text, not the whole conversation, makes this fire once, on the turn that introduced the phrase, instead of on every turn after it.
Files at upload, files at send. Write the metadata rule for upload, and the content rule for both:
connector.m365.copilot.surface == "attachment_upload" && request.files.exists(f, f.size_bytes > 10485760)
request.files.exists(f, f.text.contains("CONFIDENTIAL"))
Related
- Writing a Policy by Hand — paste any of these into the form
- Attribute Reference — every attribute these examples use, with type and presence
- Authoring a Policy with AI — reach the starter guardrails