unlabelContact( )


Removes labels from a contact.

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.

Method Declaration
Copy
function unlabelContact(
  contactId: string,
  labelKeys: Array<string>,
  options: AuthOptions,
): Promise<Contact>;
Method Parameters
contactIdstringRequired

ID of the contact to remove labels from.


labelKeysArray<string>Required

List of label keys to remove from the contact.


optionsAuthOptions

Authorization options.

Returns
Return Type:Promise<Contact>
Unlabel a contact
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { contacts } from "wix-crm-backend"; export const myUnlabelContactFunction = webMethod(Permissions.Anyone, () => { const contactId = "bc0ae72b-3285-485b-b0ad-c32c769a4daf"; const labelKeys = ["custom.at-risk", "custom.white-glove-treatment"]; const options = { suppressAuth: false, }; return contacts .unlabelContact(contactId, labelKeys, options) .then((unlabeledContact) => { return unlabeledContact; }) .catch((error) => { console.error(error); }); }); /* Promise resolves to: * { * "_id": "bc0ae72b-3285-485b-b0ad-c32c769a4daf", * "_createdDate": "2021-03-30T13:12:39.650Z", * "_updatedDate": "2021-04-07T21:03:39.481Z", * "revision": 2, * "info": { * "name": { * "first": "Gene", * "last": "Lopez" * }, * "birthdate": "1981-11-02", * "jobTitle": "Senior Staff Attorney", * "company": "Borer and Sons, Attorneys at Law", * "locale": "en-us", * "profilePicture": "https://randomuser.me/api/portraits/men/0.jpg", * "addresses": [ * { * "address": { * "formatted": "9834 Bollinger Rd\nEl Cajon, WY 97766\nUS", * "location": { * "latitude": 84.1048, * "longitude": -116.8836 * }, * "city": "El Cajon", * "subdivision": "US-WY", * "country": "US", * "postalCode": "97766", * "streetAddress": { * "name": "Bollinger Rd", * "number": "9834", * "apt": "" * } * }, * "_id": "8532051f-91f2-42d9-9a97-9f2c39e64f7a", * "tag": "HOME" * } * ], * "emails": [ * { * "_id": "5bdcce4a-37c2-46ed-b49c-d562c6e3c4ce", * "tag": "HOME", * "email": "gene.lopez.at.home@example.com", * "primary": true * }, * { * "_id": "78e5f398-e148-448d-b490-7c0b7d2ab336", * "tag": "WORK", * "email": "gene.lopez@example.com", * "primary": false * } * ], * "phones": [ * { * "_id": "820e4640-ffe0-4980-a097-62a715e73135", * "tag": "MOBILE", * "countryCode": "US", * "phone": "(722)-138-3099", * "primary": true * }, * { * "_id": "8506549e-e4f8-42f6-b6fc-9db155b582ef", * "tag": "HOME", * "countryCode": "US", * "phone": "(704)-454-1233", * "e164Phone": "+17044541233", * "primary": false * } * ], * "labelKeys": [ * "contacts.contacted-me", * "custom.new-lead" * ], * "extendedFields": { * "contacts.displayByLastName": "Lopez Gene", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "emailSubscriptions.subscriptionStatus": "NOT_SET", * "custom.event-we-met-at": "LegalBigData", * "emailSubscriptions.effectiveEmail": "gene.lopez.at.home@example.com", * "contacts.displayByFirstName": "Gene Lopez" * } * }, * "lastActivity": { * "activityDate": "2021-03-30T13:12:39.649Z", * "activityType": "CONTACT_CREATED" * }, * "primaryInfo": { * "email": "gene.lopez.at.home@example.com", * "phone": "(722)-138-3099" * }, * "source": { * "sourceType": "OTHER" * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?