How to set up API Autodiscovery in Anypoint Studio

api autodiscovery
Developer Relations
10 min read

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.

Step 1: Create a new API in API Manager

The first step to managing your API and enabling security policies is to Create a new API in API Manager.

create new API

Configure your API and make sure to select the box if you are using Mule 4 or above.

mule version

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.

autodiscovery test
Step 2: Configure Anypoint Studio with API Autodiscovery

In your Anypoint Studio project, go to Global Elements, click the Create button, then select API Autodiscovery.

setup autodiscovery

Enter your API ID from API Manager and select the flow that will be linked, then click OK. Remember, if you have a file, you can store your API ID as a variable in that file and reference it by using the dollar sign notion such as: ${apiId}
Learn more by visiting the documentation.

Step 3: Deploy with environment credentials

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:
anypoint.platform.client_id: CLIENT_ID
anypoint.platform.client_secret: CLIENT_SECRET


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.

autodiscovery testautodiscovery

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.

Try Anypoint Platform for free

Start free trial

Already have an account? Sign in.

Related tutorials