secure-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecure Agent
保护 Agent
Overview
概述
Applies a security or traffic management policy to an agent and deploys it to a self-managed Omni Gateway, walking through the full process from identifying the target agent to selecting a policy, configuring it, and deploying. Supports multiple starting points depending on what the user already has set up — an API Manager instance, an Exchange asset, or just an agent specification.
What you'll build: A fully configured policy enforced on your agent instance, deployed to a Omni Gateway
将安全或流量管理策略应用到 Agent,并将其部署到自托管 Omni Gateway,完整流程涵盖识别目标 Agent、选择策略、配置策略并完成部署。根据用户已有的配置,支持多种起始状态——API Manager 实例、Exchange asset,或仅有一份 Agent specification。
你将构建: 在 Agent 实例上强制执行且已部署到 Omni Gateway 的完整策略配置
Architecture
架构
mermaid
sequenceDiagram
participant User
participant Exchange
participant API Manager
participant Omni Gateway
participant Policy Catalog
User->>Exchange: Publish Agent spec
User->>Exchange: Find Agent asset
Exchange-->>User: groupId, assetId, version
User->>API Manager: Create Instance
API Manager-->>User: instanceId
User->>Omni Gateway: Deploy Instance
Omni Gateway-->>User: Deployment active
User->>Policy Catalog: Browse compatible policies
Policy Catalog-->>User: Policy template + config schema
User->>API Manager: Apply policy with config
API Manager-->>Omni Gateway: Policy enforcedmermaid
sequenceDiagram
participant User
participant Exchange
participant API Manager
participant Omni Gateway
participant Policy Catalog
User->>Exchange: Publish Agent spec
User->>Exchange: Find Agent asset
Exchange-->>User: groupId, assetId, version
User->>API Manager: Create Instance
API Manager-->>User: instanceId
User->>Omni Gateway: Deploy Instance
Omni Gateway-->>User: Deployment active
User->>Policy Catalog: Browse compatible policies
Policy Catalog-->>User: Policy template + config schema
User->>API Manager: Apply policy with config
API Manager-->>Omni Gateway: Policy enforcedPrerequisites
前置条件
Before starting, ensure you have:
-
Authentication ready
- Valid Bearer token for Anypoint Platform. If you only have username/password, call (
createLogin) from thePOST /accounts/loginAPI with bodyurn:api:access-managementto obtain a Bearer token first.{"username":"...","password":"..."} - API Manager permissions: View APIs Configuration and Manage Policies scopes
- Valid Bearer token for Anypoint Platform. If you only have username/password, call
-
Organization Id
- Call (
listMe) fromGET /accounts/api/meto get your organization IDurn:api:access-management - Extract from
organizationIdin the response$.user.organization.id - This is used to list environments, browse the policy catalog, check Exchange, etc.
- Call
-
One of the following
- An API instance already in API Manager for the agent (skip to Step 3, then Step 7)
- An agent asset already in Exchange (skip to Step 2)
- An agent specification that needs to be published first (start at Step 1)
开始前,请确保已具备:
-
身份验证已就绪
- 持有 Anypoint Platform 的有效 Bearer token。如果只有用户名/密码,请先调用 API 中的
urn:api:access-management(createLogin),请求体为POST /accounts/login,以获取 Bearer token。{"username":"...","password":"..."} - API Manager 权限:需要 View APIs Configuration 和 Manage Policies scopes
- 持有 Anypoint Platform 的有效 Bearer token。如果只有用户名/密码,请先调用
-
Organization Id
- 调用 中的
urn:api:access-management(listMe)以获取 organization IDGET /accounts/api/me - 从响应中的 提取
$.user.organization.idorganizationId - 该 ID 用于列出环境、浏览策略目录、检查 Exchange 等操作
- 调用
-
以下项目之一
- API Manager 中已有该 Agent 的 API instance(跳至步骤 3,然后执行步骤 7)
- Exchange 中已有 Agent asset(跳至步骤 2)
- 需要先发布的 Agent specification(从步骤 1 开始)
Choose Your Path
选择执行路径
mermaid
flowchart TD
Start{What do you have?} -->|Agent spec only| Full[Full Setup]
Start -->|Asset in Exchange| FromExchange[From Exchange]
Start -->|API Manager instance| PolicyOnly[Apply Policy Only]
Full --> S1[Step 1: Publish to Exchange]
S1 --> S2[Step 2: Find in Exchange]
FromExchange --> S2
S2 --> S3[Step 3: Select Environment]
S3 --> S4[Step 4: Select Gateway Target]
S4 --> S5[Step 5: Create API Instance]
S5 --> S6[Step 6: Deploy to Gateway]
PolicyOnly --> S3b[Step 3: Select Environment]
S3b --> S7[Step 7: List Agent Instances]
S6 --> S8[Step 8: Browse Policies]
S7 --> S8
S8 --> S9[Step 9: Apply Policy]
S9 --> Done[✓ Agent Secured]mermaid
flowchart TD
Start{What do you have?} -->|Agent spec only| Full[Full Setup]
Start -->|Asset in Exchange| FromExchange[From Exchange]
Start -->|API Manager instance| PolicyOnly[Apply Policy Only]
Full --> S1[Step 1: Publish to Exchange]
S1 --> S2[Step 2: Find in Exchange]
FromExchange --> S2
S2 --> S3[Step 3: Select Environment]
S3 --> S4[Step 4: Select Gateway Target]
S4 --> S5[Step 5: Create API Instance]
S5 --> S6[Step 6: Deploy to Gateway]
PolicyOnly --> S3b[Step 3: Select Environment]
S3b --> S7[Step 7: List Agent Instances]
S6 --> S8[Step 8: Browse Policies]
S7 --> S8
S8 --> S9[Step 9: Apply Policy]
S9 --> Done[✓ Agent Secured]Execution Paths
执行路径
This skill has multiple execution paths depending on what you already have:
-
Full setup: Steps 1, 2, 3, 4, 5, 6, 8, 9
- When: You have an agent specification and need to publish it to Exchange first
- You'll need: , agent specification file
organizationId
-
From Exchange asset: Steps 2, 3, 4, 5, 6, 8, 9
- When: The agent is already published in Exchange and you need to find it and create an API Manager instance
- You'll need:
organizationId
-
Apply policy only: Steps 3, 7, 8, 9
- When: You already have an API Manager instance for the agent and want to apply a policy
- You'll need:
organizationId
此 skill 根据你已有的资源提供多种执行路径:
-
完整配置:步骤 1、2、3、4、5、6、8、9
- 适用情况:你有一份 Agent specification,需要先将其发布到 Exchange
- 所需内容:、Agent specification 文件
organizationId
-
从 Exchange asset 开始:步骤 2、3、4、5、6、8、9
- 适用情况:Agent 已发布到 Exchange,你需要找到它并创建 API Manager instance
- 所需内容:
organizationId
-
仅应用策略:步骤 3、7、8、9
- 适用情况:你已经拥有该 Agent 的 API Manager instance,并希望应用策略
- 所需内容:
organizationId
Step 1: Publish Agent to Exchange
步骤 1:将 Agent 发布到 Exchange
Publishes your agent specification to Exchange as a reusable asset. This makes it available for API Manager to create managed instances from it.
What you'll need:
- Organization ID
- Agent specification file
- Asset name, groupId, assetId, and version
Action: Create a new asset in Exchange with your agent specification.
yaml
api: urn:api:exchange-experience
operationId: uploadAsset
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Your organization's Business Group GUID
groupId:
userProvided: true
description: The group ID for the asset (typically matches your organization ID)
example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
assetId:
userProvided: true
description: A unique identifier for the asset in kebab-case
example: "my-agent"
version:
userProvided: true
description: Semantic version for the asset
example: "1.0.0"
outputs:
- name: groupId
path: $.groupId
description: The group ID of the published asset
- name: assetId
path: $.assetId
description: The asset ID of the published asset
- name: assetVersion
path: $.version
description: The version of the published assetWhat happens next: Your agent specification is now available in Exchange. Next, you can search for it to confirm and extract the coordinates needed for API Manager.
将 Agent specification 发布到 Exchange,作为可复用的 asset。这使 API Manager 能够基于它创建受管理的 instance。
所需内容:
- Organization ID
- Agent specification 文件
- Asset 名称、groupId、assetId 和 version
操作: 使用 Agent specification 在 Exchange 中创建新 asset。
yaml
api: urn:api:exchange-experience
operationId: uploadAsset
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Your organization's Business Group GUID
groupId:
userProvided: true
description: The group ID for the asset (typically matches your organization ID)
example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
assetId:
userProvided: true
description: A unique identifier for the asset in kebab-case
example: "my-agent"
version:
userProvided: true
description: Semantic version for the asset
example: "1.0.0"
outputs:
- name: groupId
path: $.groupId
description: The group ID of the published asset
- name: assetId
path: $.assetId
description: The asset ID of the published asset
- name: assetVersion
path: $.version
description: The version of the published asset接下来会发生什么: Agent specification 现已可在 Exchange 中使用。接下来可以搜索它,以确认发布结果并提取 API Manager 所需的坐标信息。
Step 2: Find Agent in Exchange
步骤 2:在 Exchange 中查找 Agent
Search Exchange for agent assets. This search is not scoped to a specific organization — it returns all agent assets visible to the authenticated user across all organizations.
What you'll need:
- Valid Bearer token (from Prerequisites)
Action: Search Exchange filtering by agent asset type and select the target agent.
yaml
api: urn:api:exchange-experience
operationId: searchAssets
inputs:
types:
value: "agent"
description: Filter for agent assets only
outputs:
- name: groupId
path: $[*].groupId
labels: $[*].name
description: Group ID of the selected agent asset
- name: assetId
path: $[*].assetId
description: Asset ID of the selected agent asset
- name: assetVersion
path: $[*].version
description: Version of the selected agent assetWhat happens next: You have the Exchange coordinates (groupId, assetId, version) for the agent. Next, select an environment where the API instance will be created.
在 Exchange 中搜索 Agent asset。此搜索不限定于特定组织——它会返回当前认证用户在所有组织中可见的全部 Agent asset。
所需内容:
- 有效的 Bearer token(见前置条件)
操作: 搜索 Exchange,按 Agent asset 类型筛选,然后选择目标 Agent。
yaml
api: urn:api:exchange-experience
operationId: searchAssets
inputs:
types:
value: "agent"
description: Filter for agent assets only
outputs:
- name: groupId
path: $[*].groupId
labels: $[*].name
description: Group ID of the selected agent asset
- name: assetId
path: $[*].assetId
description: Asset ID of the selected agent asset
- name: assetVersion
path: $[*].version
description: Version of the selected agent asset接下来会发生什么: 你已获得 Agent 的 Exchange 坐标信息(groupId、assetId、version)。接下来,选择一个用于创建 API instance 的环境。
Step 3: List Environments
步骤 3:列出环境
List all environments in the organization so you can confirm or select the one where your agent instance will live.
What you'll need:
- Organization ID
Action: List available environments and select the target.
yaml
api: urn:api:access-management
operationId: listEnvironments
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID from Prerequisites
outputs:
- name: environmentId
path: $.data[*].id
labels: $.data[*].name
description: Selected environment ID (e.g., Production, Sandbox)What happens next: With the environment selected, you can create an API instance or browse policies.
列出组织中的所有环境,以便确认或选择 Agent instance 所在的环境。
所需内容:
- Organization ID
操作: 列出可用环境并选择目标环境。
yaml
api: urn:api:access-management
operationId: listEnvironments
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID from Prerequisites
outputs:
- name: environmentId
path: $.data[*].id
labels: $.data[*].name
description: Selected environment ID (e.g., Production, Sandbox)接下来会发生什么: 选定环境后,即可创建 API instance 或浏览策略。
Step 4: Select Deployment Target
步骤 4:选择部署目标
List available gateway targets registered in the environment. You need the target ID and gateway version before creating the API instance, because the deployment configuration is set via a PATCH after creation.
What you'll need:
- Organization ID and Environment ID
Action: List gateway targets and select the Omni Gateway where the agent will run. Prefer a target with .
status: "RUNNING"yaml
api: urn:api:api-portal-xapi
operationId: getGatewayTargets
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
outputs:
- name: targetId
path: $.rows[*].id
labels: $.rows[*].name
description: Selected gateway target ID
- name: targetName
path: $.rows[*].name
description: Name of the selected gateway target
- name: gatewayVersion
value: "1.0.0"
description: Gateway version to use for deployment. The targets response may return "-" instead of a real version; use "1.0.0" as the default.What happens next: You have a deployment target and its gateway version. Next, create the API instance and then configure its deployment target.
列出环境中已注册的可用 Gateway targets。创建 API instance 前需要 target ID 和 gateway version,因为部署配置是在创建后通过 PATCH 设置的。
所需内容:
- Organization ID 和 Environment ID
操作: 列出 Gateway targets,并选择 Agent 运行所在的 Omni Gateway。优先选择 的 target。
status: "RUNNING"yaml
api: urn:api:api-portal-xapi
operationId: getGatewayTargets
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
outputs:
- name: targetId
path: $.rows[*].id
labels: $.rows[*].name
description: Selected gateway target ID
- name: targetName
path: $.rows[*].name
description: Name of the selected gateway target
- name: gatewayVersion
value: "1.0.0"
description: Gateway version to use for deployment. The targets response may return "-" instead of a real version; use "1.0.0" as the default.接下来会发生什么: 你已获得部署目标及其 gateway version。接下来,创建 API instance,然后配置其部署目标。
Step 5: Create API Manager Instance
步骤 5:创建 API Manager Instance
Creates a managed API instance in API Manager from your agent Exchange asset. This creates the API configuration; deployment to the Omni Gateway happens in Step 6.
Important: For Omni Gateway instances, must be (not ). Setting it to causes a validation error.
isCloudHubnullfalsefalseWhat you'll need:
- Organization ID and Environment ID
- Exchange asset coordinates (groupId, assetId, version)
Action: Create an API instance in the target environment.
yaml
api: urn:api:api-manager
operationId: createApiInstance
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Your organization's Business Group GUID
environmentId:
from:
variable: environmentId
description: Target environment ID from Step 3
groupId:
from:
variable: groupId
description: Exchange asset group ID from Step 2
assetId:
from:
variable: assetId
description: Exchange asset ID from Step 2
assetVersion:
from:
variable: assetVersion
description: Exchange asset version from Step 2
instanceLabel:
userProvided: true
description: A human-readable label for this API instance (e.g., "my-agent-v1")
example: "my-agent-v1"
technology:
value: "flexGateway"
description: Gateway technology — this skill targets Omni Gateway deployments
endpoint.isCloudHub:
value: null
description: "Must be null for flexGateway technology (not false — false causes a validation error)"
endpoint.proxyUri:
userProvided: true
description: "The proxy listener URI. Ask the user which port the Omni Gateway should listen on, then use http://0.0.0.0:<port>/"
example: "http://0.0.0.0:8081/"
endpoint.uri:
userProvided: true
optional: true
description: The upstream backend URL for the agent. Ask the user if they want to provide it now or configure it later.
example: "https://backend.example.com/agent/v1"
outputs:
- name: environmentApiId
path: $.id
description: The API instance ID in API ManagerWhat happens next: The API instance exists but is not yet deployed. Next, deploy it to the Omni Gateway target selected in Step 4.
基于 Agent 的 Exchange asset,在 API Manager 中创建受管理的 API instance。这会创建 API 配置;向 Omni Gateway 的部署将在步骤 6 中完成。
重要: 对于 Omni Gateway instance, 必须为 ,不能为 。设置为 会导致验证错误。
isCloudHubnullfalsefalse所需内容:
- Organization ID 和 Environment ID
- Exchange asset 坐标信息(groupId、assetId、version)
操作: 在目标环境中创建 API instance。
yaml
api: urn:api:api-manager
operationId: createApiInstance
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Your organization's Business Group GUID
environmentId:
from:
variable: environmentId
description: Target environment ID from Step 3
groupId:
from:
variable: groupId
description: Exchange asset group ID from Step 2
assetId:
from:
variable: assetId
description: Exchange asset ID from Step 2
assetVersion:
from:
variable: assetVersion
description: Exchange asset version from Step 2
instanceLabel:
userProvided: true
description: A human-readable label for this API instance (e.g., "my-agent-v1")
example: "my-agent-v1"
technology:
value: "flexGateway"
description: Gateway technology — this skill targets Omni Gateway deployments
endpoint.isCloudHub:
value: null
description: "Must be null for flexGateway technology (not false — false causes a validation error)"
endpoint.proxyUri:
userProvided: true
description: "The proxy listener URI. Ask the user which port the Omni Gateway should listen on, then use http://0.0.0.0:<port>/"
example: "http://0.0.0.0:8081/"
endpoint.uri:
userProvided: true
optional: true
description: The upstream backend URL for the agent. Ask the user if they want to provide it now or configure it later.
example: "https://backend.example.com/agent/v1"
outputs:
- name: environmentApiId
path: $.id
description: The API instance ID in API Manager接下来会发生什么: API instance 已创建,但尚未部署。接下来,将其部署到步骤 4 中选择的 Omni Gateway target。
Step 6: Deploy to Omni Gateway
步骤 6:部署到 Omni Gateway
Deploys the API instance to the selected Omni Gateway target. This uses the Proxies API deployment endpoint with flat top-level fields — do not use the nested object, which requires additional fields that are not needed for self-managed Omni Gateway deployments.
targetWhat you'll need:
- Organization ID, Environment ID, and API instance ID from Step 5
- Deployment target ID and gateway version from Step 4
Action: Create a deployment for the API instance on the selected Omni Gateway.
yaml
api: urn:api:proxies-xapi
operationId: createProxyDeployment
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3 (used in both the URL path and the request body for HY deployment type)
environmentApiId:
from:
variable: environmentApiId
description: API instance ID from Step 5
type:
value: "HY"
description: "Deployment type for self-managed Omni Gateway (HY = Hybrid)"
targetId:
from:
variable: targetId
description: Omni Gateway target ID from Step 4
targetName:
from:
variable: targetName
description: Omni Gateway target name from Step 4
gatewayVersion:
value: "1.0.0"
description: "Gateway version for deployment. Use \"1.0.0\" as the default."
overwrite:
value: false
description: "Whether to overwrite an existing deployment"
outputs:
- name: deploymentId
path: $.id
description: The ID of the proxy deploymentRequest body structure: Use flat top-level fields, not the nested object:
targetjson
{
"type": "HY",
"targetId": "<from Step 4>",
"targetName": "<from Step 4>",
"gatewayVersion": "1.0.0",
"environmentId": "<from Step 3>",
"overwrite": false
}What happens next: The agent instance is now deployed to the Omni Gateway. Next, browse the policy catalog to select which policy to apply.
Common issues:
- : The
"Field environmentId is required for deployment type HY"must be in the request body, not just the URL path parameter.environmentId - : Use the version from the
"Field gatewayVersion is required for deployment type HY"response (Step 4). Using an incorrect version causes policy implementation errors.getGatewayTargets - : The
"Policy implementations cannot be set because runtime version is unknown"value doesn't match a known Omni Gateway version. Verify the version from the target's actual runtime version in Step 4.gatewayVersion - 409 Conflict: The agent may already be deployed to this target. List existing deployments with first to check.
GET .../deployments
将 API instance 部署到所选的 Omni Gateway target。此处使用 Proxies API 的 deployment endpoint,并采用扁平化的顶层字段——不要使用嵌套的 对象,因为后者需要 self-managed Omni Gateway deployment 不需要的额外字段。
target所需内容:
- 步骤 5 中的 Organization ID、Environment ID 和 API instance ID
- 步骤 4 中的部署 target ID 和 gateway version
操作: 在所选 Omni Gateway 上为 API instance 创建 deployment。
yaml
api: urn:api:proxies-xapi
operationId: createProxyDeployment
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3 (used in both the URL path and the request body for HY deployment type)
environmentApiId:
from:
variable: environmentApiId
description: API instance ID from Step 5
type:
value: "HY"
description: "Deployment type for self-managed Omni Gateway (HY = Hybrid)"
targetId:
from:
variable: targetId
description: Omni Gateway target ID from Step 4
targetName:
from:
variable: targetName
description: Omni Gateway target name from Step 4
gatewayVersion:
value: "1.0.0"
description: "Gateway version for deployment. Use \"1.0.0\" as the default."
overwrite:
value: false
description: "Whether to overwrite an existing deployment"
outputs:
- name: deploymentId
path: $.id
description: The ID of the proxy deployment请求体结构: 使用扁平的顶层字段,而不是嵌套的 对象:
targetjson
{
"type": "HY",
"targetId": "<from Step 4>",
"targetName": "<from Step 4>",
"gatewayVersion": "1.0.0",
"environmentId": "<from Step 3>",
"overwrite": false
}接下来会发生什么: Agent instance 现已部署到 Omni Gateway。接下来,浏览策略目录并选择要应用的策略。
常见问题:
- :
"Field environmentId is required for deployment type HY"必须位于请求体中,而不能只存在于 URL 路径参数中。environmentId - :使用
"Field gatewayVersion is required for deployment type HY"响应中的 version(步骤 4)。使用不正确的版本会导致策略实现错误。getGatewayTargets - :
"Policy implementations cannot be set because runtime version is unknown"值与已知 Omni Gateway 版本不匹配。请根据步骤 4 中 target 的实际 runtime version 验证版本。gatewayVersion - 409 Conflict:Agent 可能已部署到此 target。请先使用 列出已有 deployments,以进行检查。
GET .../deployments
Step 7: List Agent Instances
步骤 7:列出 Agent Instances
Lists agent instances in the selected environment by filtering with . Use this step when you already have an API Manager instance for the agent and need to find its ID to apply a policy.
family=agenticWhat you'll need:
- Organization ID and Environment ID
Action: List agent instances and select the target.
yaml
api: urn:api:api-manager
operationId: listApiInstances
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
family:
value: "agentic"
description: Filter for agent (agentic) instances only
outputs:
- name: environmentApiId
path: $.assets[*].apis[*].id
labels: $.assets[*].apis[*].autodiscoveryInstanceName
description: The agent instance ID in API ManagerWhat happens next: You have the agent instance ID. Next, browse the policy catalog to select which policy to apply.
通过 过滤,列出所选环境中的 Agent instances。当你已经拥有该 Agent 的 API Manager instance,并需要找到其 ID 以应用策略时,使用此步骤。
family=agentic所需内容:
- Organization ID 和 Environment ID
操作: 列出 Agent instances 并选择目标。
yaml
api: urn:api:api-manager
operationId: listApiInstances
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
family:
value: "agentic"
description: Filter for agent (agentic) instances only
outputs:
- name: environmentApiId
path: $.assets[*].apis[*].id
labels: $.assets[*].apis[*].autodiscoveryInstanceName
description: The agent instance ID in API Manager接下来会发生什么: 你已获得 Agent instance ID。接下来,浏览策略目录并选择要应用的策略。
Step 8: Browse Exchange Policy Catalog
步骤 8:浏览 Exchange 策略目录
List all available policy templates from Exchange for your organization. This endpoint returns the full Exchange coordinates (, , ) and gateway-compatible configuration for each template — these are required when applying a policy.
groupIdassetIdassetVersionImportant: Use the endpoint () instead of the generic endpoint. The generic endpoint does not return Exchange coordinates or gateway-specific configuration property names, which are required for the apply step.
api-portal-xapigetExchangePolicyTemplateslistPolicyTemplatesWhat you'll need:
- Organization ID
- Environment ID and API instance ID (to filter for compatible templates)
Action: List Exchange policy templates and select the one to apply. Pass and to filter for templates compatible with your agent's gateway type (e.g., Omni Gateway, Mule Gateway).
apiInstanceIdenvironmentIdyaml
api: urn:api:api-portal-xapi
operationId: getExchangePolicyTemplates
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
apiInstanceId:
from:
variable: environmentApiId
description: API instance ID from Step 5 or Step 7 (filters for compatible templates)
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
latest:
value: "true"
description: Return only the latest version of each template
includeConfiguration:
value: "true"
description: Include the configuration schema for each template
outputs:
- name: policyGroupId
path: $[*].groupId
labels: $[*].assetId
description: Exchange group ID of the selected policy template
- name: policyAssetId
path: $[*].assetId
description: Exchange asset ID of the selected policy template
- name: policyAssetVersion
path: $[*].version
description: Exchange version of the selected policy template (gateway-compatible)
- name: policyConfiguration
path: $[*].configuration
description: Configuration schema with gateway-compatible property names and defaultsWhat happens next: You have the policy template's Exchange coordinates and its configuration schema with the correct property names for your gateway type. Review the output to understand what settings the policy accepts before applying it.
policyConfigurationCommon issues:
- Empty list: Pass and
apiInstanceIdto get templates compatible with your gateway type. Without these filters, some templates may not appear.environmentId - Wrong config property names: Always use the configuration from this endpoint — the generic endpoint may return different (non-gateway-compatible) property names and defaults.
listPolicyTemplates
为组织列出 Exchange 中所有可用的 policy templates。此 endpoint 会为每个 template 返回完整的 Exchange 坐标信息(、、)以及 gateway-compatible configuration——这些信息在应用策略时必需。
groupIdassetIdassetVersion重要: 使用 endpoint(),不要使用通用的 endpoint。通用 endpoint 不会返回 Exchange 坐标信息或 gateway-specific configuration property names,而应用策略时需要这些内容。
api-portal-xapigetExchangePolicyTemplateslistPolicyTemplates所需内容:
- Organization ID
- Environment ID 和 API instance ID(用于筛选兼容的 templates)
操作: 列出 Exchange policy templates 并选择要应用的 template。传入 和 ,以筛选与 Agent 的 gateway type 兼容的 templates,例如 Omni Gateway、Mule Gateway。
apiInstanceIdenvironmentIdyaml
api: urn:api:api-portal-xapi
operationId: getExchangePolicyTemplates
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
apiInstanceId:
from:
variable: environmentApiId
description: API instance ID from Step 5 or Step 7 (filters for compatible templates)
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
latest:
value: "true"
description: Return only the latest version of each template
includeConfiguration:
value: "true"
description: Include the configuration schema for each template
outputs:
- name: policyGroupId
path: $[*].groupId
labels: $[*].assetId
description: Exchange group ID of the selected policy template
- name: policyAssetId
path: $[*].assetId
description: Exchange asset ID of the selected policy template
- name: policyAssetVersion
path: $[*].version
description: Exchange version of the selected policy template (gateway-compatible)
- name: policyConfiguration
path: $[*].configuration
description: Configuration schema with gateway-compatible property names and defaults接下来会发生什么: 你已获得 policy template 的 Exchange 坐标信息,以及包含适用于当前 gateway type 的正确 property names 的 configuration schema。应用策略前,请查看 输出,以了解该策略支持哪些设置。
policyConfiguration常见问题:
- 列表为空:传入 和
apiInstanceId,以获取与 gateway type 兼容的 templates。不使用这些筛选条件时,某些 templates 可能不会显示。environmentId - configuration property names 错误:始终使用此 endpoint 返回的 configuration——通用 endpoint 可能返回不同的、非 gateway-compatible 的 property names 和 defaults。
listPolicyTemplates
Step 9: Apply Policy to Instance
步骤 9:将策略应用到 Instance
Apply the selected policy to your agent instance with the appropriate configuration. Use the Exchange coordinates and configuration property names from Step 8.
What you'll need:
- Organization ID, Environment ID, and API instance ID
- Policy Exchange coordinates (groupId, assetId, assetVersion) from Step 8
- Policy configuration based on the schema from Step 8's output
policyConfiguration
Action: Apply the policy to your API instance. Build the object using the property names from Step 8's configuration schema. For each configuration property, present the user with the property name, its description, and the default value, then ask if they want to keep the default or provide a custom value. If a property has no default, always ask the user for a value.
configurationDatayaml
api: urn:api:api-manager
operationId: applyApiInstancePolicy
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
environmentApiId:
from:
variable: environmentApiId
description: API instance ID from Step 5 or Step 7 (or provided manually)
groupId:
from:
variable: policyGroupId
description: Policy Exchange group ID from Step 8
assetId:
from:
variable: policyAssetId
description: Policy Exchange asset ID from Step 8
assetVersion:
from:
variable: policyAssetVersion
description: Policy Exchange version from Step 8
outputs:
- name: policyId
path: $.id
description: The ID of the applied policy instanceWhat happens next: Your agent is now protected with the selected policy. Since the API instance was configured with deployment information in Step 6, the policy is active and enforcing on the Omni Gateway.
Common issues:
- 400 Bad Request — missing groupId/assetId/assetVersion: The apply endpoint requires full Exchange coordinates, not just a template ID. Make sure you used (Step 8) to get these values.
getExchangePolicyTemplates - 400 Bad Request — invalid configurationData: The configuration property names differ between gateway types. Use the property names from Step 8's output, not from the generic template endpoint. For example, Omni Gateway uses
policyConfigurationwhile the generic template usescredentialsOriginHasHttpBasicAuthenticationHeader.credentialsOrigin - 409 Conflict: A policy of this type may already be applied to the API instance. List existing policies first to check, or add to the request URL to apply a second instance of the same policy type.
?allowDuplicated=true - 403 Forbidden: You need Manage Policies permission in the target environment.
使用适当的 configuration,将所选策略应用到 Agent instance。使用步骤 8 中的 Exchange 坐标信息和 configuration property names。
所需内容:
- Organization ID、Environment ID 和 API instance ID
- 步骤 8 中的 Policy Exchange 坐标信息(groupId、assetId、assetVersion)
- 基于步骤 8 的 输出所确定的 Policy configuration
policyConfiguration
操作: 将策略应用到 API instance。使用步骤 8 configuration schema 中的 property names 构建 对象。对于每个 configuration property,向用户展示 property name、description 和 default value,然后询问用户是保留 default 还是提供 custom value。如果某个 property 没有 default,则始终要求用户提供 value。
configurationDatayaml
api: urn:api:api-manager
operationId: applyApiInstancePolicy
inputs:
organizationId:
from:
api: urn:api:access-management
operation: listMe
field: $.user.organization.id
description: Organization ID
environmentId:
from:
variable: environmentId
description: Environment ID from Step 3
environmentApiId:
from:
variable: environmentApiId
description: API instance ID from Step 5 or Step 7 (or provided manually)
groupId:
from:
variable: policyGroupId
description: Policy Exchange group ID from Step 8
assetId:
from:
variable: policyAssetId
description: Policy Exchange asset ID from Step 8
assetVersion:
from:
variable: policyAssetVersion
description: Policy Exchange version from Step 8
outputs:
- name: policyId
path: $.id
description: The ID of the applied policy instance接下来会发生什么: Agent 现已受到所选策略的保护。由于 API instance 已在步骤 6 中配置了 deployment 信息,因此策略已启用,并在 Omni Gateway 上执行。
常见问题:
- 400 Bad Request — 缺少 groupId/assetId/assetVersion:apply endpoint 需要完整的 Exchange 坐标信息,而不只是 template ID。请确保使用了 (步骤 8)获取这些值。
getExchangePolicyTemplates - 400 Bad Request — configurationData 无效:不同 gateway type 的 configuration property names 不同。请使用步骤 8 的 输出中的 property names,而不要使用通用 template endpoint 返回的 property names。例如,Omni Gateway 使用
policyConfiguration,而通用 template 使用credentialsOriginHasHttpBasicAuthenticationHeader。credentialsOrigin - 409 Conflict:API instance 上可能已经应用了此类型的策略。请先列出已有 policies 以进行检查,或者在请求 URL 中添加 ,以应用第二个相同类型的 policy instance。
?allowDuplicated=true - 403 Forbidden:你需要在目标环境中拥有 Manage Policies 权限。
Completion Checklist
完成检查清单
After completing all steps, verify:
- Agent instance is bound to the Omni Gateway target (deployment info visible in API Manager)
- Policy appears in the API instance's policy list
- Policy status shows as "Active"
- Agent requests are being evaluated against the policy rules
- Policy configuration matches your requirements
完成所有步骤后,请验证:
- Agent instance 已绑定至 Omni Gateway target(API Manager 中可见 deployment 信息)
- Policy 出现在 API instance 的 policy list 中
- Policy 状态显示为 "Active"
- Agent 请求正在依据 policy rules 进行评估
- Policy configuration 符合你的需求
What You've Built
你已经构建的内容
Your agent is now protected with:
- Policy enforcement — Selected policy is active on your agent instance. All incoming traffic is evaluated against policy rules.
- Bound to Omni Gateway — API instance is created with deployment configuration targeting a self-managed Omni Gateway. The Omni Gateway picks up the configuration automatically.
- Managed configuration — Policy settings are version-controlled in API Manager. Configuration can be updated without redeploying the agent.
你的 Agent 现在受到以下机制的保护:
- Policy enforcement——所选 Policy 已在 Agent instance 上处于活动状态。所有传入流量都会依据 policy rules 进行评估。
- Bound to Omni Gateway——创建 API instance 时已配置 deployment,目标为 self-managed Omni Gateway。Omni Gateway 会自动获取该配置。
- Managed configuration——Policy settings 在 API Manager 中进行版本控制。无需重新部署 Agent,即可更新 configuration。
Next Steps
后续步骤
-
Test the policy
- Send test requests to verify the policy is enforcing correctly
- Check that authorized requests pass and unauthorized ones are blocked
-
Add more policies
- Run this skill again to layer additional policies (e.g., rate limiting + OAuth2)
- Policy ordering matters — adjust priority in API Manager if needed
-
Monitor policy activity
- Check API Manager analytics for policy enforcement metrics
- Set up alerts for unusual rejection patterns
-
测试策略
- 发送测试请求,验证策略是否正确执行
- 检查已授权请求是否通过,以及未授权请求是否被阻止
-
添加更多策略
- 再次运行此 skill,叠加其他策略,例如 rate limiting + OAuth2
- Policy 顺序很重要——如有需要,可在 API Manager 中调整 priority
-
监控策略活动
- 查看 API Manager analytics 中的策略执行指标
- 为异常拒绝模式设置 alerts
Tips and Best Practices
提示与最佳实践
Policy Selection
策略选择
- Rate Limiting: Use when you need to control traffic volume per client
- OAuth 2.0: Use for token-based authentication and authorization
- IP Allowlist/Blocklist: Use to restrict access by network origin
- Client ID Enforcement: Use to require registered client applications
- Rate Limiting:用于控制每个客户端的流量规模
- OAuth 2.0:用于基于 token 的身份验证和授权
- IP Allowlist/Blocklist:用于按网络来源限制访问
- Client ID Enforcement:用于要求 client applications 已注册
Policy Ordering
策略顺序
- Authentication policies should be applied first (lowest order number)
- Rate limiting should come after authentication
- Transformation policies should be last
- Authentication policies 应最先应用(order number 最低)
- Rate limiting 应在 authentication 之后应用
- Transformation policies 应最后应用
Gateway Compatibility
Gateway 兼容性
- Always use with
getExchangePolicyTemplatesto get gateway-compatible templatesapiInstanceId - Configuration property names and defaults vary by gateway type (Omni Gateway vs. Mule Gateway)
- The Exchange template version may differ from the generic template version
- 始终将 与
getExchangePolicyTemplates一起使用,以获取 gateway-compatible templatesapiInstanceId - Configuration property names 和 defaults 会因 gateway type 而异(Omni Gateway 与 Mule Gateway)
- Exchange template version 可能与通用 template version 不同
Agent Discovery
Agent 发现
- The Exchange search in Step 2 is not org-scoped — it returns all agents visible to the authenticated user
- Use the asset field to identify the correct agent when multiple results are returned
name - If you published the agent in Step 1, its coordinates are already available — Step 2 can be used to confirm
- 步骤 2 中的 Exchange search 不按 org 限定——它会返回 authenticated user 可见的所有 Agents
- 当返回多个结果时,使用 asset 的 field 识别正确的 Agent
name - 如果已在步骤 1 发布 Agent,其坐标信息已经可用——可使用步骤 2 进行确认
Troubleshooting
故障排除
Policy Not Enforcing
策略未生效
Symptoms: Requests pass through without policy evaluation
Possible causes:
- API instance is not deployed or is in an error state
- Policy configuration has a permissive default that allows all traffic
- Policy is applied but not yet propagated (wait 1-2 minutes)
Solutions:
- Check API instance status in API Manager
- Review policy configuration for overly permissive settings
- Wait for propagation and retry
症状: 请求未经策略评估便直接通过
可能原因:
- API instance 尚未部署或处于 error state
- Policy configuration 使用了允许所有流量通过的 permissive default
- Policy 已应用,但尚未 propagated(等待 1–2 分钟)
解决方案:
- 检查 API Manager 中的 API instance status
- 审查 Policy configuration 中是否有过于宽松的设置
- 等待 propagation 完成,然后重试
Policy Blocks All Requests
策略阻止所有请求
Symptoms: All requests return 401 or 403, even legitimate ones
Possible causes:
- Policy configuration is too restrictive
- Required credentials are not being sent correctly
- Policy expects headers or parameters in a specific format
Solutions:
- Review the policy configuration schema for required fields
- Check that client applications are sending credentials in the expected format
- Temporarily disable the policy to isolate the issue
症状: 即使是合法请求,也全部返回 401 或 403
可能原因:
- Policy configuration 过于严格
- 所需 credentials 未正确发送
- Policy 要求 headers 或 parameters 使用特定格式
解决方案:
- 检查 Policy configuration schema 中的必填字段
- 检查 client applications 是否按预期格式发送 credentials
- 临时禁用策略以隔离问题
400 Error When Applying Policy
应用策略时出现 400 错误
Symptoms:
"The policy to be created is missing at least one of the following properties related to the policy template: 'groupId', 'assetId', 'assetVersion'."Possible causes:
- Used the generic endpoint which does not return Exchange coordinates
listPolicyTemplates
Solutions:
- Use from
getExchangePolicyTemplatesinstead — this returns the full Exchange coordinates needed by the apply endpointapi-portal-xapi
症状:
"The policy to be created is missing at least one of the following properties related to the policy template: 'groupId', 'assetId', 'assetVersion'."可能原因:
- 使用了通用 endpoint,该 endpoint 不会返回 Exchange 坐标信息
listPolicyTemplates
解决方案:
- 改用 中的
api-portal-xapi——它会返回 apply endpoint 所需的完整 Exchange 坐标信息getExchangePolicyTemplates
Agent Not Found in Exchange
在 Exchange 中未找到 Agent
Symptoms: Step 2 returns an empty list
Possible causes:
- The agent has not been published to Exchange yet
- The asset type is not
agent
Solutions:
- Start from Step 1 to publish the agent to Exchange first
- Verify the asset was published with the correct type
症状: 步骤 2 返回空列表
可能原因:
- Agent 尚未发布到 Exchange
- Asset type 不是
agent
解决方案:
- 从步骤 1 开始,先将 Agent 发布到 Exchange
- 验证 Asset 已使用正确的 type 发布
Related Jobs
相关 Jobs
- secure-api: The equivalent skill for securing standard APIs with policies
- secure-mcp-server: The equivalent skill for securing MCP servers with policies
- apply-policy-to-api-instance: Apply a policy when you already have an API instance (simpler flow)
- secure-api:用于通过策略保护标准 API 的等效 skill
- secure-mcp-server:用于通过策略保护 MCP servers 的等效 skill
- apply-policy-to-api-instance:当已有 API instance 时应用策略的简化流程