> 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/customer-attribute.md).

# Create a Customer Attribute and Update Existing Customer Identity

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

Use this script to create customer attributes and update existing customer keys with identity values in a given environment.

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

* Install the [Python Admin API Wrapper](/feature-management-experimentation/management-and-administration/api-best-practices/wrappers/python-admin-api.md).
* You've created an Admin API key from the Split UI.

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

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

* `ADMIN API KEY`: Your Split Admin API key.
* `workspaceName`: The name of the workspace.
* `environmentName`: The name of the environment.
* `trafficTypeName`: The name of the traffic type.
* `customerKey`: The name of the customer key.

Run this script using Python 3 from your local machine or preferred development environment. The script creates two attributes (Age and Country) and adds values for them to the given customer key.

{% hint style="info" %}
`SaveCustomerIdentity()` wipes out any previous stored identities for the customer key. `UpdateCustomerIdentity()` only updates the identities in the call.
{% endhint %}

```python
from splitapiclient.main import get_client

#############################################
workspaceName="Default"
environmentName="Production"
trafficTypeName="employees"
customerKey="dave"
#############################################

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

at1 = tp.add_attribute({"id": "attrib90", "displayName": "Age", "description": "age",
"dataType": "STRING", "isSearchable": False, "workspaceId": ws.id})
at2 = tp.add_attribute({"id": "attrib11", "displayName": "Country", "description": "country name",
"dataType": "STRING", "isSearchable": False, "workspaceId": ws.id})

# Adding 50 as age <a href="#adding-50-as-age" id="adding-50-as-age"></a>
at = tp.add_identity({'key': customerKey, 'values': {'attrib456': '50'}, 'environmentId': env.id})
# Adding USA as country <a href="#adding-usa-as-country" id="adding-usa-as-country"></a>
at = tp.add_identity({'key': customerKey, 'values': {'attrib11': 'USA'}, 'environmentId': env.id})
```
