> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/internal-developer-portal/use-idp/self-service-workflows/workflows-tutorials/user-group-dynamic-picker.md).

# Get User Group with Backend Proxy

In this tutorial, you will learn how to create a workflow form with a dynamic dropdown that fetches data from an external API using Harness IDP's backend proxy feature. Specifically, you will build:

* A workflow form with a dynamic dropdown menu for selecting User Groups
* A backend proxy configuration that securely connects to the Harness API
* A dependent field relationship where the Organization is automatically selected based on the chosen Project

<figure><img src="/files/IOhThmb3ivp5nIIyzPY1" alt=""><figcaption></figcaption></figure>

This approach allows you to present users with real-time data from your systems, creating more dynamic and powerful self-service experiences in your Internal Developer Portal.

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Before starting, ensure you have the following:

* **Access to Harness IDP** with permissions to create Workflows and configure Backend Proxies.
* The target API endpoint to fetch data for the dynamic dropdown. In this example, we will use the [Get User Groups API](https://apidocs.harness.io/tag/User-Group#operation/getUserGroupList), which returns a list of user groups within a given project and organization.

## Explore the API and set up the backend proxy <a href="#explore-the-api-and-set-up-the-backend-proxy" id="explore-the-api-and-set-up-the-backend-proxy"></a>

To power your dynamic dropdown, you will use Harness’s public API to fetch user groups for a given project and organization. This data will be used to populate the options in your Workflow form.

#### Understand the API <a href="#understand-the-api" id="understand-the-api"></a>

The API you will use is:

```
GET /ng/api/user-groups?accountIdentifier=<account>&orgIdentifier=<org>&projectIdentifier=<project>
```

This endpoint returns a list of user groups associated with the provided account, org, and project identifiers. You can try this API via [Harness API Explorer](https://apidocs.harness.io/tag/User-Group#operation/getUserGroupList) to see the expected response format and query parameters.

But here is the thing, Workflows cannot directly call external APIs from the UI. That is where **backend proxies** come in.

#### Set up the backend proxy <a href="#set-up-the-backend-proxy" id="set-up-the-backend-proxy"></a>

To safely expose this API to your Workflow UI, you need to define a backend proxy. Here’s how you can do it:

1. Go to **IDP** → **Plugins** → **Configure Backend Proxies**.
2. Add a new proxy configuration.
3. Use the following YAML definition to register the proxy:

```yaml
proxy:
  endpoints:
    /harness-user-groups:
      target: https://app.harness.io/ng/api/user-groups
      pathRewrite:
        /api/proxy/harness-user-groups/?: /
      headers:
        x-api-key: ${PROXY_HARNESS_TOKEN}
```

Let’s break this down:

* `/harness-user-groups` is the proxy path that your Workflow will call.
* The proxy forwards the request to the Harness public API (`https://app.harness.io/ng/api`).
* The `pathRewrite` ensures that requests to `/api/proxy/harness-user-groups` map correctly to the API path `/user-groups`.
* The `x-api-key` header authenticates the request. You can securely store this token as an environment variable.

![proxy](/files/RXKLsJ4lYiG39ybeCY6N) Once saved, this proxy will become accessible from your Workflow form logic. It ensures the API is securely routed through the backend while keeping your tokens safe and abstracted from the frontend.

## Create the workflow and add the dynamic picker <a href="#create-the-workflow-and-add-the-dynamic-picker" id="create-the-workflow-and-add-the-dynamic-picker"></a>

With the backend proxy in place, you can now build a Workflow that uses it to fetch user groups dynamically. Start by going to **IDP** → **Workflows** and clicking **Create Workflow**. In the UI, fill in basic information like the name, identifier, type (`harness_project`), and owner. Once saved, switch to **YAML View** to define the form parameters and logic.

This Workflow form is designed to collect a few key inputs:

* A secure Harness token (optional, if required for downstream API or pipeline access)
* A project selected manually using `HarnessProjectPicker`
* An org auto-derived using `HarnessAutoOrgPicker`
* A dynamic dropdown that calls the proxy you created to fetch user groups

Here’s the full YAML:

```yaml
apiVersion: harness.io/v1
kind: Workflow
name: Get User Groups
identifier: get_user_groups
type: harness_project
owner: backend-group
metadata: {}
spec:
  output:
    links:
      - title: Pipeline Details
        url: ${{ steps.trigger.output.PipelineUrl }}
  lifecycle: production
  parameters:
    - title: Service Details
      properties:
        token:
          title: Harness Token
          type: string
          ui:widget: password
          ui:field: HarnessAuthToken

        projectId:
          title: Project Identifier
          description: Harness Project Identifier
          type: string
          ui:field: HarnessProjectPicker

        orgId:
          title: Org Identifier
          description: Harness Org Identifier
          type: string
          ui:field: HarnessAutoOrgPicker // works with only 'projectId' as dependency

        # highlight-start
        harness_group:
          type: string
          ui:field: SelectFieldFromApi
          ui:options:
            title: User groups
            path: proxy/harness-user-groups?orgIdentifier={{parameters.orgId}}&projectIdentifier={{parameters.projectId}}
            arraySelector: data.content
            valueSelector: identifier
            labelSelector: name
        # highlight-end

  steps:
    - id: trigger
      name: Creating your application
      action: trigger:harness-custom-pipeline
      input:
        url:
          - Harness Pipeline URL
        inputset:
          projectId: ${{ parameters.projectId }}
          orgId: ${{ parameters.orgId }}
          harness_group: ${{ parameters.harness_group }}
        apikey: ${{ parameters.token }}
```

* `ui:field: SelectFieldFromApi`: This special field type tells Harness to create a dropdown that fetches options from an API endpoint.
* `path: proxy/harness-user-groups/user-groups?...`: This points to the backend proxy we configured earlier, passing the selected org and project as query parameters using template variables (`{{parameters.orgId}}` and `{{parameters.projectId}}`).
* `arraySelector: data.content`: This tells the picker where to find the array of items in the API response. In this case, the Harness API returns user groups inside a nested path `data.content`.
* `valueSelector: identifier` and `labelSelector: name`: These define which properties from each user group object should be used as the dropdown's value (stored internally) and label (displayed to the user).

When you run this Workflow, the experience is fully dynamic. After selecting a project, the org field auto-fills, and the user group dropdown fetches data from your proxy in real-time. It displays the group names and passes their identifiers under the hood, exactly what you want for automation or pipeline inputs.
