To Configure Auto-Discovery (Nov 2017)

You include API auto-discovery capability in a Mule application to enable API management from Anypoint Platform on the application HTTP endpoint.

You need to create an instance (Nov 2017) or version (Jul 2017) of an API before setting up auto-discovery. The way you set up auto-discovery depends on the Mule version you use to deploy the API.

  • Mule 4

    Include the API ID-based auto-discovery element in the configuration.xml.

  • Mule 3.x: Use one of the following procedures:

    • Include the name and version-based auto-discovery element in the configuration.xml.


    • Set up the global auto-discovery element in Studio 6.

This topic describes how to incorporate auto-discovery in your Mule 4.x or Mule 3.x Runtime.

To Configure the Auto-Discovery XML Element for Mule 4.x Runtime

In Mule 4, the apiId and a reference to the API’s main flow identify the API. The main flow is where the HTTP listener is defined. The apiId in Mule 4 replaces the API Name and API Version used to specify auto-discovery in releases before Mule 4.

  1. On the API administration dashboard, expand the API version name to display the instances.

    instances jsonplaceholder
  2. Click an instance name.

    The API ID appears.

    api id
  3. Use the following syntax to specify the apiId in the configuration.xml:

    <api-gateway:autodiscovery apiId="${}" flowRef="proxy" />

To Configure the Auto-Discovery XML Element for Mule 3.x Runtime

In Mule 3.x, the API name and version reference to the API’s main flow identify the API. The main flow is where the HTTP listener is defined.

  1. In API Administration, click the API version name.

    click version

    The version details page, which shows the API name and version, appears.

    name version
  2. Use the following syntax to specify the apiName and version in the configuration.xml:

    <api-gateway:autodiscovery apiName="${apiName}" version="${apiVersion}" flowRef="proxy" />

    The API name consists of a UUID, which is the group ID and the Exchange asset ID. The API version consists of the version name and the instance ID or the label.

To Configure Auto-Discovery in Studio (Mule Runtime 3.x)

In this procedure, you pair Anypoint Studio with an Anypoint Platform environment in your organization by adding environment credentials to Studio Preferences. You configure auto-discovery for each flow you want to manage using a global element.

Prepare to use API auto-discovery:

  1. In Design Center, create an API for each flow you plan to implement in a Mule app.

  2. In Design Center, publish the APIs in Exchange.

  3. In API Manager, set the APIs to manage them from Exchange.

Set up auto-discovery:

  1. In a browser, log in to Anypoint Platform as an administrator, click Access Management > Environments. Click an environment.

    The environment client ID and client secret appear.

    env clientid clientsecret
  2. From the Anypoint Studio main menu, select Anypoint Studio > Preferences > Anypoint Studio > Anypoint Platform for APIs.

    The Preferences dialog for Anypoint Platform for APIs appears.

  3. Copy the environment client ID and client secret from step 1 to Client Credentials.


    This action pairs Mule Runtime with your Anypoint Platform organization’s environment.

  4. Click Validate to verify that the pairing succeeds.

  5. In Project Explorer, select the app. For example, select api.xml in src/main/app that you created in the APIkit tutorial.

  6. On the Global Elements tab on the canvas, click Create.


    The Choose Global Type dialog appears.

  7. Select Component Configurations > API Autodiscovery.

    The Global Element Properties - API Autodiscovery dialog appears.

  8. Create a global element to declare the details of the API version you want Anypoint Platform to discover:

    • In API Name, type the name of the API that you set up to manage from API Manager.

    • In API Version, type the version identifier as registered in API Manager, for example 1.0.

    • In Flow Name, select the name of the flow in the API to which you want to direct requests. For example, select api-main, the APIkit tutorial main flow.

    • In APIkit Router Configuration, click api-config from the drop-down in the case of the APIkit tutorial.

      This configuration is not used by API Manager.

    • In Description, write some documentation about the API.


  9. In Project Explorer, right-click the app, api.xml in this example, and select Run As > Mule Application.