> 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/index.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Admin API examples

Learn how to automate common tasks using the Admin API.

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

Whether you are managing feature flags at scale, migrating between environments, or reporting on usage, these examples are designed to help platform and release engineering teams speed up workflows and enforce governance.

## Common use cases <a href="#common-use-cases" id="common-use-cases"></a>

You can use these sample scripts to automate common tasks with the Admin API.

{% hint style="info" %}
All examples use the Python PyPi library for the Admin API, and require access tokens with Admin permissions. Go to [Python PyPi Library](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/wrappers/python-admin-api.md) for setup instructions.
{% endhint %}

### Flag lifecycle management <a href="#flag-lifecycle-management" id="flag-lifecycle-management"></a>

The following examples cover flag lifecycle management:

* [Find all Feature Flags that depend on a given flag](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/find-flags.md)
* [Delete a list of Feature Flags and their definitions](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/delete-list.md)
* [Export all feature flag definitions to JSON files](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/export-flag-definitions.md)
* [Copy feature flags with their definitions between projects](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/copy-flags.md)
* [Copy and overwrite feature flag definitions between environments](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/copy-flag-definition.md)
* [Export feature flags treatments to YAML file](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/export-treatments.md)
* [Get list of feature flags in an environment with rollout status](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/get-list.md)
* [Report flags with 100% treatment and no changes since a given date](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/report-flags.md)

### Targeting and segments <a href="#targeting-and-segments" id="targeting-and-segments"></a>

The following examples cover targeting and segments:

* [Import thousands of keys to an existing segment](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/import-keys.md)
* [Delete thousands of keys from a segment](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/delete-keys.md)
* [Copy segment content to another segment](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/copy-segment.md)
* [Add segment to individual targets for a group of feature flags](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/add-segment.md)
* [Add user keys to individual targets in a flag](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/add-keys.md)
* [Add targeting rule to an existing feature flag](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/add-targeting-rule.md)

### User and identity management <a href="#user-and-identity-management" id="user-and-identity-management"></a>

The following examples cover user and identity management:

* [Fetch list of all feature flag users](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/fetch-list.md)
* [Create custom attribute and update an existing Identity](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/customer-attribute.md)

### Metadata and reporting <a href="#metadata-and-reporting" id="metadata-and-reporting"></a>

The following examples cover metadata and reporting:

* [Extract list of tags for flags and segments](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/extract-list.md)
* [Export flags that have not received impressions since a certain date](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/examples/export-flags.md)

{% @harness-feedback/feedback %}
