> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# QueryGroups

# Package: groups

# Namespace: GroupsService

# Method link: https://dev.wix.com/docs/api-reference/crm/community/groups/groups/query-groups?apiView=SDK.md

## Permission Scopes:
## Method Code Examples

--- Code Example: queryGroups ---

## Introduction

Retrieves up to 100 groups, given the provided paging, filtering, and sorting.

Supported fields for filtering:
- `title`

Supported fields for sorting:
- `title`
- `createdDate`
- `membersCount`
- `recentActivityDate`

For groups with `group.privacyStatus` set to `SECRET`, only group admins and group members can see the group and its content.

---

## REST API

### Schema

```
 Method: queryGroups
 Description: Retrieves up to 100 groups, given the provided paging, filtering, and sorting.  Supported fields for filtering: - `title`  Supported fields for sorting: - `title` - `createdDate` - `membersCount` - `recentActivityDate`  For groups with `group.privacyStatus` set to `SECRET`, only group admins and group members can see the group and its content.
 URL: https://www.wixapis.com/social-groups-proxy/groups/v2/groups/query
 Method: POST
 Method parameters:
   param name: contentType | type: ContentType    
      - enum:
           PLAIN_TEXT - 
           DRAFTJS - 
           RICH_CONTENT - 
   param name: query | type: Query    
        - name: filter | type: Value | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`  
           - ONE-OF: 
              - name: nullValue | type:  | description:   
              - name: numberValue | type: number | description:   
              - name: stringValue | type: string | description:   
              - name: boolValue | type: boolean | description:   
              - name: structValue | type: object | description:   
              - name: listValue | type: ListValue | description:   
                 - name: values | type: array<Value> | description:   
        - name: sort | type: array<Sorting> | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`  
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
        - name: paging | type: Paging | description: Paging options to limit and skip the number of items.  
           - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
           - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
        - name: fields | type: array<string> | description: Array of projected fields. A list of specific field names to return. If `fieldsets` are also specified, the union of `fieldsets` and `fields` is returned.  
        - name: fieldsets | type: array<string> | description: Array of named, predefined sets of projected fields. A array of predefined named sets of fields to be returned. Specifying multiple `fieldsets` will return the union of fields from all sets. If `fields` are also specified, the union of `fieldsets` and `fields` is returned.  
 Return type: QueryGroupsResponse
  - name: groups | type: array<Group> | description: Retrieved groups.  
     - name: id | type: string | description: Group GUID.  | read-only: true | validation: format GUID
     - name: slug | type: string | description: A unique part of a group's URL, for example `https:/example.com/groups/slug`.  | validation: minLength 1, maxLength 100
     - name: privacyStatus | type: PrivacyStatus | description: Group privacy status.  
         - enum:
         -     UNKNOWN: Undefined group privacy status.
         -     PUBLIC: Anyone can see the group and its content. Anyone can join the group.
         -     PRIVATE: Anyone can see the group, but only members can see its content. New members must submit a `Join Group Request`.
         -     SECRET: Only admins and members can see the group. New members can only be added by other members.
     - name: name | type: string | description: Group name.  | validation: maxLength 100
     - name: description | type: string | description: Group description in [DraftJS](https://draftjs.org) format.  | validation: maxLength 20480
     - name: teaser | type: string | description: Group teaser.  | validation: maxLength 1000
     - name: memberTitle | type: string | description: What group members are called, for example `Coworkers`, `Friends`, or `Students`.  | validation: minLength 1, maxLength 1000
     - name: coverImage | type: CoverImage | description: Cover image. You cannot upload your own cover image.  
        - name: image | type: Image | description: Cover image.  
           - name: mediaId | type: string | description: Image GUID (for internal use).  | validation: maxLength 1000
           - name: width | type: integer | description: Image width.  | validation: format int32
           - name: height | type: integer | description: Image height.  | validation: format int32
           - name: preset | type: boolean | description: Indicates pre-configured/auto-generated images (from templates, client generated).  
        - name: position | type: Position | description: Position of the corner of the cover image (or logo).  
           - name: x | type: float | description: horizontal coordinate  
           - name: y | type: float | description: vertical coordinate  
        - name: mobilePosition | type: Position | description: Position of the corner of the cover image (or logo) for mobile browser.  
        - name: altText | type: string | description: Alternative text is typically a relatively short phrase that describes what the image depicts.  The alternative text is used: + If the browser cannot display the image. + If the user is utilizing a screen reader. + By search engines to understand what images are on your site.  | validation: maxLength 200
     - name: settings | type: GroupSettings | description: Group specific settings.  These settings can also be found in [a site's Dashboard](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%2Fwix-groups/settings?).  
        - name: welcomeMemberPostEnabled | type: boolean | description: Whether a daily post about new members is enabled.  
        - name: groupDetailsChangedPostEnabled | type: boolean | description: Whether an automatic post about changing the group details is enabled.  
        - name: showMemberList | type: boolean | description: Whether all members can see the full member list.  
        - name: allowedToInviteMembers | type: AllowPolicy | description: Determines who can invite members to the group  
             - enum: UNKNOWN, OWNER_AND_ADMINS, OWNER, ALL_MEMBERS
        - name: allowedToApproveJoinRequests | type: AllowPolicy | description: Determines who can approve member join requests to the group  
        - name: aiSpamProtectionEnabled | type: boolean | description: Whether AI spam protection is enabled for post creation in the group. If not explicitly set, the default behavior is 'true' (enabled).  
     - name: membersCount | type: integer | description: Total count of current group members.  | read-only: true | validation: format int32
     - name: ownerId | type: string | description: Group owner.  | read-only: true | validation: format GUID
     - name: createdDate | type: string | description: Group creation date and time.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time of the latest group update.  | read-only: true | validation: format date-time
     - name: lastActivityDate | type: string | description: Date and time of the most recent group activity, for example a post or comment.  | read-only: true | validation: format date-time
  - name: metadata | type: PagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  


```

### Examples

### QueryGroups
```curl
~~~cURL
curl -X POST \
    https://www.wixapis.com/social-groups-proxy/groups/v2/groups/query \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Authorization: <AUTH>' \
    -d '{
            "query": {
                "filter": {
                    "title": {
                        "$contains": "Test"
                    }
                },
                "sort": [
                    {
                        "fieldName": "createdDate",
                        "order": "DESC"
                    }
                ],
                "paging": {
                    "offset": 10,
                    "limit": 15
                }
            }
        }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.groups.groups.queryGroups(options)
 Description: Retrieves up to 100 groups, given the provided paging, filtering, and sorting.  Supported fields for filtering: - `title`  Supported fields for sorting: - `title` - `createdDate` - `membersCount` - `recentActivityDate`  For groups with `group.privacyStatus` set to `SECRET`, only group admins and group members can see the group and its content.
 Method parameters:
   param name: options | type: QueryGroupsOptions  none  
        - name: query | type: Query | description: Query options.  
           - name: filter | type: any<Value> | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`  
              - ONE-OF: 
                 - name: nullValue | type:  | description:   
                 - name: numberValue | type: number | description:   
                 - name: stringValue | type: string | description:   
                 - name: boolValue | type: boolean | description:   
                 - name: structValue | type: object | description:   
                 - name: listValue | type: ListValue | description:   
                    - name: values | type: array<Value> | description:   
           - name: sort | type: array<Sorting> | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`  
              - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
              - name: order | type: SortOrder | description: Sort order.  
                     - enum: ASC, DESC
              - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
                 - name: latitude | type: number | description: Address latitude.  
                 - name: longitude | type: number | description: Address longitude.  
           - name: paging | type: Paging | description: Paging options to limit and skip the number of items.  
              - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
              - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
           - name: fields | type: array<string> | description: Array of projected fields. A list of specific field names to return. If `fieldsets` are also specified, the union of `fieldsets` and `fields` is returned.  
           - name: fieldsets | type: array<string> | description: Array of named, predefined sets of projected fields. A array of predefined named sets of fields to be returned. Specifying multiple `fieldsets` will return the union of fields from all sets. If `fields` are also specified, the union of `fieldsets` and `fields` is returned.  
        - name: contentType | type: ContentType | description: Content type.  
             - enum: PLAIN_TEXT, DRAFTJS, RICH_CONTENT
 Return type: PROMISE<QueryGroupsResponse>
  - name: groups | type: array<Group> | description: Retrieved groups.  
     - name: _id | type: string | description: Group GUID.  | read-only: true | validation: format GUID
     - name: slug | type: string | description: A unique part of a group's URL, for example `https:/example.com/groups/slug`.  | validation: minLength 1, maxLength 100
     - name: privacyStatus | type: PrivacyStatus | description: Group privacy status.  
         - enum:
         -     UNKNOWN: Undefined group privacy status.
         -     PUBLIC: Anyone can see the group and its content. Anyone can join the group.
         -     PRIVATE: Anyone can see the group, but only members can see its content. New members must submit a `Join Group Request`.
         -     SECRET: Only admins and members can see the group. New members can only be added by other members.
     - name: name | type: string | description: Group name.  | validation: maxLength 100
     - name: description | type: string | description: Group description in [DraftJS](https://draftjs.org) format.  | validation: maxLength 20480
     - name: teaser | type: string | description: Group teaser.  | validation: maxLength 1000
     - name: memberTitle | type: string | description: What group members are called, for example `Coworkers`, `Friends`, or `Students`.  | validation: minLength 1, maxLength 1000
     - name: coverImage | type: CoverImage | description: Cover image. You cannot upload your own cover image.  
        - name: image | type: Image | description: Cover image.  
           - name: mediaId | type: string | description: Image GUID (for internal use).  | validation: maxLength 1000
           - name: width | type: integer | description: Image width.  | validation: format int32
           - name: height | type: integer | description: Image height.  | validation: format int32
           - name: preset | type: boolean | description: Indicates pre-configured/auto-generated images (from templates, client generated).  
        - name: position | type: Position | description: Position of the corner of the cover image (or logo).  
           - name: x | type: float | description: horizontal coordinate  
           - name: y | type: float | description: vertical coordinate  
        - name: mobilePosition | type: Position | description: Position of the corner of the cover image (or logo) for mobile browser.  
        - name: altText | type: string | description: Alternative text is typically a relatively short phrase that describes what the image depicts.  The alternative text is used: + If the browser cannot display the image. + If the user is utilizing a screen reader. + By search engines to understand what images are on your site.  | validation: maxLength 200
     - name: settings | type: GroupSettings | description: Group specific settings.  These settings can also be found in [a site's Dashboard](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%2Fwix-groups/settings?).  
        - name: welcomeMemberPostEnabled | type: boolean | description: Whether a daily post about new members is enabled.  
        - name: groupDetailsChangedPostEnabled | type: boolean | description: Whether an automatic post about changing the group details is enabled.  
        - name: showMemberList | type: boolean | description: Whether all members can see the full member list.  
        - name: allowedToInviteMembers | type: AllowPolicy | description: Determines who can invite members to the group  
             - enum: UNKNOWN, OWNER_AND_ADMINS, OWNER, ALL_MEMBERS
        - name: allowedToApproveJoinRequests | type: AllowPolicy | description: Determines who can approve member join requests to the group  
        - name: aiSpamProtectionEnabled | type: boolean | description: Whether AI spam protection is enabled for post creation in the group. If not explicitly set, the default behavior is 'true' (enabled).  
     - name: membersCount | type: integer | description: Total count of current group members.  | read-only: true | validation: format int32
     - name: ownerId | type: string | description: Group owner.  | read-only: true | validation: format GUID
     - name: _createdDate | type: Date | description: Group creation date and time.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time of the latest group update.  | read-only: true 
     - name: lastActivityDate | type: Date | description: Date and time of the most recent group activity, for example a post or comment.  | read-only: true 
  - name: metadata | type: PagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  


```

### Examples

### queryGroups
```javascript
import { groups } from '@wix/groups';

async function queryGroups(options) {
  const response = await groups.queryGroups(options);
};
```

### queryGroups (with elevated permissions)
```javascript
import { groups } from '@wix/groups';
import { auth } from '@wix/essentials';

async function myQueryGroupsMethod(options) {
  const elevatedQueryGroups = auth.elevate(groups.queryGroups);
  const response = await elevatedQueryGroups(options);
}
```

### queryGroups (self-managed)
Self-managed 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 { groups } from '@wix/groups';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { groups },
  // Include the auth strategy and host as relevant
});


async function queryGroups(options) {
  const response = await myWixClient.groups.queryGroups(options);
};
```

---