# Policy templates

> Reference for the built-in policy templates in the Agent Gateway policy editor: what each template decides, its settings and defaults, the policy input it reads, and the policy slots where it decides.

Policy templates are ready-made Rego policies and rules that the policy editor offers when you create or change a policy definition.

## Overview

From version 1.0.10, the policy editor ships with 20 built-in templates. A new policy starts from one of them under Start from, or as a custom policy, and Add rules from a template adds a template’s rules to a policy you already have. Each template has a short description, its settings, the Rego it writes, examples under How it decides, and a link to the docs section it follows. For the steps, see [Apply OPA policies to your gateway and surfaces](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/apply-opa-policies.md).

A template is one of two kinds:

- Whole policy: decides on its own, so it is offered only under Start from on a new policy. Adding its rules to another policy would allow requests that policy denies, because allow rules combine with OR.

- Adds rules: a set of rules you can add to any policy of its Type. The Add rules from a template panel lists only these, marked Adds rules, with the template’s own default decision, Default DENY or Default ALLOW.

Templates are part of the dashboard. A policy keeps only the Rego a template writes, so editing a template’s Rego in your policy changes nothing else. A template written for one Type reads input the other Type doesn’t get, so Define Gateway Policy lists only the 6 templates for gateway policies, and Define Agent Surface Policy the 20 for surface policies. On a surface policy, a template offered for surfaces only is marked Agent surface only.

A setting that depends on your deployment, such as an issuer, a DID or a path, starts empty with a sample value as its placeholder. Use this template and Add to policy stay disabled until you fill it in, and the Rego preview uses the sample value meanwhile.

## Templates at a glance

| Template | Kind | Offered for | Category |
| [Deny by default](#deny-by-default) | Whole policy | Gateway and Agent Surface | Baseline |
| [Monitor-only baseline](#monitor-only-baseline) | Whole policy | Gateway and Agent Surface | Baseline |
| [Require authenticated caller](#require-authenticated-caller) | Adds rules | Agent Surface | Authentication |
| [Allow by JWT claim or role](#allow-by-jwt-claim-or-role) | Adds rules | Agent Surface | Authentication |
| [Allow by JWT issuer and audience](#allow-by-jwt-issuer-and-audience) | Adds rules | Agent Surface | Authentication |
| [Require Trust Registry recognition](#require-trust-registry-recognition) | Adds rules | Agent Surface | Trust checks |
| [Require verified credential subject](#require-verified-credential-subject) | Adds rules | Agent Surface | Trust checks |
| [All trust checks pass](#all-trust-checks-pass) | Adds rules | Agent Surface | Trust checks |
| [At least N trust checks pass](#at-least-n-trust-checks-pass) | Adds rules | Agent Surface | Trust checks |
| [Allowlist outbound destinations](#allowlist-outbound-destinations) | Whole policy | Agent Surface | Routing & paths |
| [Allow listed HTTP methods](#allow-listed-http-methods) | Adds rules | Gateway and Agent Surface | Routing & paths |
| [Allow listed paths](#allow-listed-paths) | Adds rules | Gateway and Agent Surface | Routing & paths |
| [Allow listed surfaces](#allow-listed-surfaces) | Adds rules | Gateway and Agent Surface | Routing & paths |
| [Restrict MCP tools by role](#restrict-mcp-tools-by-role) | Whole policy | Agent Surface | Allow / deny lists |
| [Allow listed subjects](#allow-listed-subjects) | Adds rules | Agent Surface | Allow / deny lists |
| [Business-hours access window](#business-hours-access-window) | Whole policy | Gateway and Agent Surface | Time |
| [Tool policy: allow authenticated callers](#tool-policy-allow-authenticated-callers) | Whole policy | Agent Surface | MCP tool policies |
| [Tool policy: allow by JWT claim](#tool-policy-allow-by-jwt-claim) | Whole policy | Agent Surface | MCP tool policies |
| [Tool policy: admin role with a deny reason](#tool-policy-admin-role-with-a-deny-reason) | Whole policy | Agent Surface | MCP tool policies |
| [Tool policy: allow every caller](#tool-policy-allow-every-caller) | Whole policy | Agent Surface | MCP tool policies |

## Where a template decides

A surface has several policy slots, set by the edge you drop a Policy element on. See [Policy element](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#policy-element). A template that reads the caller decides only in the slots where the policy input describes the caller. Elsewhere it reads another party, or nothing, and gives the result in this table.

| Template | Access Point and Target request policies | Transit Point policy | Target or Transit Point response policy | Request policy of a fabric:// Target |
| Require authenticated caller, Allow by JWT claim or role, Allow by JWT issuer and audience, Allow listed subjects | Decides on the caller | Reads the client the Transit Point authenticated, not the caller | Denies every response | Decides on the caller |
| Restrict MCP tools by role | Decides on the caller | Reads the client the Transit Point authenticated, not the caller | Denies every response | Decides on the caller for a 2026-07-28 MCP request, and denies earlier MCP requests |
| Require Trust Registry recognition | Decides on the caller | Reads the destination, not the caller | Denies every response | Denies every request |
| Require verified credential subject | Decides on the caller | Denies every request | Denies every response | Denies every request |
| Allowlist outbound destinations | Allows every request | Decides on the destination | Allows every response on the Target, and denies every response on a Transit Point | Allows every request |
| Allow listed HTTP methods, Allow listed paths, Allow listed surfaces | Decides | Decides | Denies every response | Decides |
| All trust checks pass, At least N trust checks pass | Decides on the Target’s checks | Decides on that Transit Point’s checks | Denies every response | Decides on the Target’s checks |

Business-hours access window reads only the clock and decides in every slot. Allow listed HTTP methods, Allow listed paths and Allow listed surfaces read the HTTP method, the path or the surface, which every request policy gets. A response policy doesn’t get them, so these templates deny every response there. See [Response policy input](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#response-policy-input).

All trust checks pass and At least N trust checks pass read only target-leg results, from the Trust Checks on the Managed Agent’s Target or on the Transit Point the request goes through. They don’t read Trust Checks on the Access Point, they deny a request on which no target-leg check ran, and they also deny every response in a response policy. The tool policy templates are for policies bound to MCP tools, not for a slot.

## Baseline templates

### Deny by default

Denies every request. Start here, then add or write the rules that allow what you need. A new policy starts as this template until you choose another.

| Item | Value |
| Kind | Whole policy |
| Offered for | Gateway and Agent Surface |
| Settings | None |
| Reads | Nothing |
| Notes | Assigned appliance-wide, it also decides public discovery reads such as /discovery and /.well-known/ucp. |
| Docs link | [Default allow vs default deny](/products/affinidi-trust-fabric/agent-gateway/concepts/opa-policies.md#default-allow-vs-default-deny) |

### Monitor-only baseline

Allows every request, so you can watch traffic before you write a stricter policy: through the Audit Log when policy decisions are audited, or through [policy input capture](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#policy-input-capture).

| Item | Value |
| Kind | Whole policy |
| Offered for | Gateway and Agent Surface |
| Settings | None |
| Reads | Nothing |
| Notes | To try a stricter policy without blocking requests, enforce it appliance-wide with the Monitor option on the Policies list instead. |
| Docs link | [Default allow vs default deny](/products/affinidi-trust-fabric/agent-gateway/concepts/opa-policies.md#default-allow-vs-default-deny) |

## Authentication templates

These templates read input.source_auth, the caller the surface’s Caller Context element authenticated. They decide on the Access Point and Target request policies. On a Transit Point, input.source_auth is the client the Transit Point authenticated, not the caller, and a Target response policy has no input.source_auth.

### Require authenticated caller

Allows a request only when the caller authenticated with one of the surface’s Caller Context methods. Denies callers whose credential was missing or invalid, and requests on a surface without caller authentication.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | None |
| Reads | input.source_auth.method |
| Docs link | [Apply OPA policies: steps](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/apply-opa-policies.md#steps) |

### Allow by JWT claim or role

Allows a request when the caller authenticated with a JWT and the chosen claim holds one of the listed values. A claim that is a list matches when any of its values is listed. Denies every other caller.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | Claim: the JWT claim to check, such as role, roles or groups. Default role.
Allowed values: required, separated by commas. Sample admin. |
| Reads | input.source_auth.claims |
| Docs link | [Use JWT claims to control access to a surface](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/use-jwt-claims-to-control-access-to-a-surface.md#steps) |

### Allow by JWT issuer and audience

Allows a request only when the caller’s JWT was issued by one of the listed issuers and names one of the listed audiences. Denies every other caller.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | Allowed issuers: required, exact iss values separated by commas. Sample https://login.example.com.
Allowed audiences: required, exact aud values separated by commas. Sample https://gateway.example.com. |
| Reads | input.source_auth.claims.iss, input.source_auth.claims.aud |
| Notes | A token without an aud claim is denied, as from an identity provider whose JWT Bearer method checks client_id or azp instead. |
| Docs link | [input.source_auth](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputsource_auth) |

## Trust check templates

### Require Trust Registry recognition

Allows a request only when the calling agent’s DID is the caller identity the gateway established and the trust registry recognised it. A DID the request only names, without proof, is not enough.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | None |
| Reads | input.agent.did, input.agent.did_verified, input.agent.trust_verification |
| Requirements | A verified caller DID (input.agent.did_verified), and Enrich policy input with agent context turned on in the Policy element. Without it, input.agent has no trust_verification and every request is denied. |
| Restrictions | Decides on the Access Point and Target request policies. On a Transit Point input.agent describes the destination, not the caller, and a response policy has no input.agent. As the request policy of a fabric:// Target, input.agent describes this Access Point’s own card, so it denies every request there. |
| Docs link | [Require trusted agents](/products/affinidi-trust-fabric/agent-gateway/concepts/opa-policies.md#a2a-surface-require-trusted-agents) |

### Require verified credential subject

Allows a request only when the gateway verified the caller’s DID, from an identity presentation or a bound source credential, and that DID is on the list. Denies unverified and unlisted callers.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | Allowed DIDs: required, caller DIDs separated by commas. Sample did:web:agent.example.com. |
| Reads | input.extension_identity.did, input.extension_identity.verified |
| Requirements | A verified caller DID (input.extension_identity.verified). |
| Restrictions | Decides on the Access Point and Target request policies. A Transit Point policy, a response policy and the request policy of a fabric:// Target have no input.extension_identity, so it denies every request there. |
| Docs link | [input.extension_identity](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputextension_identity) |

### All trust checks pass

Allows a request only when at least one Trust Check ran on the target leg and every one passed. The target leg is the Managed Agent’s Target, or the Transit Point the request goes through. Denies when any check failed or none ran.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | None |
| Reads | input.trust_check_results.target |
| Notes | A check that queries several Authorities passes when any of them recognises the entity. Trust Checks on the Access Point are not read. |
| Docs link | [input.trust_check_results](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputtrust_check_results) |

### At least N trust checks pass

Allows a request when the number of target-leg Trust Checks that passed reaches your threshold. Denies when fewer pass, or when no checks ran.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | Minimum passing checks: from 1 to 20. Default 2. |
| Reads | input.trust_check_results.target |
| Notes | A check that queries several Authorities counts once, and passes when any of them recognises the entity. Trust Checks on the Access Point are not counted. |
| Docs link | [input.trust_check_results](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputtrust_check_results) |

## Routing and path templates

### Allowlist outbound destinations

Allows a request through a Transit Point only when the Transit Point’s configured endpoint (input.gateway.target_id) is one of the listed destinations, or a path under one.

| Item | Value |
| Kind | Whole policy |
| Offered for | Agent Surface |
| Settings | Allowed destinations: required, separated by commas. An endpoint URL such as https://api.example.com, or fabric://<gateway id> for a Fabric route. Sample https://api.example.com, fabric://partner-gateway. |
| Reads | input.transit, input.gateway.target_id |
| Restrictions | Decides only on Transit Point requests, where the gateway sets input.transit. Used as the surface’s Access Point or Target policy, it allows every request, including the request a fabric:// Target sends, whose direction is also outbound but whose target_id is the peer gateway’s DID. |
| Notes | A Transit Point matches when its endpoint is a listed destination or a path under it, never a longer host name. |
| Docs link | [input.gateway](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputgateway) |

### Allow listed HTTP methods

Allows a request only when its HTTP method is on the list, for example to keep a surface read-only.

| Item | Value |
| Kind | Adds rules |
| Offered for | Gateway and Agent Surface |
| Settings | Allowed methods: upper case, separated by commas. Default GET. |
| Reads | input.http.method |
| Notes | Assigned appliance-wide, it also decides public discovery reads such as /discovery and /.well-known/ucp. |
| Docs link | [Common policy patterns](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/apply-opa-policies.md#common-policy-patterns) |

### Allow listed paths

Allows a request only when its path is one of the listed prefixes or a path under one. Only whole path segments match: /my-surface/public allows /my-surface/public/docs, not /my-surface/public-admin.

| Item | Value |
| Kind | Adds rules |
| Offered for | Gateway and Agent Surface |
| Settings | Allowed path prefixes: required, whole path prefixes separated by commas. Sample /my-surface/public/. |
| Reads | input.http.path |
| Requirements | Each prefix starts with the surface’s Access Point route, because the path is the whole request path: /my-surface/public/ for a route /my-surface. On a Transit Point, the path starts with /outbound, the route and the Transit Point’s alias, or with the Transit Point’s own listen path. |
| Notes | Denies a path that contains .., %2e, %25, a backslash or %5c. Assigned appliance-wide, it also decides public discovery reads such as /discovery and /.well-known/ucp. |
| Docs link | [input.http](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputhttp) |

### Allow listed surfaces

Allows a request only when it is for one of the listed surfaces, matched by surface ID. A surface ID stays the same when the surface is renamed, and another surface can share a surface’s name. Useful for a policy enforced across every surface.

| Item | Value |
| Kind | Adds rules |
| Offered for | Gateway and Agent Surface |
| Settings | Surface IDs: required, separated by commas. Each ID is shown in the read-only Surface ID field of the surface panel, and at the end of the surface page’s address (/surfaces/<id>). |
| Reads | input.channel.config_id |
| Notes | Assigned appliance-wide, it also decides public discovery reads such as /discovery and /.well-known/ucp. |
| Docs link | [Common policy patterns](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/apply-opa-policies.md#common-policy-patterns) |

## Allow and deny list templates

### Restrict MCP tools by role

Lets callers with an admin role call any MCP tool, and other authenticated callers only the listed safe tools. Every authenticated caller can use other MCP methods, such as tools/list. A caller is authenticated when it passed one of the surface’s Caller Context methods, such as JWT Bearer or API Key.

| Item | Value |
| Kind | Whole policy |
| Offered for | Agent Surface |
| Settings | Admin roles: required, values of the JWT role claim that may call any tool, separated by commas. A role claim that is a list matches when any of its values is listed. Sample admin.
Safe tools: required, MCP tools every authenticated caller may call, separated by commas. Sample search, summarise, translate. |
| Reads | input.source_auth.method, input.source_auth.claims.role, input.mcp.method, input.mcp.tool_name |
| Restrictions | Decides on the Access Point and Target request policies. Denies a request without input.mcp, such as a JSON-RPC message without an id, or an MCP request earlier than 2026-07-28 that a fabric:// Target sends on. |
| Docs link | [Restrict tool access by role](/products/affinidi-trust-fabric/agent-gateway/concepts/opa-policies.md#mcp-surface-restrict-tool-access-by-role) |

### Allow listed subjects

Allows a request only when the caller authenticated with a JWT and its subject is on the list. The subject is the value of the JWT verification strategy’s Caller identity claim, sub unless the strategy names another. Denies every other caller.

| Item | Value |
| Kind | Adds rules |
| Offered for | Agent Surface |
| Settings | Allowed subjects: required, values of the strategy’s caller identity claim, separated by commas. Sample user@example.com. |
| Reads | input.source_auth.subject |
| Restrictions | Decides on the Access Point and Target request policies, like the [authentication templates](#authentication-templates). |
| Docs link | [input.source_auth](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#inputsource_auth) |

## Time templates

### Business-hours access window

Allows, or denies, requests made inside a daily time window on the listed days, in the chosen time zone. Requests outside the window get the opposite decision.

| Item | Value |
| Kind | Whole policy |
| Offered for | Gateway and Agent Surface |
| Settings | Inside the window: Allow requests lets requests through only inside the window, and Deny requests refuses requests inside it and lets every other request through. Default Allow requests.
Days: English day names, separated by commas. Leave empty for every day. Default Monday to Friday.
From: start of the window, as HH:MM. Default 09:00.
Until: end of the window, as HH:MM. Requests from this time on are outside it. It must differ from From. Default 17:00.
Time zone: an IANA time zone, such as Europe/Berlin or Asia/Singapore. Default UTC. |
| Reads | The current time, in the chosen time zone |
| Notes | An Until earlier than From makes the window cross midnight, for example 22:00 to 06:00. Each part counts on its own date: with Monday to Friday, Monday 01:00 is inside the window and Saturday 01:00 is outside. A request whose time the policy can’t read in the time zone is denied in both modes. Rate limits are set on the surface’s Rate Limit panel, not in policy. See also [Time-based decisions](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#time-based-decisions). |
| Docs link | [Policy input reference](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md#policy-input-reference) |

This template has no How it decides examples, since its decision depends on the time of the request.

## Tool policy templates

These four templates are for a policy bound to MCP tools, which decides each tools/call to the surface’s MCP Target. Each card is marked MCP tool policy. Bind the policy to tools on the Per-Tool Access Control list, as in [Control MCP tool access with per-tool policies](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/control-mcp-tool-access-with-per-tool-policies.md#example-policies).

The first three read input.jwt, the claims of the bearer token in the request’s Authorization header, which the tool policy decodes without verifying. Use them only on a closed Access Point whose Caller Context methods are all JWT Bearer reading the Authorization header with the Bearer scheme, so the gateway verifies the token first.

### Tool policy: allow authenticated callers

Allows a call when the request’s bearer token has a sub claim.

| Item | Value |
| Kind | Whole policy |
| Offered for | Agent Surface |
| Settings | None |
| Reads | input.jwt.sub |
| Requirements | A closed Access Point whose Caller Context methods are all JWT Bearer reading Authorization with Bearer. |

### Tool policy: allow by JWT claim

Allows a call when a claim of the request’s bearer token, a single value or a list, has one of the listed values. Covers admin-only and subscription-based access.

| Item | Value |
| Kind | Whole policy |
| Offered for | Agent Surface |
| Settings | Claim: the token claim to read, such as role or subscription. Default role.
Allowed values: required, separated by commas. Sample admin. |
| Reads | input.jwt |
| Requirements | A closed Access Point whose Caller Context methods are all JWT Bearer reading Authorization with Bearer. |

### Tool policy: admin role with a deny reason

Allows callers whose bearer token has the allowed role, as a single value or in a list. It sets deny_reason when the token has no role or another one. The reason is written to the audit log only, not to the response.

| Item | Value |
| Kind | Whole policy |
| Offered for | Agent Surface |
| Settings | Allowed role: required, the role claim value that may call the tool. Sample admin. |
| Reads | input.jwt.role |
| Requirements | A closed Access Point whose Caller Context methods are all JWT Bearer reading Authorization with Bearer. |

### Tool policy: allow every caller

Allows every call, so only the tools listed on the binding decide what can be called.

| Item | Value |
| Kind | Whole policy |
| Offered for | Agent Surface |
| Settings | None |
| Reads | Nothing |

## Related

- [Apply OPA policies to your gateway and surfaces](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/apply-opa-policies.md): Create a policy from a template and combine templates.

- [OPA policies reference](/products/affinidi-trust-fabric/agent-gateway/reference/surfaces/opa-policies.md): The policy editor, the Rules view and every field of the policy input.

- [OPA policies](/products/affinidi-trust-fabric/agent-gateway/concepts/opa-policies.md): How the gateway evaluates policies and combines their rules.

- [Control MCP tool access with per-tool policies](/products/affinidi-trust-fabric/agent-gateway/how-to-guides/policies/control-mcp-tool-access-with-per-tool-policies.md): Bind a tool policy template to individual tools.
