> 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/feature-management-experimentation/management-and-administration/api-best-practices/examples/find-flags.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Find feature flags dependent on a specific flag

Learn how to find all feature flags that have a dependency on a feature flag name using the Admin API.

## Overview <a href="#overview" id="overview"></a>

Use this script to find all feature flags that have a dependency on a given feature flag within a specific environment and workspace.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* Install the [Python Admin API Wrapper](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/wrappers/python-admin-api.md).
* You have created an Admin API key from the Harness FME UI.
* Make sure you have the workspace and environment names where your flags are defined.

## Configuration <a href="#configuration" id="configuration"></a>

Before running the script, update the following variables in the code:

* `ADMIN API KEY`: Your Admin API key.
* `workspaceName`: Name of your workspace.
* `environmentName`: Name of the environment.
* `splitName`: The feature flag you want to check dependencies for.

Run this script using Python 3 from your local machine or preferred development environment.

```python
from splitapiclient.main import get_client

#############################################
workspaceName="Default"
environmentName="Production"
splitName = "mysplit"
#############################################

client = get_client({'apikey': 'ADMIN API KEY'})
ws = client.workspaces.find(workspaceName)
env = client.environments.find(environmentName, ws.id)

for spDef in client.split_definitions.list(env.id, ws.id):
    for rule in spDef._rules:
        if rule._condition != {}:
            for matcher in rule._condition['matchers']:
                if 'depends' in matcher:
                    if matcher['depends']['splitName']==splitName:
                        print ("Found dependency: "+spDef.name)
```

## Next steps

* Go to [Delete a list of feature flags and flag definitions](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/delete-list.md) to delete flags and their definitions.
* Go to [Get a list of feature flags with rollout status](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/get-list.md) to list flags with their rollout status.

{% @harness-feedback/feedback %}
