Configuring Mule Gateway API Autodiscovery in a Mule 3 Application | MuleSoft Documentation
# Configuring Mule Gateway API Autodiscovery in a Mule 3 Application
To configure API Autodiscovery in your Mule 3.x application, you must meet the following requirements:
## Making your API Available in API Manager
The API to which you want to pair your Mule application must be available in API Manager. You can either:
  * Publish your API in Exchange and import it from there to API Manager. See To Manage an API from Exchange.
  * Import it directly from your machine. See To Import an API Instance for more details.


API Manager exposes the API Name and version that you generated in the tasks above. These API Name and Version are required by the Autodiscovery element to identify the API to which you want to pair your application.
## Configuring Anypoint Platform Organization Credentials in Mule Runtime
To use Autodiscovery in a Mule Application, the Runtime must start with Anypoint Platform credentials already configured. Learn how to configure your organization credentials based on your deployment target in Configuring Organization Credentials in Mule Runtime 3.
## Configuring the Autodiscovery Element in Your Mule Application
Within the code of your Mule Application, you must configure the `api-gateway:auto-discovery` element. The Autodiscovery element points to the specific API in API Manager to which you want to pair.
If you configured a proxy endpoint for your API, your autogenerated proxy will already be correctly configured with the Autodiscovery element.   
---  
XML element
```
<api-platform-gw:api
 apiName="${apiName}" **(1)**
 version="${apiVersion}" **(2)**
 flowRef="proxy" **(3)**
 apikitRef="api-config"/> **(4)**
```

Configure the `${apiName}` with the UUID, which is the group ID and the Exchange asset ID assigned to your API by API Manager.  
---  
Configure the `${apiVersion}` with the API Version, which is the version name and the instance ID or the label assigned to your API by API Manager.  
Set the `flowRef` element to point to the flow that you want to pair to the API in API Manager.  
If you use APIkit and you would like to apply policies at a resource level, you must set this value. Otherwise said policies won’t work at resource level.  
You can either replace `${apiName}` and `${apiVersion}` with your specific value, or you can create a `config.properties` file where you define it in a key-value fashion: `apiName=[your-specific-value]` and reference it as `${apiName}` and `${apiVersion}` in this configuration.
You can also configure this using Anypoint Studio’s UI:
  1. In your existing flow, select the Global Elements tab in your Mule Configuration File editor.
  2. Click the Create button, and look for the API Autodiscovery global element.
  3. Set the APIname, version, and Flow Reference.
You can also choose to use the `${apiName}` and `${apiVersion}` value and reference it from a `config.properties` file.


After the element is defined in the application, and the runtime is configured with your Anypoint Platform credentials, Mule Runtime will automatically track and keep up to date with the API configuration. defined in API Manager.
## See Also
  * Reviewing Mule Gateway API Autodiscovery concepts