> 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

# GetLabel

# Package: contacts

# Namespace: ContactLabelsServiceV4

# Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/labels/get-label.md

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

## Introduction

Retrieves a label by the specified label key.

---

## REST API

### Schema

```
 Method: getLabel
 Description: Retrieves a label by the specified label key.
 URL: https://www.wixapis.com/contacts/v4/labels/{key}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  key
 Method parameters: 
   param name: key | type:   none | required: true 
   query 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: GetLabelResponse
  - name: label | type: ContactLabel | description: The specified 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

### Get Label
```curl
curl -X GET 'https://www.wixapis.com/contacts/v4/labels/custom.my-label' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.crm.labels.getLabel(key, options)
 Description: Retrieves a label by the specified label key.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  key
 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: options | type: GetLabelOptions  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

### Get the display name for a specified label (with elevated permissions)
```javascript
import { labels } from '@wix/crm';
import { auth } from '@wix/essentials';

/* Sample key value: 'custom.at-risk' */

export async function myGetLabelFunction(key) {
  
  try {
    const elevatedGetLabel = auth.elevate(labels.getLabel);
    const label = await elevatedGetLabel(key);   
    const displayName = label.displayName; 
    console.log('successfully retrieved the display name:', displayName);
 
    return displayName;  
  } catch (error) {
    console.log(error);
    // Handle the error
  }
}

// Return value: "At Risk"
```

### Get the display name for a specified label
```javascript
import { labels } from '@wix/crm';

/* Sample key value: 'custom.at-risk' */

export async function myGetLabelFunction(key) {
  
  try {
    const label = await labels.getLabel(key);   
    const displayName = label.displayName; 
    console.log('successfully retrieved the display name:', displayName);
 
    return displayName;  
  } catch (error) {
    console.log(error);
    // Handle the error
  }
}

// Return value: "At Risk"
```

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

/* Sample key value: 'custom.at-risk' */

const elevatedGetLabel = auth.elevate(labels.getLabel);

export async function myGetLabelFunction(key) {
  
  try {
    const label = await elevatedGetLabel(key);    
    console.log('successfully retrieved label:', label);
 
    return label;  
  } catch (error) {
    console.log(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "namespace": "custom",
 *   "namespaceDisplayName": "Labels",
 *   "key": "custom.at-risk",
 *   "displayName": "At Risk",
 *   "labelType": "USER_DEFINED",
 *   "legacyId": "65bd6a68-e10e-4831-8d92-c90e75be1570",
 *   "_createdDate": "2023-12-25T08:38:36.000Z",
 *   "_updatedDate": "2023-12-25T08:38:36.000Z"
 * }
 */
```

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

/* Sample key value: 'custom.at-risk' */

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

/* Promise resolves to:
 * {
 *   "namespace": "custom",
 *   "namespaceDisplayName": "Labels",
 *   "key": "custom.at-risk",
 *   "displayName": "At Risk",
 *   "labelType": "USER_DEFINED",
 *   "legacyId": "65bd6a68-e10e-4831-8d92-c90e75be1570",
 *   "_createdDate": "2023-12-25T08:38:36.000Z",
 *   "_updatedDate": "2023-12-25T08:38:36.000Z"
 * }
 */
```

### getLabel (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 getLabel(key,options) {
  const response = await myWixClient.labels.getLabel(key,options);
};
```

---