> 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`). > - 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. 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. - name: namespaceDisplayName | type: string | description: Display name for the namespace, used to organize the list of labels in the site dashboard. - 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. - name: displayName | type: string | description: Label display name shown in the dashboard. - name: labelType | type: LabelType | description: Label type indicating how the label was created. - 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. - name: updatedDate | type: string | description: Date and time the label was last updated. ``` ### Examples ### Get Label ```curl curl -X GET 'https://www.wixapis.com/contacts/v4/labels/custom.my-label' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.contacts.ContactLabelsServiceV4.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 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. Return type: PROMISE - name: namespace | type: string | description: Label namespace. Labels created by calling the Find Or Create Label method are automatically assigned to the `custom` namespace. - name: namespaceDisplayName | type: string | description: Display name for the namespace, used to organize the list of labels in the site dashboard. - 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. - name: displayName | type: string | description: Label display name shown in the dashboard. - name: labelType | type: LabelType | description: Label type indicating how the label was created. - 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. - name: _updatedDate | type: Date | description: Date and time the label was last updated. ``` ### 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-hosted) Self-hosted 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); }; ``` ---