> 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 # CreateTier # Package: loyaltyProgramManagement # Namespace: LoyaltyTiers # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/tiers/create-tier.md ## Permission Scopes: Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY ## Introduction Creates a tier. The name for a tier and the amount of required points to qualify for a tier can only exist for a single tier. Attempts to create a tier with a `tierDefinition.name` or `requiredPoints` that already exist return an error. To create up to 20 tiers at once, call Bulk Create Tiers. >**Note:** A site must have a [Plus plan](https://support.wix.com/en/article/wix-studio-upgrading-sites) (Wix Studio) >or a [Business plan](https://support.wix.com/en/article/choosing-a-premium-plan?tabs=Business) (Wix Editor) to add tiers. --- ## REST API ### Schema ``` Method: createTier Description: Creates a tier. The name for a tier and the amount of required points to qualify for a tier can only exist for a single tier. Attempts to create a tier with a `tierDefinition.name` or `requiredPoints` that already exist return an error. To create up to 20 tiers at once, call Bulk Create Tiers. >**Note:** A site must have a [Plus plan](https://support.wix.com/en/article/wix-studio-upgrading-sites) (Wix Studio) >or a [Business plan](https://support.wix.com/en/article/choosing-a-premium-plan?tabs=Business) (Wix Editor) to add tiers. URL: https://www.wixapis.com/v1/tiers Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: tier Method parameters: param name: tier | type: Tier | description: A tier is a loyalty level that customers are assigned to based on the amount of points they earn. Read more [about loyalty tiers](https://support.wix.com/en/article/about-tiers). | required: true - name: tierDefinition | type: TierDefinition | description: Information about the 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. - name: description | type: string | description: Tier description. - name: requiredPoints | type: integer | description: The amount of points required to be in this tier. Return type: CreateTierResponse - name: tier | type: Tier | description: Created loyalty tier. - name: id | type: string | description: Tier GUID. - name: tierDefinition | type: TierDefinition | description: Information about the 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. - name: width | type: integer | description: Original image width. - name: altText | type: string | description: Image alt text. - name: filename | type: string | description: Image filename. - name: name | type: string | description: Tier name. - name: description | type: string | description: Tier description. - name: requiredPoints | type: integer | description: The amount of points required to be in this tier. - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty tier is updated. To prevent conflicting changes, the current `revision` must be passed when updating the loyalty tier. - name: createdDate | type: string | description: Date and time the tier was created. - name: updatedDate | type: string | description: Date and time the tier was last updated. ``` ### Examples ### Create tier ```curl curl -X POST \ 'https://www.wixapis.com/loyalty-tiers/v1/tiers' \ -H 'Authorization: ' -H 'Content-Type: application/json' \ --data-raw '{ "tier": { "tierDefinition": { "name": "Gold", "description": "Earn 2x points and get special discount", "icon": { "url": "shapes/39dce0a5d1ce498f95526b1390eaf585.svg" } }, "requiredPoints": 200 } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.loyaltyProgramManagement.LoyaltyTiers.createTier(tier) Description: Creates a tier. The name for a tier and the amount of required points to qualify for a tier can only exist for a single tier. Attempts to create a tier with a `tierDefinition.name` or `requiredPoints` that already exist return an error. To create up to 20 tiers at once, call Bulk Create Tiers. >**Note:** A site must have a [Plus plan](https://support.wix.com/en/article/wix-studio-upgrading-sites) (Wix Studio) >or a [Business plan](https://support.wix.com/en/article/choosing-a-premium-plan?tabs=Business) (Wix Editor) to add tiers. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: tier Method parameters: param name: tier | type: Tier | description: A tier is a loyalty level that customers are assigned to based on the amount of points they earn. Read more [about loyalty tiers](https://support.wix.com/en/article/about-tiers). | required: true - name: tierDefinition | type: TierDefinition | description: Information about the tier. - name: icon | type: string | description: Details about the tier icon. - name: name | type: string | description: Tier name. - name: description | type: string | description: Tier description. - name: requiredPoints | type: integer | description: The amount of points required to be in this tier. Return type: PROMISE - name: _id | type: string | description: Tier GUID. - name: tierDefinition | type: TierDefinition | description: Information about the tier. - name: icon | type: string | description: Details about the tier icon. - name: name | type: string | description: Tier name. - name: description | type: string | description: Tier description. - name: requiredPoints | type: integer | description: The amount of points required to be in this tier. - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty tier is updated. To prevent conflicting changes, the current `revision` must be passed when updating the loyalty tier. - name: _createdDate | type: Date | description: Date and time the tier was created. - name: _updatedDate | type: Date | description: Date and time the tier was last updated. ``` ### Examples ### Create a new tier (with elevated permissions) ```javascript import { tiers } from "@wix/loyalty"; import { auth } from "@wix/essentials"; /* Sample tier value: * { * "tier": { * "required_points": 1000, * "tierDefinition": { * "name": "Jadeite Tier", * "description": "Jadeite Tier Benefits", * "icon": { * "url": "shapes/cca51dde12d348379113f2201cbe4e6c.svg" * } * } * } * } */ const elevatedCreateTier = auth.elevate(tiers.createTier); export async function createTier(tier) { try { const result = await elevatedCreateTier(tier); return result; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "tier": { * "_createdDate": "2024-06-11T12:38:35.490Z", * "_id": "8edeea05-2c90-43fa-bd15-b2352620fd51", * "_updatedDate": "2024-06-11T12:38:35.490Z", * "requiredPoints": 1000, * "revision": "1", * "tierDefinition": { * "description": "Jadeite Tier Benefits", * "icon": { * "id": "", * "url": "shapes/cca51dde12d348379113f2201cbe4e6c.svg", * "height": 0, * "width": 0, * "altText": null, * "urlExpirationDate": null, * "filename": null, * "sizeInBytes": null * }, * "name": "Jadeite Tier" * } * } * } */ ``` ### Create a new tier ```javascript import { tiers } from "@wix/loyalty"; /* Sample tier value: * { * "tier": { * "required_points": 1000, * "tierDefinition": { * "name": "Jadeite Tier", * "description": "Jadeite Tier Benefits", * "icon": { * "url": "shapes/cca51dde12d348379113f2201cbe4e6c.svg" * } * } * } * } */ export async function createTier(tier) { try { const result = await tiers.createTier(tier); return result; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "tier": { * "_createdDate": "2024-06-11T12:38:35.490Z", * "_id": "8edeea05-2c90-43fa-bd15-b2352620fd51", * "_updatedDate": "2024-06-11T12:38:35.490Z", * "requiredPoints": 1000, * "revision": "1", * "tierDefinition": { * "description": "Jadeite Tier Benefits", * "icon": { * "id": "", * "url": "shapes/cca51dde12d348379113f2201cbe4e6c.svg", * "height": 0, * "width": 0, * "altText": null, * "urlExpirationDate": null, * "filename": null, * "sizeInBytes": null * }, * "name": "Jadeite Tier" * } * } * } */ ``` ### createTier (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 { 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 createTier(tier) { const response = await myWixClient.tiers.createTier(tier); }; ``` ---