About the Labels API

The Labels API provides functionality for managing labels for your site. Labels allow site admins to segment or categorize the contacts in their Contact List. Using Labels enchances the CRM by allowing site admins to customize data organization according to their needs. For example, you can use labels to target specific audiences for email campaigns or bulk actions. Learn more about labels.

With the Labels API, you can:

Terminology

  • Label: A tag that is applied to contacts to help site admins organzie and group contacts with shared characteristics. Labels can be either user-defined or system-defined.
    • User-defined label: A label that is custom created by site admins.
    • System-defined label: A label that is pre-defined in your site and cannot be deleted from the CRM.
Was this helpful?
Yes
No

Setup

To use the Labels API, install the @wix/crm package using npm or Yarn:

Copy
1
npm install @wix/crm

or

Copy
1
yarn add @wix/crm

Then import { labels } from @wix/crm:

Copy
1
import { labels } from '@wix/crm'
Was this helpful?
Yes
No

deleteLabel( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes a label from the site and removes it from contacts it applies to.

The deleteLabel() function returns a Promise that resolves when the specified label is deleted.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Contact Labels
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function deleteLabel(key: string): Promise<void>
Method Parameters
keystringRequired

Label key to delete.

Was this helpful?
Yes
No

findOrCreateLabel( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a label with a given name, or creates one if it doesn't exist.

The findOrCreateLabel() function returns a Promise that resolves when the specified label is found or created.

Successful calls to findOrCreateLabel() always returns a label, which can be passed to subsequent function calls.

To find an existing label without potentially creating a new one, use getLabel() or queryLabels().

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Contact Labels
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function findOrCreateLabel(displayName: string, options: FindOrCreateLabelOptions): Promise<FindOrCreateLabelResponse>
Method Parameters
displayNamestringRequired

Display name to retrieve or create.

If an existing label is an exact match for the specified display name, the existing label is returned. If not, a new label is created and returned.


optionsFindOrCreateLabelOptions

Language options.

Returns
Return Type:Promise<FindOrCreateLabelResponse>
Was this helpful?
Yes
No

getLabel( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a label by the specified label key.

The getLabel() function returns a Promise that resolves when the specified label is retrieved.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Bookings Services and Settings
Manage Contact Labels
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function getLabel(key: string, options: GetLabelOptions): Promise<ContactLabel>
Method Parameters
keystringRequired

Label key.

key is generated when the label is created. It cannot be modified, even if displayName is updated.


optionsGetLabelOptions

Language options.

Returns
Return Type:Promise<ContactLabel>
Was this helpful?
Yes
No

queryLabels( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a query to retrieve a list of labels.

The queryLabels() function builds a query to retrieve a list of labels and returns a LabelsQueryBuilder object.

The returned object contains the query definition, which is used to run the query using the find() function.

You can refine the query by chaining LabelsQueryBuilder functions onto the query. LabelsQueryBuilder functions enable you to filter, sort, and control the results that queryLabels() returns.

queryLabels() runs with the following LabelsQueryBuilder defaults, which you can override:

  • skip(0)
  • limit(50)
  • descending('_createdDate')

The following LabelsQueryBuilder functions are supported for queryLabels(). For a full description of the Labels object, see the object returned for the items property in LabelsQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
namespaceeq(),ne()
keyeq(),ne(),in()
displayNameeq(),ne(),in(),startsWith(),ascending(),descending()
labelTypeeq()
_createdDateeq(),ne(),gt(),lt(),ge(),le(),ascending(),descending()
_updatedDateeq(),ne(),gt(),lt(),ge(),le(),ascending(),descending()

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Bookings Services and Settings
Manage Contact Labels
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function queryLabels(options: QueryLabelsOptions): LabelsQueryBuilder
Method Parameters
optionsQueryLabelsOptions

Language options.

Returns
Return Type:LabelsQueryBuilder
Was this helpful?
Yes
No

renameLabel( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Renames a label.

The renameLabel() function returns a Promise that resolves when the specified label's display name is changed.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Contact Labels
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function renameLabel(key: string, label: RenameLabel, options: RenameLabelOptions): Promise<ContactLabel>
Method Parameters
keystringRequired

Label key.

key is generated when the label is created. It cannot be modified, even if displayName is updated.


labelRenameLabelRequired

Label to rename.


optionsRenameLabelOptions

Language options.

Returns
Return Type:Promise<ContactLabel>
Was this helpful?
Yes
No