OPA policies reference
Agent Gateway evaluates Open Policy Agent (OPA) policies, written in Rego, selected on a gateway, in the slots a surface’s Policy elements fill, and on every gateway or surface at once when a policy is enforced appliance-wide. Its parts are:
- Policy element: which canvas slots accept a policy and how to configure the element on a surface.
- Policy editor: the Start from gallery, the Details and Policy sections, the Rules and Rego views, and the read-only editor.
- Policy definitions: versions, dry-run testing, and deletion: the version fields, the dry-run Test panel, policy input capture, and what the delete confirmation checks.
- Appliance-wide (global) policy enforcement: enforcing a policy definition on every gateway or every surface at once.
- Policy input reference: every field the gateway populates in the
inputobject that Rego rules read at evaluation time, for request, response and MCP tool policies.
If you are new to OPA policies on the Agent Gateway, read the OPA policies concept overview first.
Policy element
The Policy element runs an OPA (Rego) policy against the request or response and denies it when the policy returns false. Multiple Policy elements can coexist on a surface, one per slot.
The slot the element fills is determined by the edge you drop it on.
| Drop position | Slot | When it evaluates |
|---|---|---|
| Access Point → Managed Agent (request) | Target policy | Before the request is forwarded to the Managed Agent. One Policy element per slot. |
| Access Point → Managed Agent (response) | Response policy | On the response before it is forwarded back to the caller. |
| Managed Agent → Transit Point (request) | Transit Point policy | Per hop, before dispatch to that destination. |
| Managed Agent → Transit Point (response) | Transit Point response policy | On the response from that destination, before it returns to the Managed Agent. |
A surface saved with an inbound policy shows it as a second Policy element on the Access Point → Managed Agent edge, evaluated before the target policy. New surfaces can’t add one in the dashboard.
Gateway-level policies (configured outside the surface) always run before any surface-level policy element. A gateway-level deny cannot be overridden by this element.
Fields
| Field | Required | Default | Description |
|---|---|---|---|
| Policy Definition | Yes | — | The Agent Surface policy to evaluate, chosen by name from the policies on the Policies page. A request slot evaluates it against the gateway and surface policy input, and a response slot against the response policy input. |
| Enrich policy input with agent context | No | Off | When on, the pipeline fetches the target’s agent card and queries the trust registry before evaluation, populating input.agent in the OPA input. Adds latency. Enable only when the policy uses input.agent. Not available for response policies. |
Policy editor
The policy editor creates and edits one policy definition. It opens from Define Gateway Policy or Define Agent Surface Policy on the Policies page, with the header Create Gateway Policy or Create Agent Surface Policy, or from a policy’s row, with the header Edit Policy: and the policy’s name. The Define button sets the new policy’s Type.
Start from
A new policy shows only the Start from gallery until you choose how to begin. Select a card to show its Template details beside the form, then select Use this template, or select Create custom policy under the cards. The Details and Policy sections appear after that choice.
- A new policy starts as deny by default, with no card selected.
- Use this template fills the Rego and the Description. It replaces the Description only when the Description is empty or still holds the text the previous template filled in, and it leaves the Name unchanged.
- Create custom policy starts an allow-all policy and empties the Name and Description.
- Change reopens the gallery, and Cancel closes it again. When the policy already has added rules or your own edits, Use this template and Create custom policy ask before they replace them.
- Using a template or starting a custom policy shows a notice with Undo.
The gallery lists 20 templates for an Agent Surface policy and 6 for a Gateway policy. Six cards show at first, and Show all (20) lists the rest of the Agent Surface templates. For each template’s settings and behaviour, see Policy templates.
| Template details item | What it shows |
|---|---|
| Settings | The template’s own fields. A deployment-specific setting starts empty with a sample value as its placeholder, and shows “Required before the template can be used.” until you fill it. Use this template stays disabled until then. |
| Show Rego | The Rego the template writes with the current settings. With an empty setting, the preview uses the sample value and says so. |
| How it decides | Each example request, with Show input for its input and an ALLOW or DENY badge for the decision the template gives it. |
| Docs link | The docs section the template follows. |
Details
| Field | What it does | Default |
|---|---|---|
| Name | Required. The label shown in the policy list and on Audit Log entries when the policy decides. | Empty |
| Description | Shown in the policy list and version history. | Empty, or the template’s description after Use this template |
| Type | Gateway or Agent Surfaces. Hidden on a new policy opened from a Define button. Shown read-only otherwise, with “Set by the Define button that opens this page. It can’t be changed here.” on a new policy and “A policy’s type is fixed once created.” on a saved one. | Set by the Define button |
| Status | The Enabled switch. While off, the policy is never evaluated. A policy enforced appliance-wide that is turned off makes every request in that plane fail closed, unless the assignment is Monitor only. | On |
| Policy ID | Saved policies only. The ID that surfaces, gateways and the Audit Log refer to, with a copy button. It can’t be changed. | — |
| SHA | Saved policies only. The content hash of the enforced revision, with a copy button. See Content hash and version fields. | — |
Policy section
The Policy section shows the policy in one of two views, chosen with the Rules and Rego buttons. It opens on Rules. Above the views, a status line shows the rule count, the policy’s default decision as Default DENY or Default ALLOW, and Valid or Invalid for the compiled Rego. Add rules from a template opens the panel that adds a template’s rules to the end of the policy.
The Rules view lists the policy’s rules in groups:
- From template: and the template’s name, for the rules Add to policy added. Remove group removes them.
- Your rules, for every other rule, with the template the policy started from while its Rego still matches it.
Each rule shows its Kind, Rule and Line. Select the line number to show the rule in the Rego, or the trash icon to remove it. A rule or group that another rule still reads can’t be removed, and the view names the rule that reads it. A line above the groups says what the policy decides, or that the Rules view can’t summarise it and to read the Rego.
| Kind | Meaning |
|---|---|
| Allows | Allows the request when its conditions match. |
| Sets allow | Sets allow in a way the Rules view can’t read. Read the Rego, and remove such a rule in the Rego view. |
| Deny reason | Gives the reason a request was denied, and does not decide it. |
| Used by allow | A helper rule that allow reads, directly or through other rules. |
| Not used by allow | A helper rule that allow doesn’t read, so it doesn’t change whether a request is allowed. |
Warnings in the Rules view:
- When every request is allowed by default, the view says the allow rules change nothing, and Deny by default changes the default to deny.
- A group shows “No effect while the default is ALLOW.” for the same reason.
- A group added from a template written for the other Type blocks Create until you remove it.
The Rego view holds Rego reference and Policy Content (Rego), the Rego with line numbers. A compile error shows below the editor. A package that doesn’t match the policy’s Type shows a Package mismatch banner with Fix it, which sets the expected package, and blocks saving.
Rego reference is a collapsed card with the package the policy uses, the allow rule structure, the main input fields of gateway and surface policies, the separate input of policies bound to MCP tools, and short examples. Its links open Gateway and surface policy input and MCP tool policy input on this page.
Template examples
On a saved policy, after Add to policy adds a template’s rules, a Template examples card appears below the editor. It runs that template’s examples through the dry run against the draft, saved or not.
| Column | What it shows |
|---|---|
| Example | The example request, with a short explanation when the decision differs. |
| Expected | The decision the template gives the example. |
| This policy | The decision the whole draft gives it. |
| Result | Matches or Differs. Left empty when you changed a template setting from its default, since a different decision is then expected. |
Load in Test copies the example’s input into Sample input JSON of the Test (dry-run) panel, with an Undo notice. A row differs when another rule in the policy allows or denies that request, because any rule that allows lets the request through.
Read-only editor
A user without permission to edit policies sees the policy read-only, with the note “You can view this policy but not change it.” The Rego and Details can’t be changed, and the page has no Create or Save button, no Fix it, no Add rules from a template, and no Test (dry-run) panel.
Policy definitions: versions, dry-run testing, and deletion
Every policy definition is stored as an append-only sequence of versions, not a single mutable record. Saving a change to the Rego body appends a new version and keeps every earlier one. Saving only the name, description, or enabled state updates the current version in place without creating a new one.
Content hash and version fields
The policy editor and list both show read-only fields that identify the exact Rego enforced, so a decision or an audit entry can be traced back to specific bytes even after the policy has since changed.
| Field | What it does | Default |
|---|---|---|
| SHA | The content hash (sha256:<hex>) of the Rego currently enforced. Shown on the policy editor, in the policy list, and against every row of the version history. Binds the policy’s scope to its body, so identical Rego under Gateway and Agent Surface scope hashes differently. | — |
| Version history | An append-only, newest-first list of every revision the policy has had: version number, content hash, creation time, author, and the name/description as they stood at the time. Selecting an older version compares it line-by-line against the current one. | — |
| Author | The username of whoever saved the revision, resolved from the authenticated account. Falls back to the raw account identifier when the account can no longer be resolved, for example a deleted user. | — |
Dry-run testing (Test panel)
The Test (dry-run) panel appears below the Rego editor once the policy definition has been saved at least once.
| Field | What it does | Default |
|---|---|---|
| Sample input JSON | The input document the dry run evaluates the policy against. Saved with the policy definition, so the last input you tested with is still there next time you open it. | A caller authenticated by JWT Bearer, in source_auth with method jwt_bearer, a subject and claims, plus an HTTP method and path and an inbound direction. Gateway and surface policies read the caller from input.source_auth, as this sample does. |
| Run against the draft above | Evaluates the Rego currently in the editor, including unsaved changes, against the sample input. Disabled while the policy does not compile or the sample input is not valid JSON. Nothing here reaches the live policy engine or in-flight traffic. | — |
| Auto-run | Re-runs the dry run automatically, a short pause after every change to the policy or the sample input. | Off |
The result shows an ALLOW or DENY badge, a reason when the policy defines one, and the query, draft, and the content hash the dry run evaluated. A dry run always evaluates the Rego in the editor, saved or not.
The draft Rego and sample input each have a size limit, and a run has a time limit. An oversized draft returns “Draft policy is too large to simulate”, and an oversized sample input returns “Sample input is too large to simulate”.
To test against the input of a real request, copy one from the surface’s Policy Input card, described below, and paste it into Sample input JSON.
Policy input capture
From version 1.0.10, policy input capture shows the input of a surface’s policies live, so you can write and test a policy against real requests. It is on the Policy Input card of the surface’s Capture view, opened from its Monitoring tab. The card says “For developing and testing policies only”.
For a walkthrough from dry run to the Audit page, see Test your policy in action.
Policy input capture is off until an administrator turns on its feature flag under Settings › Admin › Feature Flags. While it is off, the card says so and names that setting. Listening needs permission to edit both surfaces and policies. Without it, the card shows “Needs permission to edit surfaces and policies”.
- Listen to policy input starts listening, and the card shows “Listening”. Stop listening stops it. Leaving the view or reloading the page also stops it. The Capture view’s Pause holds payload capture only.
- While you listen, each request and response policy evaluation on the surface adds a row: Access Point, Target, Transit Point and response policies, and gateway and appliance-wide policies that apply to it. MCP tool policies are not shown.
- A surface with no policy of its own has no surface evaluation to show. Add a request policy to see each request’s input. One that allows everything is enough.
- The card keeps the last 50 evaluations. One request can add several rows.
- Credentials in the input are masked. Only the dashboard users listening to this surface at the time receive the input. The captured input isn’t written to the Audit Log or kept on the gateway. It still holds request data such as messages, tool arguments and claims.
- Starting and stopping a capture are audit events, Policy Input Capture Started and Policy Input Capture Stopped, recorded when the gateway’s audit settings select them. See Audit log.
- Clear in the Capture view’s toolbar empties the captured payloads and policy inputs.
| Column | What it shows |
|---|---|
| Timestamp | When the policy decided. |
| Policy | The policy slot that ran, such as inbound, target, transit <alias>, response or gateway, the surface variant when there is one, and the name and version of each policy the slot evaluated. |
| Decision | Allow, Deny or Error, with the deny reason or evaluation error. |
| Actions | Show input or Hide input for the evaluation’s input, and a button that copies it. |
All policy slots above the table filters the rows to one slot. To test a captured input, copy it and paste it into Sample input JSON of the Test (dry-run) panel.
Delete confirmation and affected references
Selecting the delete icon on a policy row opens a confirmation instead of deleting immediately.
- The confirmation states how many gateways (for a Gateway policy) or surfaces (for an Agent Surface policy) currently reference the policy, so you can judge the impact before committing to a delete that cannot be undone.
- This count only covers direct references within the policy’s own scope: gateways with it selected on their Global Policy tab, or surfaces with a Policy element bound to it. It does not include appliance-wide (global) enforcement. Check the policy’s Global column before deleting. Removing a globally-enforced policy fails its entire plane closed, not only the objects the count includes. See Appliance-wide (global) policy enforcement.
- A referencing gateway or surface does not fall back to allowing traffic once its policy disappears. It fails closed: every request that policy used to evaluate is denied until a replacement is attached or the reference is removed.
Appliance-wide (global) policy enforcement
Any Gateway-type or Agent Surface-type policy definition can also be enforced across every gateway or every surface on the appliance, from the Policies list, in addition to or instead of being attached to individual objects. This is a reach setting on an existing definition, not a separate Rego scope: an appliance-wide Gateway policy still uses package gateway.policy and query path data.gateway.policy.allow, and an appliance-wide Agent Surface policy still uses package surface.policy and query path data.surface.policy.allow, exactly as described in Policy scopes and input structs.
| Field | What it does | Default |
|---|---|---|
| Global (toggle, per policy row on the Gateway or Agent Surfaces tab) | Enforces this policy definition on every gateway or every surface on the appliance, on top of that object’s own policy. Switching it on shows a confirmation stating how many gateways or surfaces will enforce it. | Off |
| Monitor (checkbox, shown once Global is on) | Evaluates and records the decision without blocking a request the policy would have denied. | Off (enforcing) |
- Appliance-wide policies evaluate deny-overrides, ahead of that plane’s own per-object policy. On an inbound direct request the order is: appliance-wide gateway policy, the gateway’s own Global Policy tab policy, appliance-wide surface policy, then the surface’s own Policy element. A deny at any stage is final.
- A Monitor assignment is evaluated and its would-be decision recorded, but it never blocks a request, so it is a way to observe a new appliance-wide rule before enforcing it.
A Global assignment that is switched on (not Monitor) and can no longer be resolved, because the underlying policy definition was disabled, deleted, or no longer compiles, fails its entire plane closed: every gateway or every surface, depending on the plane, denies matching traffic until the assignment is fixed or removed. A Monitor-only assignment is skipped instead.
Policy input reference
The gateway serialises request context into a structured input object before evaluating any Rego policy. Policy rules read fields from input to make access decisions. Use this reference when writing Rego rules to understand which fields are available, how authentication data appears in input.source_auth, and which fields are populated at each evaluation point.
The input carries no request time. A policy that decides by time of day reads the clock itself. See Time-based decisions.
Policy scopes and input structs
Three input shapes exist. Use the package declaration and field paths of the slot you are writing for.
| Scope | Package declaration | Query path | Input |
|---|---|---|---|
| Gateway | package gateway.policy | data.gateway.policy.allow | Gateway and surface policy input |
| Surface request (Access Point, Target, Transit Point) | package surface.policy | data.surface.policy.allow | Gateway and surface policy input |
| Surface response (Target and Transit Point response policies) | package surface.policy | data.surface.policy.allow | Response policy input |
| MCP tool | package surface.policy | data.surface.policy.allow | MCP tool policy input |
Gateway and surface request policies share the same input and field names. Response policies and MCP tool policies each get a different input with its own fields, so a rule written for a request policy reads absent fields there and denies.
The policy editor refuses package channel.policy, the package name of earlier versions, with a Package mismatch banner. Use package surface.policy.
Gateway and surface policy input (PolicyInput)
Full example
A fully-populated input for an inbound MCP request with JWT authentication and trust registry data:
{
"http": {
"method": "POST",
"path": "/my-surface/mcp",
"headers": {
"content-type": "application/json",
"x-request-id": "req-abc123"
}
},
"gateway": {
"direction": "inbound"
},
"channel": {
"config_id": "surface-abc123",
"name": "my-surface"
},
"source_auth": {
"method": "jwt_bearer",
"subject": "user@example.com",
"claims": {
"role": "admin",
"org": "acme-corp",
"aud": "https://gateway.example.com"
}
},
"mcp": {
"method": "tools/call",
"tool_name": "search",
"params": { "query": "hello" }
},
"agent": {
"did": "did:web:example.com:agent-1",
"did_verified": true,
"trust_verification": true,
"agent_dna": {
"uai": "urn:uai:example.com:agent-1:v1",
"birthEvent": { "scid": "...", "timestamp": "..." },
"genesis": { "codeHash": "...", "genesisHash": "..." },
"behavioral": { "behavioralHash": "..." },
"operational": {},
"attestations": {}
}
}
}Not all fields are present on every request. See Input availability by evaluation path for when each field is populated.
input.http
Always present. Sensitive headers are stripped before policy evaluation, on inbound and outbound requests alike. Policies cannot read credential values from headers.
| Field | Type | Description |
|---|---|---|
method | string | HTTP method: "POST", "GET", etc. |
path | string | The whole request path, which starts with the surface’s Access Point route: /my-surface/public/docs for a route /my-surface. On a Transit Point, the path of the request the managed agent sends, which starts with /outbound, the route and the Transit Point’s alias (/outbound/my-surface/partner-a/...), or with the Transit Point’s own listen path. |
headers | object | Non-sensitive request headers as a flat string-to-string map. On an outbound Transit Point request, these are the headers from the original inbound request. |
input.gateway
Always present. Describes the traffic direction and the identity participants.
| Field | Type | Description |
|---|---|---|
direction | string | "inbound" when a request arrives at the Access Point, directly or over Fabric. "outbound" when the managed agent sends a request through a Transit Point. Also "outbound" for the request a surface with a fabric:// Target sends to the peer gateway, which the Target’s request policy evaluates. |
source_id | string | On a Transit Point request, the resolved DID of the managed agent acting as the protected caller. On a request received over Fabric, the DID that sent it. Absent on the request a fabric:// Target sends and on a direct inbound request. |
target_id | string | On a Transit Point request, the Transit Point’s configured endpoint, the same for every request through it, such as https://api.example.com/mcp, or fabric://<gateway id>/<surface id> on a Fabric route. On the request a fabric:// Target sends, the peer gateway’s DID. Absent on inbound requests. |
Both a Transit Point request and the request a fabric:// Target sends have direction "outbound". Only a Transit Point evaluation carries input.transit, so a rule that must decide on Transit Point calls only tests input.transit first.
input.channel
Always present. Identifies the surface handling the request.
| Field | Type | Description |
|---|---|---|
config_id | string | The surface ID. It stays the same when the surface is renamed. |
name | string | The surface name as configured in the dashboard. Other surfaces may share it. |
variant_alias | string | The surface variant the request selects, on a request received over Fabric and on a Transit Point. Absent on a direct request and for the default variant. |
input.source_auth
On inbound evaluations, present whenever the surface has a Caller Context element and the request reaches policy. A caller whose credential failed reaches policy only on some Access Points. See Failed. On outbound evaluations, present when the Transit Point’s own Caller authentication verified the caller, with the same shape as on the inbound side.
The method field names the Caller Context method that verified the caller and determines the shape of the object. When a Caller Context element holds several methods, the gateway verifies each request with the method whose credential it carries, so method tells a policy which kind of credential the caller used. See How the gateway selects a method.
This rule admits every JWT caller, and only those API key callers verified against one secret:
package surface.policy
default allow := false
allow if input.source_auth.method == "jwt_bearer"
allow if {
input.source_auth.method == "api_key"
input.source_auth.key_name == "partner-keys"
}JWT bearer
Callers authenticated with a validated JWT.
{
"method": "jwt_bearer",
"subject": "user@example.com",
"claims": {
"role": "admin",
"org": "acme-corp"
}
}| Field | Description |
|---|---|
subject | The value of the JWT verification strategy’s Caller identity claim, sub by default. |
claims | All claims from the token payload as a JSON object. Access individual claims as input.source_auth.claims.<claim_name>. |
API key
Callers verified by an API Key (secret store) or API Key (provider) method. Both report method as api_key, so a policy tells them apart by key_name.
{
"method": "api_key",
"key_name": "my-client-id"
}| Field | Description |
|---|---|
key_name | For API Key (secret store), the method’s Secret ID. For API Key (provider), the Key ID of the key the caller presented, as shown on the API keys page. |
DID auth
Callers authenticated with a DID-based credential.
{
"method": "did_auth",
"did": "did:web:example.com:caller"
}| Field | Description |
|---|---|
did | The caller’s DID. |
Failed
Callers whose credential was missing or invalid, or who sent credentials for more than one Caller Context method, on an Access Point that hands the failure to policy. Whether a failed caller reaches policy depends on the Access Point’s state:
- Closed (the default for surfaces created from version 1.0.4) or legacy (stored before version 1.0.4 with Public access unset): the gateway refuses the caller with
401andCaller credential missing or invalidbefore any policy runs, so policy sees nofailedresult. A legacy Access Point refuses such callers from version 1.0.9. - Public access on: the request reaches policy with
methodset tofailed, and the surface forwards it with no asserted caller identity unless a policy denies it.
On a surface with authorization server discovery for MCP clients, a failed caller gets a 401 instead in every state. See Access Point readiness for each state.
{
"method": "failed",
"attempted_method": "jwt_bearer",
"reason": "Invalid credential: Token has expired"
}| Field | Description |
|---|---|
attempted_method | The Caller Context method selected for the request: the method whose credential the request carried, or the primary (first) method when it carried none or credentials for more than one. One of jwt_bearer, api_key, api_key_provider or did_auth. Unlike method, the two API key methods report different values here. |
reason | A human-readable description of why authentication failed. A request carrying credentials for more than one method gives “Ambiguous credentials: the request carries credentials for more than one source authentication method”. |
On a public Access Point, a failed credential does not block the request by itself. Add a policy rule that checks input.source_auth.method to deny an unauthenticated caller there. On a closed or legacy Access Point, the gateway refuses that caller with 401 before policy runs.
input.mcp
Present on MCP requests: at the Access Point, on a request received over Fabric, and through an MCP Transit Point. On the request a fabric:// Target sends, present only for a 2026-07-28 MCP request. Absent on other protocols, and for a JSON-RPC message without an id.
| Field | Type | Description |
|---|---|---|
method | string | The MCP JSON-RPC method, for example "tools/call", "tools/list", "resources/read". |
tool_name | string | The name in the request’s params. For a 2026-07-28 request, set on tools/call only. For an earlier request, set for any method whose params has a name, such as prompts/get, so check method as well. |
resource_uri | string | Resource URI from a resources/read request, for a 2026-07-28 request only. For an earlier request, read params.uri. |
prompt_name | string | Prompt name from a prompts/get request, for a 2026-07-28 request only. For an earlier request, read params.name. |
params | object | Full parsed params from the JSON-RPC request body. Absent when the request has none. |
protocol_version, client_capabilities, client_info | string, object, object | The MCP protocol version and the client’s declared capabilities and information. Set for a 2026-07-28 MCP request only. |
input.a2a
Present on A2A protocol requests. It is built from the original request body before the gateway attaches a signed identity VP, and reflects what the caller actually sent.
| Field | Type | Description |
|---|---|---|
method | string | The A2A JSON-RPC method exactly as the caller sent it, for example "message/send". |
method_canonical | string | The method in its A2A v0.3 slash form, such as message/send, when the gateway recognises it. Absent otherwise. |
message | object | The A2A message object (params.message or top-level message). Contains role, parts, metadata, and messageId when present. |
input.agent
Present when Enrich policy input with agent context is on in the Policy element and data was retrieved. Also present with did populated after the caller DID is resolved. Absent when neither condition applies.
| Field | Type | Description |
|---|---|---|
did | string | The agent’s effective DID. |
did_verified | boolean | true when something in this request proves did. Always present. |
did_verification | string | How did was established, with the same values as input.extension_identity.verification. |
trust_verification | boolean | true when all configured trust registry recognition queries pass. false when any query returns untrusted. Absent when no queries ran. |
agent_dna | object | Agent DNA fingerprint from the agent card. Contains uai and nested fingerprint objects. Absent when the agent card does not include an agentDNA field. |
trust_registry_did | string | The trust registry DID from the agent’s trust-registry extension. |
provider_did | string | The provider DID from the agent’s trust-registry extension. |
authority_did | string | The authority DID from the trust-registry extension. |
identity_issuer_did | string | The issuer DID of the agent identity credential in the caller’s identity presentation. Set only when the gateway verified that presentation, and absent otherwise. |
If input.agent.trust_verification is absent, a condition that checks input.agent.trust_verification == true evaluates to undefined in Rego and the rule denies. Turn on Enrich policy input with agent context in the Policy element when writing policies that check input.agent.
input.extension_identity
Present when the gateway resolved a caller identity from the request’s identity extension. Absent otherwise. Check verified before a policy trusts the DID.
| Field | Type | Description |
|---|---|---|
did | string | The agent DID from the Verifiable Presentation (VP) holder or subject. Absent when none was resolved. |
identity_hash | string | A hash of the identity payload for correlation. Absent when none was computed. |
verified | boolean | true when something in this request proves the DID: verification is vp, vp_unanchored or source_auth. |
verification | string | How the DID was established: vp (a verified identity presentation whose issuer is a trust anchor), vp_unanchored (a verified presentation whose issuer no trust anchor vouches for), source_auth (bound to the credential the gateway authenticated on this request), or unverified (nothing in the request proves it, for example an identity configured on the surface). |
input.identity_binding
Present when a verifiable presentation (VP) from an upstream gateway was processed and its signature verified. Absent when the request carries no binding VP, and when the VP is invalid, for example when its signature fails to verify. An invalid VP never appears as verified set to false.
| Field | Type | Description |
|---|---|---|
verified | boolean | true when the VP signature verified, its holder matches the credential subject, and its issuer is one of the sending connection’s issuers. false when the signature verified but no trust anchor vouches for issuer_gateway. Check it before relying on agent.did. |
agent.did | string | The managed agent’s DID on the sending gateway. |
agent.identity_fields | object | Agent identity fields from the VP credential subject. |
caller.fields | object | Allowlisted caller claims, keyed by field name. Absent when the sending gateway bound no caller context. |
caller.user_hash | string | One-way hash of the caller’s identity on the sending gateway. It depends on how that gateway identified the caller: the authentication method, the credential’s issuer and the principal. |
caller.assurance | string | "gateway_attested" or "caller_credential_chained". |
caller.identity_source | string | How the sending gateway sourced caller context: "transit_token" or "jwt_bearer". |
delegated | boolean | true when the sending gateway was acting for a caller. |
issuer_gateway | string | The DID of the gateway that issued the VP. |
target | string | The endpoint the request was forwarded to. Absent when not recorded. |
intent | object | Structured intent object from the VP. Absent when not present. |
input.trust_check_results
Present when at least one Trust Check ran on the request, on either leg. Absent when none ran.
{
"trust_check_results": {
"caller": [
{
"id": "tc-caller-1",
"trust_registry_id": "tr-main",
"query_type": "recognition",
"ok": true,
"error": null,
"name": "Verify caller department",
"authority_id": "did:web:authority.example.com",
"entity_id": "did:web:caller.example.com",
"action": "is",
"resource": "ownedAgent",
"query_resolved": true
}
],
"target": []
}
}| Field | Type | Description |
|---|---|---|
caller | array | Results for the caller leg. An empty array when no caller-leg checks ran. |
target | array | Results for the target leg. On a request through a Transit Point, only that Transit Point’s results for its destination. A Transit Point without Trust Checks leaves input.trust_check_results absent, so a policy that requires Trust Checks also checks that count(input.trust_check_results.target) > 0. |
managed_agent | array | From version 1.0.10, on a request through a Transit Point, the results of that Transit Point’s queries that check This surface’s managed agent: whether the trust registry still recognises the DID the managed agent calls out under. Absent when the Transit Point has no such query, and on a discovery read. Available to the gateway, surface and Transit Point policies on that request. |
From version 1.0.10, a Trust Check query can list several Authorities. It gives one result per Authority, in list order, and every one carries the query’s id with its own authority_id. A rule that matches one result by id therefore matches every Authority of that query. To accept an entity that any one Authority recognises, iterate the results, as in Accept any one Authority:
allow if {
some r in input.trust_check_results.caller
r.id == "authority-recognised"
r.ok
}A rule over every result, such as every r in input.trust_check_results.target { r.ok }, requires every Authority of every query. To require every query, each passing when any of its Authorities recognises the entity, group the results by id, as the All trust checks pass and At least N trust checks pass templates do:
check_ids contains r.id if {
some r in input.trust_check_results.target
}
passed_ids contains r.id if {
some r in input.trust_check_results.target
r.ok == true
}
allow if {
count(check_ids) > 0
count(check_ids - passed_ids) == 0
}To refuse a managed agent the trust registry no longer recognises, while still serving discovery reads where managed_agent is absent, group the results by query id, so that each query passes when any one of its Authorities recognises the agent:
package surface.policy
default allow := false
managed_agent_checks contains r.id if {
some r in input.trust_check_results.managed_agent
}
managed_agent_checks_passed contains r.id if {
some r in input.trust_check_results.managed_agent
r.ok
}
allow if {
count(managed_agent_checks - managed_agent_checks_passed) == 0
}The rule allows every call while the Transit Point has no managed-agent queries, so pair this policy with them. See Require the managed agent to be recognised.
Each result in the array shares the same shape as the Trust Check result fields. For the complete list of error.code values and their categories, see Trust Check error codes.
input.transit
Present on every evaluation of a Transit Point call: the gateway, surface, per-Transit-Point and response policies, and MCP Tool Gating conditions on a Transit Point. Absent on inbound evaluations. It names two principals, each in its own field, because one call can carry both:
input.transit.caller: the end user the transit token names, as the Access Point authenticated them. Without a valid transit token it isanonymous.input.transit.client: the caller the Transit Point’s own Caller authentication verified on this request. Absent when the Transit Point authenticated none.
{
"transit": {
"caller": {
"verified": true,
"verification": "transit_token",
"identity_source": "gateway-computed",
"user_identity_hash": "42628a381c35947c51d560b24315c5590c6f3c217701fcabd95f9fd9697bcd3f",
"did": "did:web:caller.example.com"
},
"client": {
"verification": "source_auth",
"method": "jwt_bearer",
"user_identity_hash": "2155543194a07922605d5396881518ffe9bc6a2dfdc434e250ea1363324f297f",
"subject": "crm-agent"
}
}
}| Field | Type | Description |
|---|---|---|
caller.verified | boolean | true when verification is transit_token, or fabric_peer with a caller the receiving surface verified. It covers user_identity_hash and fields, not did. Test it before reading any other caller field. |
caller.verification | string | transit_token: the call carries a valid transit token whose caller the Access Point authenticated. unverified: a valid token names a caller DID that nothing verified. fabric_peer: the token was issued for a request a paired gateway sent over Fabric. anonymous: the call carries no valid transit token, as on a Transit Point that doesn’t require one and receives none, or on a discovery read. |
caller.identity_source | string | How the caller DID was established. Absent when the token names no DID. |
caller.user_identity_hash | string | The caller’s identity hash. It depends on how the caller authenticated, who issued the credential and the principal, so the same name authenticated another way has another hash. Present only when verified. |
caller.did | string | The caller DID the transit token carries. Always asserted, even when verified is true. Absent for a fabric_peer caller and when the token names none. |
caller.fields | object | Caller claims this Transit Point’s Workload Binding allowlists, from the caller’s verified token. Absent unless verified. |
caller.fabric | object | Present for a fabric_peer caller: peer_gateway_id, peer_issuer_did, hops, and caller_did, the DID the peer named. The gateway verifies the peer gateway itself. caller_did is the DID the peer states for its caller. |
client.verification | string | source_auth when the Transit Point’s Caller authentication verified the caller. |
client.method | string | jwt_bearer, or api_key for both API key methods. |
client.user_identity_hash | string | The client’s identity hash. Absent for a credential that names no subject, such as a JWT without its strategy’s caller identity claim. |
client.subject | string | The verified principal: the value of the JWT’s caller identity claim (sub by default), the Key ID for API key (provider), or the Secret ID for API key (secret store). Absent with the hash. |
On a Transit Point that requires the transit token, caller is the end user. On a Transit Point that authenticates its own callers, client is the agent or service that called it. A Transit Point that does both fills both. A rule about the end user reads caller, and a rule about the calling agent reads client.
To allow only calls whose end user the Access Point verified, test verified and verification:
package surface.policy
default allow := false
allow if {
input.transit.caller.verified
input.transit.caller.verification == "transit_token"
}To allow only named callers on a Transit Point that authenticates its own callers, check that the Transit Point verified the caller before you match its name:
package surface.policy
default allow := false
named_callers := {"crm-agent", "billing-agent"}
allow if {
input.transit.client.verification == "source_auth"
named_callers[input.transit.client.subject]
}A transit token issued for a partner’s request over Fabric reaches the agent with caller.fabric set. Check caller.fabric only as an extra rule on Transit Points that require the transit token: on one that doesn’t, an agent that sends no token leaves the rule unmatched. Which partners reach a surface is set on the Publishing tab of each remote gateway record. See Gateways.
Input availability by evaluation path
Use this table when a policy condition behaves unexpectedly. The field you are checking may simply not be populated on that evaluation path.
The four columns correspond to these evaluation paths:
- Inbound direct: a caller connects to an Access Point on this gateway.
- Sent on to a
fabric://Target: a request arrives at the Access Point of a surface whose Target isfabric://, and the Target’s request policy evaluates the request this gateway sends on to the peer gateway. - Inbound from a connected gateway: this gateway receives, over Fabric, a request a connected gateway forwarded.
- Outbound: the Managed Agent sends a request through a Transit Point to an upstream target.
Condition shorthand used in this table:
- If Caller Context configured: the surface has a Caller Context element, whether or not the request’s credentials validated.
- If enrichment on: Enrich policy input with agent context is on in the Policy element.
- If Trust Checks configured: at least one Trust Check element is configured for this leg.
- If VP present: a verified Verifiable Presentation (VP) was included in the request body.
- If binding VP present: a verified VP from an upstream gateway was processed at the connection point.
✓ = always present on this path. — = never present on this path.
| Field | Inbound direct | Sent on to a fabric:// Target | Inbound from a connected gateway | Outbound |
|---|---|---|---|---|
input.http | ✓ | ✓ | ✓ | ✓ |
input.http.headers | Filtered | Filtered | Filtered | Filtered, from the original inbound request |
input.gateway | ✓ | ✓ | ✓ | ✓ |
input.gateway.direction | "inbound" | "outbound" | "inbound" | "outbound" |
input.gateway.source_id | Absent | Absent | Sending DID | Managed agent DID |
input.gateway.target_id | Absent | Remote gateway DID | Absent | Transit Point endpoint |
input.channel | ✓ | ✓ | ✓ | ✓ |
input.source_auth | If Caller Context configured | If Caller Context configured | If Caller Context configured | If the Transit Point authenticated the caller |
input.mcp | If MCP | If 2026-07-28 MCP | If MCP | If MCP Transit Point |
input.a2a | If A2A | If A2A | If A2A | If A2A Transit Point |
input.agent | If enrichment on | If enrichment on | If enrichment on | If enrichment on |
input.extension_identity | If VP present | — | If VP present | — |
input.identity_binding | — | — | If binding VP present | — |
input.trust_check_results | If Trust Checks configured | If Trust Checks configured | If Trust Checks configured | If Trust Checks configured |
input.transit | — | — | — | ✓ |
Response policy input
A Target response policy and a Transit Point response policy evaluate the response, not the request, so they get their own input. It has no input.http, input.channel, input.gateway or input.trust_check_results. A rule written for a request policy reads absent fields here, evaluates to undefined, and denies every response.
{
"response": {
"status_code": 200,
"body": { "jsonrpc": "2.0", "id": 1, "result": { "content": [] } },
"content_type": "application/json",
"is_error": false
},
"caller": {
"did": "did:web:example.com:agent-1"
},
"surface": {
"id": "surface-abc123",
"name": "my-surface",
"protocol": "mcp"
}
}| Field | Type | Description |
|---|---|---|
input.response.status_code | number | The HTTP status code of the response. |
input.response.body | object | The response body as JSON. Absent when the body isn’t JSON. |
input.response.content_type | string | The response’s Content-Type. Absent when it has none. |
input.response.is_error | boolean | true when the status code is 4xx or 5xx. Always false on a response from an MCP proxy Target, so check status_code there. |
input.caller.did | string | On a Target response policy, the caller’s agent DID when the gateway resolved one. On a Transit Point response policy, the managed agent’s DID. Absent otherwise. |
input.caller.identity_source | string | How the caller’s identity was established, when known. Absent otherwise. |
input.caller.dna_uai | string | The caller’s Agent DNA identifier, when its agent card carries one. Absent otherwise. |
input.surface.id | string | The surface ID. |
input.surface.name | string | The surface name. |
input.surface.protocol | string | The surface protocol, such as mcp or a2a. |
input.transit | object | On a Transit Point response policy only: the same input.transit its request policies get. A rule about who receives the response reads input.transit.caller. |
input.source_auth | object | On a Transit Point response policy only, when the Transit Point’s Caller authentication verified a caller: the same input.source_auth its request policies get. |
input.transit is undefined on a Target response policy, so not input.transit.caller.verified is true there. A rule that denies on it denies every response, and one that allows on it allows every response. In a response policy that can run on the Target, test that input.transit is present first, for example with input.transit.caller.verification, or keep the rule in the Transit Point’s own response policy.
Time-based decisions
A policy can allow or deny a request by the time it is evaluated, for example only during business hours. Rego’s time.now_ns() returns the current time, and time.clock and time.weekday turn it into the hour, minute and day in a time zone you name. The Business-hours access window template writes such a policy from a time window, a list of days and a time zone.
package surface.policy
default allow := false
# Minutes since midnight in the policy's time zone.
access_minute := (hour * 60) + minute if {
[hour, minute, _] := time.clock([time.now_ns(), "Europe/Berlin"])
}
access_day if time.weekday([time.now_ns(), "Europe/Berlin"]) in {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}
# 09:00 (540) until 17:00 (1020), Monday to Friday.
allow if {
access_day
access_minute >= 540
access_minute < 1020
}- Time zone: name it as an IANA time zone, such as
Europe/Berlin,Asia/SingaporeorUTC. The day is the request’s date in that time zone, not in UTC. - Day names:
time.weekdayreturns English day names, such asMonday. - End of the window: a request at the end time is outside the window, so
17:00allows requests until 16:59. - Windows that cross midnight: a window such as 22:00 to 06:00 has two parts, from 22:00 to midnight and from midnight to 06:00, and each part counts on its own date. With Monday to Friday listed, Monday 01:00 is inside the window and Saturday 01:00 is outside it.
- Unreadable time: when the policy can’t read the time in its time zone,
access_minuteis undefined, so noallowrule matches and the request is denied.
The template’s Inside the window setting chooses Allow requests, which allows requests only inside the window, or Deny requests, which denies requests inside it and allows the rest. A request whose time the policy can’t read is denied either way. See Policy templates.
MCP tool policy input
MCP tool policies share the same package declaration (package surface.policy) and query path (data.surface.policy.allow) as surface policies, but get a different input with different field paths.
Use input.jwt for JWT claims in an MCP tool policy. input.source_auth is absent from this input. A rule referencing a field that does not exist evaluates to undefined and silently denies the request.
Full example
{
"mcp": {
"method": "tools/call",
"params": { "name": "search", "arguments": { "query": "hello" } },
"protocol": "json-rpc-2.0"
},
"jwt": {
"role": "admin",
"org": "acme-corp",
"sub": "user@example.com"
},
"channel": {
"name": "my-mcp-surface",
"id": "surface-abc123",
"protocol": "mcp"
},
"request": {
"source_ip": "203.0.113.42",
"method": "POST",
"path": "/my-mcp-surface/mcp"
}
}Fields
| Field | Type | Description |
|---|---|---|
input.mcp.method | string | Always "tools/call": tool policies run only for tool calls. |
input.mcp.params | object | Full parsed params from the tools/call body. Absent when the call has none. The tool name is input.mcp.params.name, and its arguments are input.mcp.params.arguments. |
input.mcp.protocol | string | Always "json-rpc-2.0". |
input.mcp.protocol_version, input.mcp.client_capabilities, input.mcp.client_info | string, object, object | Set for a 2026-07-28 MCP request only. |
input.jwt | object | Flat claims map decoded from the request’s Authorization: Bearer token, without checking its signature. Rely on it only when the surface’s Access Point is closed and its Caller Context methods are all JWT Bearer, which verify the token first. Absent from the input entirely when the caller used a different authentication method. Referencing input.jwt.* without JWT auth evaluates to undefined and silently denies. Access claims directly: input.jwt.role, input.jwt.sub. |
input.channel.name | string | Surface name. |
input.channel.id | string | Surface ID. |
input.channel.protocol | string | Always "mcp" for MCP tool policies. |
input.request.method | string | HTTP method of the request. |
input.request.path | string | HTTP request path. |
input.request.source_ip | string | Source IP address of the caller, or fabric on a request received over Fabric. |
Field name mapping to MCP tool policy input
| In gateway / surface policy | In MCP tool policy | Notes |
|---|---|---|
input.source_auth.claims.* | input.jwt.* | JWT claims are a flat map in the MCP tool policy input. |
input.mcp.tool_name | input.mcp.params.name | In a tool policy, input.mcp.method is always tools/call. |
input.http.method | input.request.method | |
input.http.path | input.request.path | |
input.channel.config_id | input.channel.id | |
| Not available | input.request.source_ip | Source IP only available in MCP tool policies. |
Absent fields and Rego behaviour
Fields that are not populated are omitted entirely from the JSON input. The only field that is ever null is a Trust Check result’s error. In Rego, referencing an absent field evaluates to undefined.
A rule block where any condition is undefined does not contribute to the allow decision. When default allow := false, a rule that silently becomes undefined causes a deny.
# This rule silently denies when input.mcp is absent (non-MCP request)
allow if {
input.mcp.tool_name == "search"
}To write rules that handle both present and absent fields safely, use object.get or check for field existence first:
allow if {
input.source_auth.method == "jwt_bearer"
object.get(input.source_auth, "claims", {}).role == "admin"
}Stripped headers
input.http.headers never contains a header named exactly authorization, proxy-authorization, cookie, or set-cookie, or any header whose name contains token, secret, credential, apikey, or api-key, matched case-insensitively. These are stripped at policy input construction time, on both inbound and outbound requests. Policies cannot read bearer tokens, API key header values, session cookies, or similarly named credential headers from input.http.headers. Use input.source_auth for authenticated identity information instead.
On a Transit Point’s outbound leg, input.http.headers carries the non-sensitive headers from the original inbound request, so a policy on that leg can check a custom header the caller sent (for example a threat-intelligence or classification header) without needing to read it from input.source_auth.
Related
- OPA policies: Conceptual overview of how the gateway evaluates policies, evaluation order, and policy scopes.
- Apply OPA policies to your gateway and surfaces: Create policy definitions and attach them to a gateway or surface.
- Control MCP tool access with per-tool policies: Per-tool policy configuration using the MCP tool policy input.
- Trust registries: How
input.agent.trust_verificationandinput.trust_check_resultsare populated. - Audit log: How policy version and content-hash evidence appears on Audit Log rows and in the event detail panel.
Glad to hear it. Thanks for letting us know.
Sorry to hear that. Thanks for letting us know.
Still stuck? Ask the community on Discord or contact us.