> 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 # CreateOrReplaceAllRules # Package: groups # Namespace: GroupRulesService # Method link: https://dev.wix.com/docs/api-reference/crm/community/groups/rules/create-or-replace-all-rules.md ## Introduction Creates rules if no rules have been set up. Otherwise, replaces all existing rules. > **Notes:** > + Only group admins can create or replace rules. > + This endpoint requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions.md). --- ## REST API ### Schema ``` Method: createOrReplaceAllRules Description: Creates rules if no rules have been set up. Otherwise, replaces all existing rules. > **Notes:** > + Only group admins can create or replace rules. > + This endpoint requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions.md). URL: https://www.wixapis.com/social-groups/v2/rules/{groupId} Method: PUT Method parameters: param name: rules | type: array | description: New rules. - name: title | type: string | description: Rule title. - name: description | type: string | description: Rule description. Return type: CreateOrReplaceAllRulesResponse - name: groupId | type: string | description: Group GUID. - name: rules | type: array | description: Rules. - name: title | type: string | description: Rule title. - name: description | type: string | description: Rule description. ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.groups.GroupRulesService.createOrReplaceAllRules(groupId, options) Description: Creates rules if no rules have been set up. Otherwise, replaces all existing rules. > **Notes:** > + Only group admins can create or replace rules. > + This endpoint requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions.md). # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: groupId Method parameters: param name: groupId | type: string | description: Group GUID. | required: true param name: options | type: CreateOrReplaceAllRulesOptions none - name: rules | type: array | description: New rules. - name: title | type: string | description: Rule title. - name: description | type: string | description: Rule description. Return type: PROMISE - name: groupId | type: string | description: Group GUID. - name: rules | type: array | description: Rules. - name: title | type: string | description: Rule title. - name: description | type: string | description: Rule description. ``` ### Examples ### createOrReplaceAllRules ```javascript import { rules } from '@wix/groups'; async function createOrReplaceAllRules(groupId,options) { const response = await rules.createOrReplaceAllRules(groupId,options); }; ``` ### createOrReplaceAllRules (with elevated permissions) ```javascript import { rules } from '@wix/groups'; import { auth } from '@wix/essentials'; async function myCreateOrReplaceAllRulesMethod(groupId,options) { const elevatedCreateOrReplaceAllRules = auth.elevate(rules.createOrReplaceAllRules); const response = await elevatedCreateOrReplaceAllRules(groupId,options); } ``` ### createOrReplaceAllRules (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 { rules } from '@wix/groups'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { rules }, // Include the auth strategy and host as relevant }); async function createOrReplaceAllRules(groupId,options) { const response = await myWixClient.rules.createOrReplaceAllRules(groupId,options); }; ``` ---