> 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

# UpdateTiersProgramSettings

# Package: loyaltyProgramManagement

# Namespace: LoyaltyTiers

# Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/tiers/update-tiers-program-settings.md

## Permission Scopes:
Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY

## Introduction

Updates the global settings of a loyalty tier program.

Use this method to update settings that apply to all of a site's loyalty tiers.
To update tier-specific settings for an individual tier, use Update Tier.

By default, the `status` of a tiers program is set to `DISABLED` and must be manually updated to `ACTIVE` using
this method or through a Wix user's dashboard.

>**Note:** The `status`, `revision`, and `rollingWindow` parameters must be passed to update the tiers program settings.
>The `baseTierDefinition` fields aren't required, however, if you don't pass them they reset to
>their default values of empty fields.

---

## REST API

### Schema

```
 Method: updateTiersProgramSettings
 Description: Updates the global settings of a loyalty tier program.  Use this method to update settings that apply to all of a site's loyalty tiers. To update tier-specific settings for an individual tier, use Update Tier.  By default, the `status` of a tiers program is set to `DISABLED` and must be manually updated to `ACTIVE` using this method or through a Wix user's dashboard.  >**Note:** The `status`, `revision`, and `rollingWindow` parameters must be passed to update the tiers program settings. >The `baseTierDefinition` fields aren't required, however, if you don't pass them they reset to >their default values of empty fields.
 URL: https://www.wixapis.com/loyalty-tiers/v1/tiers/program-settings
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  programSettings, programSettings.revision, programSettings.status
 Method parameters: 
   param name: programSettings | type: TiersProgramSettings | description: Tiers program settings apply globally to all tiers in the program. A site can only have 1 set of program settings. | required: true 
     - name: rollingWindow | type: RollingWindow | description: **Required.** Period of time used to calculate loyalty points for tier assignment.  The loyalty points accumulated during this period determine if the account meets a tier's required point threshold.  
        - name: durationInMonths | type: integer | description: Number of months to use for the rolling window period.  Min: `12`  Max: `36`  | validation: minimum 1, maximum 36
        - name: status | type: Status | description: Tiers program status. | required: true 
             - enum:
             -     UNKNOWN: Unknown status.
             -     DISABLED: Tiers are disabled.
             -     DRAFT: Tiers are enabled but not yet active.
             -     ACTIVE: Tiers are active.
             -     PAUSED: Tiers are paused.
        - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty tiers settings are updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty tiers settings. | required: true | validation: format uint64, immutable
        - name: baseTierDefinition | type: TierDefinition | description: Information about the base loyalty tier.  The base tier is the default tier for any account that's unassigned for not meeting the required points threshold of any other tier.  
           - name: icon | type: Image | description: Details about the tier icon.  
              - name: id | type: string | description: WixMedia image GUID.  
              - name: url | type: string | description: Image URL.  
              - name: altText | type: string | description: Image alt text.  
           - name: name | type: string | description: Tier name.  | validation: minLength 1, maxLength 50
           - name: description | type: string | description: Tier description.  | validation: maxLength 70
 Return type: UpdateTiersProgramSettingsResponse
  - name: programSettings | type: TiersProgramSettings | description: Updated program settings.  
     - ONE-OF: 
        - name: rollingWindow | type: RollingWindow | description: **Required.** Period of time used to calculate loyalty points for tier assignment.  The loyalty points accumulated during this period determine if the account meets a tier's required point threshold.  
           - name: durationInMonths | type: integer | description: Number of months to use for the rolling window period.  Min: `12`  Max: `36`  | validation: minimum 1, maximum 36
     - name: status | type: Status | description: Tiers program status.  
         - enum:
         -     UNKNOWN: Unknown status.
         -     DISABLED: Tiers are disabled.
         -     DRAFT: Tiers are enabled but not yet active.
         -     ACTIVE: Tiers are active.
         -     PAUSED: Tiers are paused.
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty tiers settings are updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty tiers settings.  | validation: format uint64, immutable
     - name: createdDate | type: string | description: Date and time the loyalty tiers program was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the loyalty tiers program was last updated.  | read-only: true | validation: format date-time
     - name: baseTierDefinition | type: TierDefinition | description: Information about the base loyalty tier.  The base tier is the default tier for any account that's unassigned for not meeting the required points threshold of any other tier.  
        - name: icon | type: Image | description: Details about the tier icon.  
           - name: id | type: string | description: WixMedia image GUID.  
           - name: url | type: string | description: Image URL.  
           - name: height | type: integer | description: Original image height.  | read-only: true 
           - name: width | type: integer | description: Original image width.  | read-only: true 
           - name: altText | type: string | description: Image alt text.  
           - name: filename | type: string | description: Image filename.  | read-only: true 
        - name: name | type: string | description: Tier name.  | validation: minLength 1, maxLength 50
        - name: description | type: string | description: Tier description.  | validation: maxLength 70


```

### Examples

### Update tiers program settings
```curl
curl -X PATCH \
  'https://www.wixapis.com/loyalty-tiers/v1/tiers/program-settings' \
  -H 'Authorization: <AUTH>'
  -H 'Content-Type: application/json' \
  --data-raw '{
                "programSettings": {
                  "status": "PAUSED",
                  "revision": "1",
                  "baseTierDefinition": {
                    "name": "Basic",
                    "description": "Basic tier",
                    "icon": {
                      "url": "shapes/11062b_0a8e17936d5b4d46971649be036c781b.svg"
                    }
                  },
                  "rollingWindow": {
                    "durationInMonths": 12
                  }
                }
              }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.loyalty.tiers.updateTiersProgramSettings(programSettings)
 Description: Updates the global settings of a loyalty tier program.  Use this method to update settings that apply to all of a site's loyalty tiers. To update tier-specific settings for an individual tier, use Update Tier.  By default, the `status` of a tiers program is set to `DISABLED` and must be manually updated to `ACTIVE` using this method or through a Wix user's dashboard.  >**Note:** The `status`, `revision`, and `rollingWindow` parameters must be passed to update the tiers program settings. >The `baseTierDefinition` fields aren't required, however, if you don't pass them they reset to >their default values of empty fields.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  programSettings, programSettings.revision, programSettings.status
 Method parameters: 
   param name: programSettings | type: TiersProgramSettings | description: Tiers program settings apply globally to all tiers in the program. A site can only have 1 set of program settings. | required: true 
     - name: rollingWindow | type: RollingWindow | description: **Required.** Period of time used to calculate loyalty points for tier assignment.  The loyalty points accumulated during this period determine if the account meets a tier's required point threshold.  
        - name: durationInMonths | type: integer | description: Number of months to use for the rolling window period.  Min: `12`  Max: `36`  | validation: minimum 1, maximum 36
        - name: status | type: Status | description: Tiers program status. | required: true 
             - enum:
             -     UNKNOWN: Unknown status.
             -     DISABLED: Tiers are disabled.
             -     DRAFT: Tiers are enabled but not yet active.
             -     ACTIVE: Tiers are active.
             -     PAUSED: Tiers are paused.
        - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty tiers settings are updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty tiers settings. | required: true | validation: format uint64, immutable
        - name: baseTierDefinition | type: TierDefinition | description: Information about the base loyalty tier.  The base tier is the default tier for any account that's unassigned for not meeting the required points threshold of any other tier.  
           - name: icon | type: string | description: Details about the tier icon.  
           - name: name | type: string | description: Tier name.  | validation: minLength 1, maxLength 50
           - name: description | type: string | description: Tier description.  | validation: maxLength 70
 Return type: PROMISE<UpdateTiersProgramSettingsResponse>
  - name: programSettings | type: TiersProgramSettings | description: Updated program settings.  
     - ONE-OF: - required: true
        - name: rollingWindow | type: RollingWindow | description: **Required.** Period of time used to calculate loyalty points for tier assignment.  The loyalty points accumulated during this period determine if the account meets a tier's required point threshold.  
           - name: durationInMonths | type: integer | description: Number of months to use for the rolling window period.  Min: `12`  Max: `36`  | validation: minimum 1, maximum 36
     - name: status | type: Status | description: Tiers program status.  
         - enum:
         -     UNKNOWN: Unknown status.
         -     DISABLED: Tiers are disabled.
         -     DRAFT: Tiers are enabled but not yet active.
         -     ACTIVE: Tiers are active.
         -     PAUSED: Tiers are paused.
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty tiers settings are updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty tiers settings.  | validation: format uint64, immutable
     - name: _createdDate | type: Date | description: Date and time the loyalty tiers program was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the loyalty tiers program was last updated.  | read-only: true 
     - name: baseTierDefinition | type: TierDefinition | description: Information about the base loyalty tier.  The base tier is the default tier for any account that's unassigned for not meeting the required points threshold of any other tier.  
        - name: icon | type: string | description: Details about the tier icon.  
        - name: name | type: string | description: Tier name.  | validation: minLength 1, maxLength 50
        - name: description | type: string | description: Tier description.  | validation: maxLength 70


```

### Examples

### Update global settings of a loyalty tier program (with elevated permissions)
```javascript
import { tiers } from "@wix/loyalty";
import { auth } from "@wix/essentials";

/* Sample programSettings object:
 *
 * {
 *   "programSettings": {
 *     "revision": "2",
 *     "status": "PAUSED",
 *     "rollingWindow": {
 *       "durationInMonths": 12
 *     }
 *   }
 * }
 */ 
 
const elevatedUpdateTiersProgramSettings = auth.elevate(
  tiers.updateTiersProgramSettings
);

export async function updateTiersProgramSettings(programSettings) {
  try {
    const result = await elevatedUpdateTiersProgramSettings(programSettings);
    return result;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

 /* Promise resolves to:
  *
  * {
  *   "programSettings": {
  *     "_createdDate": "2024-06-05T20:27:19.147Z",
  *     "_updatedDate": "2024-06-11T14:12:48.551Z",
  *     "status": "PAUSED",
  *     "revision": "3",
  *     "rollingWindow": {
  *       "durationInMonths": 12
  *     }
  *   }
  * }
  */
```

### Update global settings of a loyalty tier program
```javascript
import { tiers } from "@wix/loyalty";

/* Sample programSettings object:
 *
 * {
 *   "programSettings": {
 *     "revision": "2",
 *     "status": "PAUSED",
 *     "rollingWindow": {
 *       "durationInMonths": 12
 *     }
 *   }
 * }
 */ 
 
export async function updateTiersProgramSettings(programSettings) {
  try {
    const result = await tiers.updateTiersProgramSettings(programSettings);
    return result;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

 /* Promise resolves to:
  *
  * {
  *   "programSettings": {
  *     "_createdDate": "2024-06-05T20:27:19.147Z",
  *     "_updatedDate": "2024-06-11T14:12:48.551Z",
  *     "status": "PAUSED",
  *     "revision": "3",
  *     "rollingWindow": {
  *       "durationInMonths": 12
  *     }
  *   }
  * }
  */
```

### updateTiersProgramSettings (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 { tiers } from '@wix/loyalty';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function updateTiersProgramSettings(programSettings) {
  const response = await myWixClient.tiers.updateTiersProgramSettings(programSettings);
};
```

---