When you develop and deploy your first API to MuleSoft’s Anypoint Platform, it’s important that you set up API Autodiscovery to enable critical features such as security policies and DDOS protection. API Autodiscovery works by linking your Mule application with your application available in API Manager. You can then enable various policies in API Manager and see those working in realtime on your deployed Mule app.
If you haven't already, make sure to sign up for a free Anypoint Platform account. Click the button below to create a free account.
The first step to managing your API and enabling security policies is to Create a new API in API Manager.
Configure your API and make sure to select the box if you are using Mule 4 or above.
When you create your new API, you will be granted an API Autodiscory API ID. You will need to input your Autodiscovery API ID in Anypoint Studio to link your mule application with your API in API Manager.
In your Anypoint Studio project, go to Global Elements, click the Create button, then select API Autodiscovery.
Enter your API ID from API Manager and select the flow that will be linked, then click OK. Remember, if you have a local.properties file, you can store your API ID as a variable in that file and reference it by using the dollar sign notion such as:
Learn more by visiting the documentation.
After you have input your API Autodiscovery API ID, navigate back to Anypoint Platform and go to Access Management. Go to your Environments, and select the Environment you are going to deploy too. You will need to copy and paste your Client ID and Client Secret and include those properties in your Deployment Properties in Anypoint Studio.
Enter your Client ID and Client Secret in your deployment window. Use the properties:
After your application finishes deploying, you should see the status of your API set as Active in API Manager. Now you can enforce policies directly from API Manager without needing to redeploy your mule application.
Setting up API Autodiscovery in Anypoint Studio is really as simple as following the few steps above. If you want to learn more about how to set up automated security polices and API design best practices, read the following tutorial by clicking here. If you found this tutorial helpful, please rate it below and visit the developer tutorials homepage for more tutorials like this.