Search.../

unlabelContact( )

Removes labels from a contact.

Description

The unlabelContact() function returns a Promise that resolves when the specified labels are removed from the contact.

If a label is no longer needed and you want to remove it from all contacts, you can delete it with deleteLabel().

Note: Only visitors with Manage Contacts permissions can unlabel contacts. You can override the permissions by setting the suppressAuth option to true.

Syntax

function unlabelContact(contactId: string, labelKeys: Array<string>, [options: AuthOptions]): Promise<Contact>

unlabelContact Parameters

NAME
TYPE
DESCRIPTION
contactId
string

ID of the contact to remove labels from.

labelKeys
Array<string>

List of label keys to remove from the contact.

options
Optional
AuthOptions

Authorization options.

Returns

Fulfilled - Updated contact.

Return Type:

Promise<Contact>
NAME
TYPE
DESCRIPTION
_id
string

Contact ID.

revision
number

Revision number, which increments by 1 each time the contact is updated. To prevent conflicting changes, the existing revision must be used when updating a contact.

source
Source

Details about the contact's source.

_createdDate
Date

Date and time the contact was created.

_updatedDate
Date

Date and time the contact was last updated.

lastActivity
LastActivity

Details about the contact's last action in the site.

primaryInfo
PrimaryInfo

Contact's primary phone and email.

info
Info

Contact's details.

Was this helpful?

Unlabel a contact

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm-backend';
3
4export const myUnlabelContactFunction = webMethod(Permissions.Anyone, () => {
5 const contactId = "bc0ae72b-3285-485b-b0ad-c32c769a4daf";
6 const labelKeys = [
7 "custom.at-risk",
8 "custom.white-glove-treatment"
9 ];
10 const options = {
11 suppressAuth: false
12 };
13
14 return contacts.unlabelContact(contactId, labelKeys, options)
15 .then((unlabeledContact) => {
16 return unlabeledContact;
17 })
18 .catch((error) => {
19 console.error(error);
20 });
21});
22
23/* Promise resolves to:
24 * {
25 * "_id": "bc0ae72b-3285-485b-b0ad-c32c769a4daf",
26 * "_createdDate": "2021-03-30T13:12:39.650Z",
27 * "_updatedDate": "2021-04-07T21:03:39.481Z",
28 * "revision": 2,
29 * "info": {
30 * "name": {
31 * "first": "Gene",
32 * "last": "Lopez"
33 * },
34 * "birthdate": "1981-11-02",
35 * "jobTitle": "Senior Staff Attorney",
36 * "company": "Borer and Sons, Attorneys at Law",
37 * "locale": "en-us",
38 * "profilePicture": "https://randomuser.me/api/portraits/men/0.jpg",
39 * "addresses": [
40 * {
41 * "address": {
42 * "formatted": "9834 Bollinger Rd\nEl Cajon, WY 97766\nUS",
43 * "location": {
44 * "latitude": 84.1048,
45 * "longitude": -116.8836
46 * },
47 * "city": "El Cajon",
48 * "subdivision": "US-WY",
49 * "country": "US",
50 * "postalCode": "97766",
51 * "streetAddress": {
52 * "name": "Bollinger Rd",
53 * "number": "9834",
54 * "apt": ""
55 * }
56 * },
57 * "_id": "8532051f-91f2-42d9-9a97-9f2c39e64f7a",
58 * "tag": "HOME"
59 * }
60 * ],
61 * "emails": [
62 * {
63 * "_id": "5bdcce4a-37c2-46ed-b49c-d562c6e3c4ce",
64 * "tag": "HOME",
65 * "email": "gene.lopez.at.home@example.com",
66 * "primary": true
67 * },
68 * {
69 * "_id": "78e5f398-e148-448d-b490-7c0b7d2ab336",
70 * "tag": "WORK",
71 * "email": "gene.lopez@example.com",
72 * "primary": false
73 * }
74 * ],
75 * "phones": [
76 * {
77 * "_id": "820e4640-ffe0-4980-a097-62a715e73135",
78 * "tag": "MOBILE",
79 * "countryCode": "US",
80 * "phone": "(722)-138-3099",
81 * "primary": true
82 * },
83 * {
84 * "_id": "8506549e-e4f8-42f6-b6fc-9db155b582ef",
85 * "tag": "HOME",
86 * "countryCode": "US",
87 * "phone": "(704)-454-1233",
88 * "e164Phone": "+17044541233",
89 * "primary": false
90 * }
91 * ],
92 * "labelKeys": [
93 * "contacts.contacted-me",
94 * "custom.new-lead"
95 * ],
96 * "extendedFields": {
97 * "contacts.displayByLastName": "Lopez Gene",
98 * "emailSubscriptions.deliverabilityStatus": "NOT_SET",
99 * "emailSubscriptions.subscriptionStatus": "NOT_SET",
100 * "custom.event-we-met-at": "LegalBigData",
101 * "emailSubscriptions.effectiveEmail": "gene.lopez.at.home@example.com",
102 * "contacts.displayByFirstName": "Gene Lopez"
103 * }
104 * },
105 * "lastActivity": {
106 * "activityDate": "2021-03-30T13:12:39.649Z",
107 * "activityType": "CONTACT_CREATED"
108 * },
109 * "primaryInfo": {
110 * "email": "gene.lopez.at.home@example.com",
111 * "phone": "(722)-138-3099"
112 * },
113 * "source": {
114 * "sourceType": "OTHER"
115 * }
116 * }
117 */