> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# UpdateLabel

# Package: contacts

# Namespace: ContactLabelsServiceV4

# Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/labels/update-label?apiView=SDK.md

## Permission Scopes:
Manage Contact Labels: SCOPE.DC-CONTACTS.MANAGE-LABELS

## Introduction

Renames a label.

---

## REST API

### Schema

```
 Method: updateLabel
 Description: Renames a label.
 URL: https://www.wixapis.com/contacts/v4/labels/{label.key}
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  label.key, label.displayName
 Method parameters: 
   param name: label | type: ContactLabel | description: Label that was found or created.  
        - name: key | type: string | description: Label key.  `key` is generated when the label is created. It can't be modified, even if `displayName` is updated. | required: true | read-only: true | validation: minLength 1, maxLength 80
        - name: displayName | type: string | description: Label display name shown in the dashboard. | required: true | validation: minLength 1, maxLength 180
   param name: language | type: language | description: Language for localization. 2-letter language code in [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) format.  | validation: format LANGUAGE
 Return type: UpdateLabelResponse
  - name: label | type: ContactLabel | description: Renamed label.  
     - name: namespace | type: string | description: Label namespace.  Labels created by calling the Find Or Create Label method are automatically assigned to the `custom` namespace.  | read-only: true | validation: minLength 1, maxLength 25
     - name: namespaceDisplayName | type: string | description: Display name for the namespace, used to organize the list of labels in the site dashboard.  | read-only: true | validation: minLength 1, maxLength 180
     - name: key | type: string | description: Label key.  `key` is generated when the label is created. It can't be modified, even if `displayName` is updated.  | read-only: true | validation: minLength 1, maxLength 80
     - name: displayName | type: string | description: Label display name shown in the dashboard.  | validation: minLength 1, maxLength 180
     - name: labelType | type: LabelType | description: Label type indicating how the label was created.  | read-only: true 
         - enum:
         -     SYSTEM: Default system label for the contact list.
         -     USER_DEFINED: Label created by calling the Find Or Create Label method.
         -     WIX_APP_DEFINED: Label created by an app built by Wix.
     - name: createdDate | type: string | description: Date and time the label was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the label was last updated.  | read-only: true | validation: format date-time


```

### Examples

### Update Label
```curl
curl -X PATCH 'https://www.wixapis.com/contacts/v4/labels/custom.my-label' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  --data-raw '{
      "displayName": "My New Label Name"
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.crm.labels.renameLabel(key, label, options)
 Description: Renames a label.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  key, label.displayName, label
 Method parameters: 
   param name: key | type: string | description: Label key.  `key` is generated when the label is created. It can't be modified, even if `displayName` is updated. | required: true | validation: minLength 1, maxLength 80
   param name: label | type: RenameLabel | description: Label that was found or created. | required: true 
        - name: displayName | type: string | description: Label display name shown in the dashboard. | required: true | validation: minLength 1, maxLength 180
   param name: options | type: UpdateLabelOptions  none  
        - name: language | type: string | description: Language for localization. 2-letter language code in [ISO 639-1 alpha-2](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) format.  | validation: format LANGUAGE
 Return type: PROMISE<ContactLabel>
  - name: namespace | type: string | description: Label namespace.  Labels created by calling the Find Or Create Label method are automatically assigned to the `custom` namespace.  | read-only: true | validation: minLength 1, maxLength 25
  - name: namespaceDisplayName | type: string | description: Display name for the namespace, used to organize the list of labels in the site dashboard.  | read-only: true | validation: minLength 1, maxLength 180
  - name: key | type: string | description: Label key.  `key` is generated when the label is created. It can't be modified, even if `displayName` is updated.  | read-only: true | validation: minLength 1, maxLength 80
  - name: displayName | type: string | description: Label display name shown in the dashboard.  | validation: minLength 1, maxLength 180
  - name: labelType | type: LabelType | description: Label type indicating how the label was created.  | read-only: true 
     - enum:
     -     SYSTEM: Default system label for the contact list.
     -     USER_DEFINED: Label created by calling the Find Or Create Label method.
     -     WIX_APP_DEFINED: Label created by an app built by Wix.
  - name: _createdDate | type: Date | description: Date and time the label was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the label was last updated.  | read-only: true 


```

### Examples

### Rename a label (with elevated permissions)
```javascript
import { labels } from '@wix/crm';
import { auth } from '@wix/essentials';

/* Sample key value:
 *
 * 'custom.active-customer'
 * 
 * Sample label object:
 * {
 *   displayName: "Customer"
 * }
 */

const elevatedRenameLabel = auth.elevate(labels.renameLabel);

export async function myRenameLabelFunction(key, label) {
  
  try {
      const renamedLabel = await elevatedRenameLabel(key, label);
      console.log('successfully renamed label:', renamedLabel);
   
      return renamedLabel;  
    } catch (error) {
      console.log(error);
      // Handle the error
    }
  }

/* Promise resolves to:
 * {
 *   "namespace": "custom",
 *   "namespaceDisplayName": "Labels",
 *   "key": "custom.active-customer",
 *   "displayName": "Customer",
 *   "labelType": "USER_DEFINED",
 *   "legacyId": "74f1e5c6-d9d5-4485-b272-13081ea35f38",
 *   "_createdDate": "2023-12-25T06:13:21.000Z",
 *   "_updatedDate": "2023-12-25T09:14:37.000Z"
 * }
 */
```

### Rename a label
```javascript
import { labels } from '@wix/crm';

/* Sample key value:
 *
 * 'custom.active-customer'
 * 
 * Sample label object:
 * {
 *   displayName: "Customer"
 * }
 */

export async function myRenameLabelFunction(key, label) {
  
  try {
      const renamedLabel = await labels.renameLabel(key, label);
      console.log('successfully renamed label:', renamedLabel);
   
      return renamedLabel;  
    } catch (error) {
      console.log(error);
      // Handle the error
    }
  }

/* Promise resolves to:
 * {
 *   "namespace": "custom",
 *   "namespaceDisplayName": "Labels",
 *   "key": "custom.active-customer",
 *   "displayName": "Customer",
 *   "labelType": "USER_DEFINED",
 *   "legacyId": "74f1e5c6-d9d5-4485-b272-13081ea35f38",
 *   "_createdDate": "2023-12-25T06:13:21.000Z",
 *   "_updatedDate": "2023-12-25T09:14:37.000Z"
 * }
 */
```

### renameLabel (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { labels } from '@wix/crm';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { labels },
  // Include the auth strategy and host as relevant
});


async function renameLabel(key,label,options) {
  const response = await myWixClient.labels.renameLabel(key,label,options);
};
```

---