labelContact( )


Adds labels to a contact.

Use the Labels API to create or retrieve labels.

Members are typically linked to contacts, and while they share a relationship, the member ID and contact ID are distinct identifiers. Make sure to specify the contact ID when calling Label Contact.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Members and Contacts - all permissions
Manage Contacts
Manage Stores
Learn more about app permissions.
Method Declaration
Copy
function labelContact(
  contactId: string,
  labelKeys: Array<string>,
  options: LabelContactOptions,
): Promise<LabelContactResponse>;
Method Parameters
contactIdstringRequired

ID of the contact to add labels to.


labelKeysArray<string>Required

List of label keys to add to the contact.

Label keys must exist to be added to the contact. Use the Labels API to create or retrieve labels.


optionsLabelContactOptions
Returns
Return Type:Promise<LabelContactResponse>
JavaScript
import { contacts } from "wix-crm.v2"; /* Sample contactId value: '2712ae1d-3f64-46c2-ac3a-94a6c2e29847' * * Sample labelKeys value: * [ * 'custom.at-risk', * 'custom.active-customer' * ] * */ export async function myLabelContactFunction(contactId, labelKeys) { try { const labeledContact = await contacts.labelContact(contactId, labelKeys); console.log("Successfully added labels to contact"); return labeledContact; } catch (error) { console.log(error); // Handle the error } } /* Promise resolves to: * { * "contact": { * "revision": 2, * "source": { * "sourceType": "WIX_CODE", * "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a" * }, * "lastActivity": { * "activityDate": "2023-12-24T11:50:46.048Z", * "activityType": "CONTACT_CREATED" * }, * "primaryInfo": { * "email": "johndoe1@example.com", * "phone": "6465676359" * }, * "info": { * "name": { * "first": "John", * "last": "Doe" * }, * "emails": { * "items": [ * { * "tag": "UNTAGGED", * "email": "johndoe1@example.com", * "primary": true, * "_id": "37db3bde-83c0-4ca2-8097-88964a2f343b" * } * ] * }, * "phones": { * "items": [ * { * "tag": "MOBILE", * "countryCode": "US", * "phone": "646-567-6359", * "e164Phone": "+16465676359", * "primary": true, * "_id": "ed1d7da0-b4a1-4164-81b7-c49dedc25dd7" * } * ] * }, * "addresses": { * "items": [ * { * "tag": "HOME", * "address": { * "formatted": "3 Park Ave\nNY, New York 10010\nUnited States", * "addressLine1": "3 Park Ave", * "city": "NY", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10010" * }, * "_id": "eeb4e174-fd0f-4ce8-8cac-dc152f284228" * } * ] * }, * "company": "Wix", * "jobTitle": "Writer", * "birthdate": "1995-04-25", * "locale": "en-us", * "labelKeys": { * "items": [ * "custom.contact", * "custom.at-risk", * "custom.active-customer" * ] * }, * "extendedFields": { * "items": { * "contacts.displayByLastName": "Doe John", * "invoices.vatId": "", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "emailSubscriptions.subscriptionStatus": "UNSUBSCRIBED", * "contacts.displayByFirstName": "John Doe", * "custom.nickname": "Jonny" * } * } * }, * "_id": "2712ae1d-3f64-46c2-ac3a-94a6c2e29847", * "_createdDate": "2023-12-24T11:50:46.049Z", * "_updatedDate": "2023-12-25T06:13:54.362Z" * } * } * */
Errors
404Not Found

There is 1 error with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?