> 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 # QueryExtendedFields # Package: contacts # Namespace: ContactExtendedFieldsServiceV4 # Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/extended-fields/query-extended-fields.md ## Permission Scopes: Manage Contact Extended Fields: SCOPE.DC-CONTACTS.MANAGE-EX-FIELDS ## Introduction Retrieves a list of extended fields. For a detailed list of supported operations, see [sorting and filtering for extended fields](https://dev.wix.com/api/rest/contacts/extended-fields/sort-and-filter). To learn more about query language, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language). --- ## REST API ### Schema ``` Method: queryExtendedFields Description: Retrieves a list of extended fields. For a detailed list of supported operations, see [sorting and filtering for extended fields](https://dev.wix.com/api/rest/contacts/extended-fields/sort-and-filter). To learn more about query language, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language). URL: https://www.wixapis.com/contacts/v4/extended-fields/query Method: POST Method parameters: param name: query | type: Query - name: filter | type: object | description: ilter object. Possible filters: `$eq`, `$gt`, `$gte`, `$in`, `$lt`, `$lte`, `$ne`, `$startsWith`. For a detailed list of supported filters, see [sorting and filtering for extended fields](https://dev.wix.com/api/rest/contacts/extended-fields/sort-and-filter). Example: `{ "filter": { "displayName": { "$startsWith": "Referral" } } }` - name: sort | type: array | description: Sorting options. Currently supports sorting on one field only. Example: `{ "sort": [{"fieldName": "displayName", "order": "DESC"}] }` - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. Default: `ASC`. - enum: - ASC: Sort by ascending order. - DESC: Sort by descending order. - name: paging | type: Paging | description: Pagination options. - name: limit | type: integer | description: Number of items to return. Defaults to `100`. - name: offset | type: integer | description: Number of items to skip in the current sort order. Defaults to `0`. Return type: QueryExtendedFieldsResponse - name: fields | type: array | description: List of extended fields. - name: namespace | type: string | description: Extended field namespace. Extended fields created through by calling the Find Or Create Extended Field method are automatically assigned to the `custom` namespace. - name: key | type: string | description: Extended field key. When accessing contact data, extended field data is available at `extendedFields[key]`. For example, if the key is "custom.notes", the value can be accessed at `extendedFields["custom.notes"]`. `key` is generated when the extended field is created and can't be modified, even if `displayName` changes. - name: displayName | type: string | description: Display name shown in the contact list. - name: dataType | type: FieldDataType | description: Type of data the field holds. - enum: - TEXT: Accepts strings. - NUMBER: Accepts floats. - DATE: Accepts dates formatted as `YYYY-MM-DD`. - URL: Accepts strings. Prepends `https://` if no protocol is included. - name: fieldType | type: FieldType | description: Indicates whether the extended field is a system field or custom field. - enum: - SYSTEM: Field is a system field managed by Wix. System fields can't be modified by calling the Update Extended Field method. - USER_DEFINED: Field is a custom field and can be modified by calling the Update Extended Field method. - name: createdDate | type: string | description: Date and time the field was created. - name: updatedDate | type: string | description: Date and time the field was last updated. - name: description | type: string | description: Field description, if the field is a system field. - name: pagingMetadata | type: PagingMetadata | description: Details on the paged set of results returned. - name: count | type: integer | description: Number of items returned. - name: offset | type: integer | description: Requested offset. - name: total | type: integer | description: Number of items that matched the query. - name: tooManyToCount | type: boolean | description: Indicates if `total` calculation timed out before the response was sent. Typically this happens if there is a large set of results. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_VALUE | Description: Unsupported filter value. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_OPERATOR | Description: Unsupported filter operator for the provided field. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_FIELD | Description: Unsupported filter field. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER | Description: At least 1 of the provided filters isn't supported. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MALFORMED_FILTER | Description: Filter couldn't be parsed. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SORT | Description: Unsupported sort field. ``` ### Examples ### Query All Extended Fields ```curl curl -X POST \ 'https://www.wixapis.com/contacts/v4/extended-fields/query' \ -H 'Authorization: ' ``` ### Query Extended Fields by Namespace Sorted by CreatedDate Desc ```curl curl -X POST \ 'https://www.wixapis.com/contacts/v4/extended-fields/query' \ -H 'Authorization: ' --data-binary '{ "query": { "filter": { "namespace" : "custom" }, "sort" : [ {"fieldName": "createdDate", "order" : "DESC"} ] } }' ``` ### Query Extended Fields by Keys ```curl curl -X POST \ 'https://www.wixapis.com/contacts/v4/extended-fields/query' \ -H 'Authorization: ' --data-binary '{ "query": { "filter": { "key" : { "$in" : ["custom.date", "emailSubscriptions.effectiveEmail"] } } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.contacts.ContactExtendedFieldsServiceV4.queryExtendedFields(query) Description: Retrieves a list of extended fields. For a detailed list of supported operations, see [sorting and filtering for extended fields](https://dev.wix.com/api/rest/contacts/extended-fields/sort-and-filter). To learn more about query language, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language). # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: query Method parameters: param name: query | type: ExtendedFieldQuery | required: true - name: filter | type: object | description: ilter object. Possible filters: `$eq`, `$gt`, `$gte`, `$in`, `$lt`, `$lte`, `$ne`, `$startsWith`. For a detailed list of supported filters, see [sorting and filtering for extended fields](https://dev.wix.com/api/rest/contacts/extended-fields/sort-and-filter). Example: `{ "filter": { "displayName": { "$startsWith": "Referral" } } }` - name: sort | type: array | description: Sorting options. Currently supports sorting on one field only. Example: `{ "sort": [{"fieldName": "displayName", "order": "DESC"}] }` - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. Default: `ASC`. - enum: - ASC: Sort by ascending order. - DESC: Sort by descending order. - name: paging | type: Paging | description: Pagination options. - name: limit | type: integer | description: Number of items to return. Defaults to `100`. - name: offset | type: integer | description: Number of items to skip in the current sort order. Defaults to `0`. Return type: PROMISE - name: fields | type: array | description: List of extended fields. - name: namespace | type: string | description: Extended field namespace. Extended fields created through by calling the Find Or Create Extended Field method are automatically assigned to the `custom` namespace. - name: key | type: string | description: Extended field key. When accessing contact data, extended field data is available at `extendedFields[key]`. For example, if the key is "custom.notes", the value can be accessed at `extendedFields["custom.notes"]`. `key` is generated when the extended field is created and can't be modified, even if `displayName` changes. - name: displayName | type: string | description: Display name shown in the contact list. - name: dataType | type: FieldDataType | description: Type of data the field holds. - enum: - TEXT: Accepts strings. - NUMBER: Accepts floats. - DATE: Accepts dates formatted as `YYYY-MM-DD`. - URL: Accepts strings. Prepends `https://` if no protocol is included. - name: fieldType | type: FieldType | description: Indicates whether the extended field is a system field or custom field. - enum: - SYSTEM: Field is a system field managed by Wix. System fields can't be modified by calling the Update Extended Field method. - USER_DEFINED: Field is a custom field and can be modified by calling the Update Extended Field method. - name: _createdDate | type: Date | description: Date and time the field was created. - name: _updatedDate | type: Date | description: Date and time the field was last updated. - name: description | type: string | description: Field description, if the field is a system field. - name: pagingMetadata | type: PagingMetadata | description: Details on the paged set of results returned. - name: count | type: integer | description: Number of items returned. - name: offset | type: integer | description: Requested offset. - name: total | type: integer | description: Number of items that matched the query. - name: tooManyToCount | type: boolean | description: Indicates if `total` calculation timed out before the response was sent. Typically this happens if there is a large set of results. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_VALUE | Description: Unsupported filter value. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_OPERATOR | Description: Unsupported filter operator for the provided field. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_FIELD | Description: Unsupported filter field. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER | Description: At least 1 of the provided filters isn't supported. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MALFORMED_FILTER | Description: Filter couldn't be parsed. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SORT | Description: Unsupported sort field. ``` ### Examples ### Retrieve extended fields with specified type (with elevated permissions) ```javascript import { extendedFields } from '@wix/crm'; import { auth } from '@wix/essentials'; export async function myQueryExtendedFieldsFunction() { try { const elevatedQueryExtendedFields = auth.elevate(extendedFields.queryExtendedFields); const queryResults = await elevatedQueryExtendedFields() .eq("dataType", "NUMBER") .find(); 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; console.log('Retrieved items:', items); return items; } catch (error) { console.error(error); // Handle the error } } /* Returns items: * [ * { * "namespace": "custom", * "key": "custom.age", * "displayName": "Age", * "dataType": "NUMBER", * "fieldType": "USER_DEFINED", * "legacyId": "ed349d8c-b2bc-46a4-80d8-7632c6f50b00", * "wixSearchColumn": "info_extendedFields_custom_double_27", * "_createdDate": "2023-12-25T12:16:40.000Z", * "_updatedDate": "2023-12-25T12:16:40.000Z" * }, * { * "namespace": "ecom", * "key": "ecom.numOfPurchases", * "displayName": "# of Purchases", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores purchase count (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.totalSpentAmount", * "displayName": "Total Spent Amount", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores aggregated spent amount (read only)" * } * ] */ ``` ### Retrieve extended fields with specified type ```javascript import { extendedFields } from '@wix/crm'; export async function myQueryExtendedFieldsFunction() { try { const queryResults = await extendedFields.queryExtendedFields() .eq("dataType", "NUMBER") .find(); 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; console.log('Retrieved items:', items); return items; } catch (error) { console.error(error); // Handle the error } } /* Returns items: * [ * { * "namespace": "custom", * "key": "custom.age", * "displayName": "Age", * "dataType": "NUMBER", * "fieldType": "USER_DEFINED", * "legacyId": "ed349d8c-b2bc-46a4-80d8-7632c6f50b00", * "wixSearchColumn": "info_extendedFields_custom_double_27", * "_createdDate": "2023-12-25T12:16:40.000Z", * "_updatedDate": "2023-12-25T12:16:40.000Z" * }, * { * "namespace": "ecom", * "key": "ecom.numOfPurchases", * "displayName": "# of Purchases", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores purchase count (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.totalSpentAmount", * "displayName": "Total Spent Amount", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores aggregated spent amount (read only)" * } * ] */ ``` ### Retrieve all extended fields (with elevated permissions) ```javascript import { extendedFields } from '@wix/crm'; import { auth } from '@wix/essentials'; const elevatedQueryExtendedFields = auth.elevate(extendedFields.queryExtendedFields); export async function myQueryExtendedFieldsFunction() { try { const queryResults = await elevatedQueryExtendedFields() .find(); 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; console.log('Retrieved items:', items); return items; } catch (error) { console.error(error); // Handle the error } } /* Returns items: * [ * { * "namespace": "custom", * "key": "custom.nickname", * "displayName": "Nickname", * "dataType": "TEXT", * "fieldType": "USER_DEFINED", * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1", * "wixSearchColumn": "info_extendedFields_custom_string_18", * "_createdDate": "2023-12-25T12:21:42.000Z", * "_updatedDate": "2023-12-25T12:22:25.000Z" * }, * { * "namespace": "custom", * "key": "custom.age", * "displayName": "Age", * "dataType": "NUMBER", * "fieldType": "USER_DEFINED", * "legacyId": "ed349d8c-b2bc-46a4-80d8-7632c6f50b00", * "wixSearchColumn": "info_extendedFields_custom_double_27", * "_createdDate": "2023-12-25T12:16:40.000Z", * "_updatedDate": "2023-12-25T12:16:40.000Z" * }, * { * "namespace": "contacts", * "key": "contacts.displayByFirstName", * "displayName": "Display Name (start with first)", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Display name starting with first name (read only)" * }, * { * "namespace": "contacts", * "key": "contacts.displayByLastName", * "displayName": "Display Name (start with last)", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Display name starting with last name (read only)" * }, * { * "namespace": "invoices", * "key": "invoices.vatId", * "displayName": "VAT ID", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Vat ID for Wix Invoices" * }, * { * "namespace": "members", * "key": "members.membershipStatus", * "displayName": "Membership Status", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "APPROVED/DENIED/PENDING/INACTIVE/OFFLINE_ONLY (read only)" * }, * { * "namespace": "members", * "key": "members.mobile", * "displayName": "Mobile flag", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "true/false" * }, * { * "namespace": "ecom", * "key": "ecom.numOfPurchases", * "displayName": "# of Purchases", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores purchase count (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.totalSpentAmount", * "displayName": "Total Spent Amount", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores aggregated spent amount (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.totalSpentCurrency", * "displayName": "Total Spent Currency", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Wix Stores currency code (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.lastPurchaseDate", * "displayName": "Last Purchase Date", * "dataType": "DATE", * "fieldType": "SYSTEM", * "description": "Wix Stores last purchase date (read only)" * }, * { * "namespace": "emailSubscriptions", * "key": "emailSubscriptions.subscriptionStatus", * "displayName": "Effective Subscription Status", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "SUBSCRIBED/UNSUBSCRIBED/NOT_SET/PENDING (read only)" * }, * { * "namespace": "emailSubscriptions", * "key": "emailSubscriptions.deliverabilityStatus", * "displayName": "Effective Deliverability Status", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "VALID/BOUNCED/SPAM_COMPLAINT/INACTIVE (read only)" * }, * { * "namespace": "emailSubscriptions", * "key": "emailSubscriptions.effectiveEmail", * "displayName": "Effective Email", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Effective Email for subscription purposes (read only)" * } * ] */ ``` ### Retrieve all extended fields ```javascript import { extendedFields } from '@wix/crm'; export async function myQueryExtendedFieldsFunction() { try { const queryResults = await extendedFields.queryExtendedFields() .find(); 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; console.log('Retrieved items:', items); return items; } catch (error) { console.error(error); // Handle the error } } /* Returns items: * [ * { * "namespace": "custom", * "key": "custom.nickname", * "displayName": "Nickname", * "dataType": "TEXT", * "fieldType": "USER_DEFINED", * "legacyId": "63408eaf-e3d0-43f3-afa5-942847d272a1", * "wixSearchColumn": "info_extendedFields_custom_string_18", * "_createdDate": "2023-12-25T12:21:42.000Z", * "_updatedDate": "2023-12-25T12:22:25.000Z" * }, * { * "namespace": "custom", * "key": "custom.age", * "displayName": "Age", * "dataType": "NUMBER", * "fieldType": "USER_DEFINED", * "legacyId": "ed349d8c-b2bc-46a4-80d8-7632c6f50b00", * "wixSearchColumn": "info_extendedFields_custom_double_27", * "_createdDate": "2023-12-25T12:16:40.000Z", * "_updatedDate": "2023-12-25T12:16:40.000Z" * }, * { * "namespace": "contacts", * "key": "contacts.displayByFirstName", * "displayName": "Display Name (start with first)", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Display name starting with first name (read only)" * }, * { * "namespace": "contacts", * "key": "contacts.displayByLastName", * "displayName": "Display Name (start with last)", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Display name starting with last name (read only)" * }, * { * "namespace": "invoices", * "key": "invoices.vatId", * "displayName": "VAT ID", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Vat ID for Wix Invoices" * }, * { * "namespace": "members", * "key": "members.membershipStatus", * "displayName": "Membership Status", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "APPROVED/DENIED/PENDING/INACTIVE/OFFLINE_ONLY (read only)" * }, * { * "namespace": "members", * "key": "members.mobile", * "displayName": "Mobile flag", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "true/false" * }, * { * "namespace": "ecom", * "key": "ecom.numOfPurchases", * "displayName": "# of Purchases", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores purchase count (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.totalSpentAmount", * "displayName": "Total Spent Amount", * "dataType": "NUMBER", * "fieldType": "SYSTEM", * "description": "Wix Stores aggregated spent amount (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.totalSpentCurrency", * "displayName": "Total Spent Currency", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Wix Stores currency code (read only)" * }, * { * "namespace": "ecom", * "key": "ecom.lastPurchaseDate", * "displayName": "Last Purchase Date", * "dataType": "DATE", * "fieldType": "SYSTEM", * "description": "Wix Stores last purchase date (read only)" * }, * { * "namespace": "emailSubscriptions", * "key": "emailSubscriptions.subscriptionStatus", * "displayName": "Effective Subscription Status", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "SUBSCRIBED/UNSUBSCRIBED/NOT_SET/PENDING (read only)" * }, * { * "namespace": "emailSubscriptions", * "key": "emailSubscriptions.deliverabilityStatus", * "displayName": "Effective Deliverability Status", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "VALID/BOUNCED/SPAM_COMPLAINT/INACTIVE (read only)" * }, * { * "namespace": "emailSubscriptions", * "key": "emailSubscriptions.effectiveEmail", * "displayName": "Effective Email", * "dataType": "TEXT", * "fieldType": "SYSTEM", * "description": "Effective Email for subscription purposes (read only)" * } * ] */ ``` ### queryExtendedFields (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { extendedFields } from '@wix/crm'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { extendedFields }, // Include the auth strategy and host as relevant }); async function queryExtendedFields(query) { const response = await myWixClient.extendedFields.queryExtendedFields(query); }; ``` ---