[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eApigee allows users to program API behavior without coding by using policies, which are modules that implement specific management functions.\u003c/p\u003e\n"],["\u003cp\u003ePolicies offer features like security, rate-limiting, transformation, and mediation, and can be extended with custom scripts and code.\u003c/p\u003e\n"],["\u003cp\u003ePolicies can be created and attached to API proxies or shared flows using Apigee in Cloud Code, with specific procedures outlined for each.\u003c/p\u003e\n"],["\u003cp\u003eCreating a policy involves selecting a policy category, giving the policy a unique name, and potentially creating resources depending on the policy type.\u003c/p\u003e\n"],["\u003cp\u003eTo be executed, policies must be attached to a flow by adding a \u003ccode\u003e<Step>\u003c/code\u003e element to the appropriate request or response flow in a ProxyEndpoint or TargetEndpoint configuration.\u003c/p\u003e\n"]]],[],null,["# Adding features using policies\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\n\u003cbr /\u003e\n\nApigee lets you program API behavior without writing any code by using *policies*. A policy is like a module that implements a specific, limited management function. Policies are designed to let you efficiently and reliably add common types of management capabilities to an API.\n\nPolicies provide features like security, rate-limiting, transformation, and mediation capabilities, saving you from having to build and maintain the code on your own. You're not limited to the set of policy types provided by Apigee. You can also write custom scripts and code (such as JavaScript applications) that extend API proxy functionality and enable you to innovate on top of the basic management capabilities supported by Apigee policies.\n\n[Create](#create) and [attach](#attach) policies to API proxies and shared flows using Apigee in Cloud Code as described in the following sections. Depending on the policy type, you may need to create a resource, as described in [Managing resources](/apigee/docs/api-platform/local-development/vscode/manage-resources). See also [Managing folders and files in an Apigee workspace](/apigee/docs/api-platform/local-development/vscode/manage-apigee-workspace#manage-folders-files).\n| **Before you begin** : Familiarize yourself with the concepts described in the following topics:\n|\n| - [What's a policy?](/apigee/docs/api-platform/develop/policy-attachment-and-enforcement)\n| - [Policy reference overview](/apigee/docs/api-platform/reference/policies/reference-overview-policy)\n| - [FlowCallout policy](/apigee/docs/api-platform/reference/policies/flow-callout-policy)\n\n### Creating a policy\n\nTo create a policy using Apigee in Cloud Code:\n\n1. In your Apigee workspace, perform one of the following actions based on where you want to attach the policy:\n\nThe Create policy wizard opens.\n\n1. Select the category of the policy that you want to create from the list.\n For a description of the policy categories, see [Policy reference overview](/apigee/docs/api-platform/reference/policies/reference-overview-policy).\n\n2. Enter a unique name for the policy and press **\u003ckbd\u003eEnter\u003c/kbd\u003e** .\n The policy is added to the `/policies` folder for the API proxy or shared flow in the Apigee section and opened in the editor.\n\n3. Edit the file, as required, and select **File \\\u003e Save** or ⌘S to save your edits.\n For more information about configuring the policy, see [Policy reference overview](/apigee/docs/api-platform/reference/policies/reference-overview-policy).\n\n4. Create resources if required by the policy type, as described in [Managing resources](/apigee/docs/api-platform/local-development/vscode/manage-resources).\n\n### Attaching a policy to a flow\n\nPolicies are not executed until they are attached to a flow. You can attach a policy to a flow by adding the **\\\u003cStep\\\u003e** element to the appropriate request or response flow element in a ProxyEndpoint or TargetEndpoint configuration, as described in the following topics:\n\n- [Attaching a policy to a ProxyEndpoint or TargetEndpoint flow](/apigee/docs/api-platform/develop/attaching-policy-proxyendpoint-or-targetendpoint-flow)\n- [FlowCallout policy](/apigee/docs/api-platform/reference/policies/flow-callout-policy)\n\nFor example, the following configuration attaches a [QuotaPolicy](/apigee/docs/api-platform/reference/policies/quota-policy) to the `\u003cPreFlow\u003e` of the ProxyEndpoint to configure the number of request messages that an API proxy allows over a period of time. \n\n```\n\u003cProxyEndpoint name=\"default\"\u003e\n \u003cPreFlow\u003e\n \u003cRequest\u003e\n \u003cStep\u003e\u003cName\u003eQuotaPolicy\u003c/Name\u003e\u003c/Step\u003e\n \u003c/Request\u003e\n \u003c/PreFlow\u003e\n \u003cHTTPProxyConnection\u003e\n \u003cBasePath\u003e/weather\u003c/BasePath\u003e\n \u003c/HTTPProxyConnection\u003e\n \u003cRouteRule name=\"default\"\u003e\n \u003cTargetEndpoint\u003edefault\u003c/TargetEndpoint\u003e\n \u003c/RouteRule\u003e\n\u003c/ProxyEndpoint\u003e\n```"]]