Contact Us 1-800-596-4880

Configure API Autodiscovery for Local Testing

logo cloud IDE Cloud IDE

logo desktop IDE Desktop IDE

Open Beta Release: The cloud IDE is in open beta. Any use of Anypoint Code Builder in its beta state is subject to the applicable beta services terms and conditions, available from the IDE.

Configure API Autodiscovery to connect your local Mule application to an API instance in API Manager. This setup enables local policy testing before you deploy the application.

Before You Begin

Ensure you have:

Get the API ID

  1. In Anypoint Platform, open API Manager.

  2. In API Administration, select your API instance.

  3. On the API summary page, copy the API Instance ID.

Add the Autodiscovery Element

In your Mule app, add the autodiscovery element in your flow definitions. Use a property reference for apiId so you can load the value through configuration:

<api-gateway:autodiscovery apiId="${api.instance.id}" flowRef="<YOUR_MAIN_FLOW_NAME>" />

Configure Local Credentials

For local execution in Anypoint Code Builder, provide your environment credentials through config.yaml or through Mule runtime arguments in VS Code settings. Avoid hardcoding secrets in Mule XML files.

Set these properties:

  • anypoint.platform.client_id

  • anypoint.platform.client_secret

Example config.yaml:

api.instance.id: "<YOUR_API_ID>"
anypoint.platform.client_id: "<YOUR_ENV_CLIENT_ID>"
anypoint.platform.client_secret: "<YOUR_ENV_CLIENT_SECRET>"

Example Mule runtime arguments:

-M-Danypoint.platform.client_id=<YOUR_ENV_CLIENT_ID> -M-Danypoint.platform.client_secret=<YOUR_ENV_CLIENT_SECRET>

To add these values in Anypoint Code Builder:

  1. Open the Settings tab. Unresolved include directive in modules/ROOT/pages/int-configure-api-autodiscovery-local.adoc - include::reuse::partial$acb-reusable-steps.adoc[]

  2. In the Settings tab, find Mule › Runtime: Default Arguments.

  3. Append the client ID and client secret arguments to the end of the existing arguments.

Append the placeholder values with your client ID and client secret.