> 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 # UpdateLabel # Package: contacts # Namespace: ContactLabelsServiceV4 # Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/labels/update-label.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 - name: displayName | type: string | description: Label display name shown in the dashboard. | required: true 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: 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. - 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 ### Update Label ```curl curl -X PATCH 'https://www.wixapis.com/contacts/v4/labels/custom.my-label' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-raw '{ "displayName": "My New Label Name" }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.contacts.ContactLabelsServiceV4.updateLabel(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 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 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. 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 ### 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-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 renameLabel(key,label,options) { const response = await myWixClient.labels.renameLabel(key,label,options); }; ``` ---