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