---
schema_version: "1"
id: 5e28ef595332d4a19dc855ef986c943296828635cdca75541d9131c45fc133d1
title: Configure API Autodiscovery for Local Testing
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/int-configure-api-autodiscovery-local.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/int-configure-api-autodiscovery-local
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a93371b12c2acc42aa7ef30b47ee2ef794901385eb6869aa75894743fab84901
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# Configure API Autodiscovery for Local Testing

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Configure **API Autodiscovery** to connect your local Mule application to an API instance in
[API Manager](https://docs.mulesoft.com/api-manager/latest/latest-overview-concept). This setup enables local policy
testing before you deploy the application.

## Before You Begin

Ensure you have:

- An active API instance in API Manager

- The
  [client ID and client secret from Access Management](https://docs.mulesoft.com/access-management/environments#to-view-the-client-id-and-client-secret-for-an-environment)

## 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

Add API Autodiscovery from **Global Elements**:

1.  Open **Project Properties** > **Global Elements**.

2.  Click **New Configuration**, and select **API Autodiscovery**.

3.  Complete the form and select the flow that Autodiscovery starts.

For more information, see [Managing Global Configuration Elements](https://docs.mulesoft.com/anypoint-code-builder/int-global-config-elements).

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

```xml
<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`:

```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:

```text
-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.

    Show me how

    - From the Anypoint Code Builder panel, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-settings-gear.png) (gear)
      icon.

    - From the activity bar, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-settings-gear.png) (gear) icon, select
      **Settings**, and search for `mule` in the **Settings** tab.

    - Provide the command `MuleSoft: Open ACB Settings` in the
      [Command Palette](https://docs.mulesoft.com/anypoint-code-builder/start-use-command-palette).

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.

## See Also

- [Managing Global Configuration Elements](https://docs.mulesoft.com/anypoint-code-builder/int-global-config-elements)

- [Tracking Requests with Autodiscovery](https://docs.mulesoft.com/anypoint-code-builder/int-autodiscovery-config)
