Often when we have CI/CD process, we need to enforce API policies after creating an API on API Manager.
This article gives steps about how to enforce an API policy via Anypoint Platform API, therefore the procedure can be automated.
Before conducting the procedure below, a Mule Application needs to be registered to the API Instance via autodiscovery process.
export accessToken={Access Token}
export organizationId={Organization ID}
export environmentId={Environment ID}
export environmentApiId={API ID}
curl "https://anypoint.mulesoft.com/apimanager/api/v1/organizations/$organizationId/environments/$environmentId/apis/$environmentApiId/policies" \
-H "Authorization: Bearer $accessToken" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"policyTemplateId": "throttling",
"configurationData": {
"rateLimits": [
{
"timePeriodInMilliseconds": 60000,
"maximumRequests": 10
}
]
},
"groupId": "68ef9520-24e9-4cf2-b2f5-620025690913",
"assetId": "rate-limiting",
"assetVersion": "1.3.1"
}'
Note: 68ef9520-24e9-4cf2-b2f5-620025690913 is MuleSoft group id owning out of box policies
export accessToken={Access Token}
export organizationId={Organization ID}
export environmentId={Environment ID}
export environmentApiId={API ID}
curl "https://anypoint.mulesoft.com/apimanager/api/v1/organizations/$organizationId/environments/$environmentId/apis/$environmentApiId/policies" \
-H "Authorization: Bearer $accessToken"
001117037

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.