To Configure Autodiscovery

You include API Autodiscovery capability in a Mule application to enable API management from Anypoint Platform on the application HTTP endpoint. Include code in your Mule app, or use Studio to incorporate Autodiscovery in your project.

The following configuration.xml shows code that configures Autodiscovery:

<api-platform-gw:api apiName="Q3 API" version="1.0development" flowRef="api-main" create="true" apikitRef="api-config" doc:name="API Autodiscovery">
  <api-platform-gw:description>Consume site statistics and perform Q3 computations</api-platform-gw:description>

For more information about the elements, see the Autodiscovery reference link below.

Studio Configuration

To use API Autodiscovery, first you need to pair Anypoint Studio with an Anypoint Platform organization by adding organization credentials to Studio Preferences. Next, you configure Autodiscovery for each flow you want to manage using a global element. A Global Element contains the necessary information for registering an API to Anypoint Platform. Global Elements must then be referenced by one or more endpoints. Finally, you deploy the API project as a Mule application in Studio. API Manager discovers the API and registers it. The API appears on the API Administration page in Anypoint Platform for each flow you configure for Autodiscovery.

To configure and trigger Autodiscovery:

  1. In a browser, log in to Anypoint Platform as an administrator, click Access Management. Select Organization.

    Select your Organization from the list.

    The client ID and client secret appear.

  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 client ID and client secret from step 2 to Client Credentials.

    autodis pairing

    This action pairs Mule Runtime with your Anypoint Platform organization.

  4. Click Validate to verify that the pairing succeeds.

  5. Click OK.

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

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


    The Choose Global Type dialog appears.

  8. Select Component configurations > API Autodiscovery.

    The Global Element Properties - API Autodiscovery dialog appears.

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

    • In API Name, type an arbitrary name, for example vending.

      If you are creating a new API, API Manager makes this name visible in Anypoint Platform.

    • In API Version, type an arbitrary version identifier, for example 1.0development.

      Do not change the version name later in API Portal, as explained in "Best Practices".

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

    • Check the option to automatically create an API if it doesn’t exist.

    • 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.

      auto disc conf2
    • Click OK.

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

    In a few moments, the API appears on the API Administration page of Anypoint Platform.

    autodisc discovered2

    You need to be a member of the Organization Administrators or API Versions Owner role to see a newly registered API in Anypoint Platform.

Autodiscovery on CloudHub

If you use the Deploy to Anypoint Platform > Cloud context menu to deploy an API or proxy with Autodiscovery to Anypoint Platform, CloudHub automatically replaces${http.port} in your endpoint with <YourUniqueDomain>.cloudhub.io and sends this endpoint URL to the API Manager to be displayed and tracked by the agent.

If your endpoint runs over HTTP, use the variable http.port in its address. If the endpoint runs over HTTPS, use the variable https.port instead.

Configuring and Using Autodiscovery - API Gateway Runtime 2.x

To set up an API for Autodiscovery, you first install an API Gateway Runtime in Studio. For example, install API Gateway Runtime 2.2.0. Next, follow the procedure in the previous section to configure and use Autodiscovery.

Best Practices

Perform the following tasks after using Autodiscovery to deploy an API:

  • API Autodiscovery registers new APIs, API versions, and/or endpoints. If the API already exists, the agent does not compare the name, description, tags, or any other information contained in the global element for updates.

  • After you have registered new APIs or versions using Autodiscovery, visit Anypoint Platform and add the necessary API Versions Owner permissions so that users who need to access the API version details page for this API version can get there.

  • Set the endpoint host to instead of localhost.

  • Do not change the API Version name in API Portal if you have used Autodiscovery. Doing so will break management of the API/

Configure a production API Gateway for integration with Anypoint Platform. For more information, see the link below for configuring API Gateway.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!