> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: queryLabels() # Method package: wixCrmBackend # Method menu location: wixCrmBackend --> Contacts --> queryLabels # Method Link: https://dev.wix.com/docs/velo/apis/wix-crm-backend/contacts/query-labels.md # Method Description: 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`](wix-crm-backend/contacts/labels-query-builder) object. The returned object contains the query definition, which is used to run the query using the [`find()`](https://dev.wix.com/docs/velo/apis/wix-crm-backend/contacts/labels-query-builder/find.md) function. You can refine the query by chaining `LabelsQueryBuilder` functions onto the query. `LabelsQueryBuilder` functions enable you to control the results `queryLabels()` returns. `queryLabels()` runs with these `LabelsQueryBuilder` defaults, which you can override: - [`skip(0)`](wix-crm-backend/contacts/labels-query-builder/skip) - [`limit(50)`](wix-crm-backend/contacts/labels-query-builder/limit) - [`descending("_createdDate")`](wix-crm-backend/contacts/labels-query-builder/descending) > **Note:** > Only visitors with > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions) > can query labels. > You can override the permissions by setting the `suppressAuth` option to `true` > in the [`find()`](https://dev.wix.com/docs/velo/apis/wix-crm-backend/contacts/labels-query-builder/find.md) function. For property support for filters and sorting, see [Query labels: Supported filters and sorting](wix-crm-backend/contacts/sort,-filter,-and-search). # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Retrieve all labels ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { contacts } from 'wix-crm-backend'; export const myQueryLabelsFunction = webMethod(Permissions.Anyone, async (options) => { try { const queryResults = await contacts.queryLabels() .find(options); const items = queryResults.items; const firstItem = items[0]; const pageSize = queryResults.pageSize; const hasNext = queryResults.hasNext(); const hasPrev = queryResults.hasPrev(); const length = queryResults.length; const query = queryResults.query; return items; } catch (error) { console.error(error); // Handle the error } }); /* Returns items: * [ * { * "_createdDate": "2021-03-30T12:42:06.000Z", * "_updatedDate": "2021-03-30T12:42:06.000Z", * "displayName": "New Lead", * "key": "custom.new-lead", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-03-29T13:17:29.000Z", * "_updatedDate": "2021-03-29T13:17:29.000Z", * "displayName": "Marketing Your Business on Social Media", * "key": "custom.marketing-your-business-on-social-media", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-01-20T12:49:09.000Z", * "_updatedDate": "2021-01-20T12:49:09.000Z", * "displayName": "Quick Win", * "key": "custom.quick-win", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-01-20T12:48:46.000Z", * "_updatedDate": "2021-01-20T12:48:46.000Z", * "displayName": "Stale Lead", * "key": "custom.stale-lead", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-01-20T06:55:58.000Z", * "_updatedDate": "2021-01-20T06:55:58.000Z", * "displayName": "White Glove Treatment", * "key": "custom.white-glove-treatment", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-01-20T06:55:47.000Z", * "_updatedDate": "2021-01-20T06:55:47.000Z", * "displayName": "At Risk", * "key": "custom.at-risk", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-01-20T00:31:41.000Z", * "_updatedDate": "2021-01-20T00:31:41.000Z", * "displayName": "Active Customer", * "key": "custom.active-customer", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "_createdDate": "2021-01-19T21:38:49.000Z", * "_updatedDate": "2021-01-20T19:07:54.000Z", * "displayName": "Incoming", * "key": "custom.incoming-leads", * "namespace": "custom", * "labelType": "USER_DEFINED" * }, * { * "displayName": "Customers", * "key": "contacts.customers", * "namespace": "contacts", * "labelType": "SYSTEM" * }, * { * "displayName": "Contacted Me", * "key": "contacts.contacted-me", * "namespace": "contacts", * "labelType": "SYSTEM" * } * ] */ ``` ---