> 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 # BulkCreateTiers # Package: loyaltyProgramManagement # Namespace: LoyaltyTiers # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/tiers/bulk-create-tiers.md ## Permission Scopes: Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY ## Introduction Creates up to 20 tiers. 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 exists returns an error. To create a single tier, use Create Tier. >**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: bulkCreateTiers Description: Creates up to 20 tiers. 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 exists returns an error. To create a single tier, use Create Tier. >**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/bulk/tiers/create Method: POST Method parameters: param name: tiers | type: array | description: Tiers to create. - 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: BulkCreateTiersResponse - name: results | type: array | description: Created tiers. - name: itemMetadata | type: ItemMetadata | description: Individual tier metadata. - name: id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item). - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items. - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated. - name: error | type: ApplicationError | description: Details about the error in case of failure. - name: code | type: string | description: Error code. - name: description | type: string | description: Description of the error. - name: data | type: object | description: Data related to the error. - name: item | type: Tier | description: Individual tier information. - 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. - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata. - name: totalSuccesses | type: integer | description: Number of items that were successfully processed. - name: totalFailures | type: integer | description: Number of items that couldn't be processed. - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded. ``` ### Examples ### Bulk create tiers ```curl curl -X POST \ 'https://www.wixapis.com/loyalty-tiers/v1/bulk/tiers/create' \ -H 'Authorization: ' -H 'Content-Type: application/json' \ --data-raw '{ "tiers": [ { "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.bulkCreateTiers(tiers) Description: Creates up to 20 tiers. 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 exists returns an error. To create a single tier, use Create Tier. >**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: tiers Method parameters: param name: tiers | type: array | description: Tiers to create. | 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: results | type: array | description: Created tiers. - name: itemMetadata | type: ItemMetadata | description: Individual tier metadata. - name: _id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item). - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items. - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated. - name: error | type: ApplicationError | description: Details about the error in case of failure. - name: code | type: string | description: Error code. - name: description | type: string | description: Description of the error. - name: data | type: object | description: Data related to the error. - name: item | type: Tier | description: Individual tier information. - 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. - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata. - name: totalSuccesses | type: integer | description: Number of items that were successfully processed. - name: totalFailures | type: integer | description: Number of items that couldn't be processed. - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded. ``` ### Examples ### Bulk create tiers (with elevated permissions) ```javascript import { tiers } from "@wix/loyalty"; import { auth } from "@wix/essentials"; /* Sample tiers object: * * { * "tiers": [ * { * "required_points": 50, * "tierDefinition": { * "name": "Elite Member Tier", * "description": "Exclusive tier for elite members" * } * } * ] * } */ const elevatedBulkCreateTiers = auth.elevate(tiers.bulkCreateTiers); async function bulkCreateTiers(tiers) { try { const result = await elevatedBulkCreateTiers(tiers); return result; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * * { * "bulkActionMetadata": { * "totalFailures": 0, * "totalSuccesses": 1, * "undetailedFailures": 0 * }, * "results": [ * { * "item": { * "tierDefinition": { * "name": "Elite Member Tier", * "description": "Exclusive tier for elite members" * }, * "_createdDate": "2024-06-10T07:09:04.213Z", * "_id": "dd43f55d-6d6f-45eb-b76e-13a161a436a1", * "_updatedDate": "2024-06-10T07:09:04.213Z", * "requiredPoints": 50, * "revision": "1" * }, * "itemMetadata": { * "_id": "dd43f55d-6d6f-45eb-b76e-13a161a436a1", * "originalIndex": 0, * "success": true * } * } * ] * } */ ``` ### Bulk create tiers ```javascript import { tiers } from "@wix/loyalty"; /* Sample tiers object: * * { * "tiers": [ * { * "required_points": 50, * "tierDefinition": { * "name": "Elite Member Tier", * "description": "Exclusive tier for elite members" * } * } * ] * } */ async function bulkCreateTiers(tiers) { try { const result = await tiers.bulkCreateTiers(tiers); return result; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * * { * "bulkActionMetadata": { * "totalFailures": 0, * "totalSuccesses": 1, * "undetailedFailures": 0 * }, * "results": [ * { * "item": { * "tierDefinition": { * "name": "Elite Member Tier", * "description": "Exclusive tier for elite members" * }, * "_createdDate": "2024-06-10T07:09:04.213Z", * "_id": "dd43f55d-6d6f-45eb-b76e-13a161a436a1", * "_updatedDate": "2024-06-10T07:09:04.213Z", * "requiredPoints": 50, * "revision": "1" * }, * "itemMetadata": { * "_id": "dd43f55d-6d6f-45eb-b76e-13a161a436a1", * "originalIndex": 0, * "success": true * } * } * ] * } */ ``` ### bulkCreateTiers (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 bulkCreateTiers(tiers) { const response = await myWixClient.tiers.bulkCreateTiers(tiers); }; ``` ---