> 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

# BulkCreatePromotions

# Package: catalogV3

# Namespace: PromotionsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/promotions-v3/bulk-create-promotions.md

## Permission Scopes:
Manage v3 catalog: SCOPE.STORES.CATALOG_WRITE

## Introduction

Creates multiple promotions. Works synchronously.

To create a single promotion, call [Create Promotion](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/promotions-v3/create-promotion.md).

---

## REST API

### Schema

```
 Method: bulkCreatePromotions
 Description: Creates multiple promotions. Works synchronously.  To create a single promotion, call [Create Promotion](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/promotions-v3/create-promotion.md).
 URL: https://www.wixapis.com/stores/v3/bulk/promotions/create
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  promotions, promotions.name, promotions.media
 Method parameters: 
   param name: promotions | type: array<promotions> | description: List of promotions to create. | required: true | validation: minItems 1, maxItems 100
              - name: name | type: string | description: Promotion name. | required: true | validation: minLength 1, maxLength 50
              - name: media | type: PromotionMedia | description: Promotion media. | required: true 
                 - ONE-OF: 
                    - name: id | type: string | description: Set media by GUID of an existing file in Wix Media Manager.  | validation: minLength 1, maxLength 200
                    - name: url | type: string | description: Set media using an external media URL.  When provided, Wix Media Manager imports the media asynchronously. During import: - `image` is empty. - The promotion is saved as disabled regardless of the requested `enabled` value.  Once the import completes successfully, the promotion's `image` is populated and `enabled` is set to the originally requested value. If the import fails, the promotion's entire `media` object is cleared and the promotion stays disabled. To retry, set new media.  | validation: format WEB_URL
                 - name: altText | type: string | description: Image alt text.  | validation: minLength 1, maxLength 1000
                 - name: displayName | type: string | description: Media display name.  Overrides the default media name. Can be passed only when the media is set by a URL in this item's `url` field.  | validation: maxLength 80
              - name: destinationUrl | type: string | description: URL the promotion redirects to when a customer clicks the banner.  | validation: format WEB_URL
              - name: categories | type: array<CategoryAssignment> | description: Categories the promotion is directly assigned to. A promotion may also appear in subcategories when `appliedToSubcategories` is `true` for a directly assigned category.  | validation: maxItems 1000
                 - name: id | type: string | description: Category GUID.  | validation: format GUID
                 - name: position | type: integer | description: Position of the promotion within the category, starting from 1.  Must be provided for each category assignment — omitting it fails validation, because positions start from 1.  | validation: minimum 1
                 - name: appliedToSubcategories | type: boolean | description: Whether the promotion also appears in this category's subcategories. When inherited by a subcategory, the promotion keeps the same position.  Default: `false`  
              - name: enabled | type: boolean | description: Whether the promotion is enabled.  When creating or updating with `media.url`, this value takes effect only after the media import completes successfully. See `media.url` for details.  Default: `false`  
              - name: extendedFields | type: ExtendedFields | description: Custom field data for the promotion object.  [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
                 - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
              - name: tags | type: Tags | description: Tags for organizing and filtering promotions.  
                 - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
                    - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
                 - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
   param name: returnEntity | type: returnEntity | description: Whether to return the created promotions in the response.  
 Return type: BulkCreatePromotionsResponse
  - name: results | type: array<BulkPromotionResult> | description: List of the bulk create operation results including the promotions and metadata.  | validation: minItems 1, maxItems 100
     - name: itemMetadata | type: ItemMetadata | description: Metadata for this specific create operation.  
        - name: id | type: string | description: Item GUID. Provided only whenever possible. For example, `itemId` can't be provided when item creation has failed.  | validation: format GUID
        - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items.  | validation: minimum 0
        - name: success | type: boolean | description: Whether the requested action for this item was successful. When `false`, the `error` field is returned.  
        - 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: Promotion | description: Created promotion. Returned only when `returnEntity` is `true` in the request.  
        - name: id | type: string | description: Promotion GUID.  | validation: format GUID
        - name: revision | type: string | description: Revision number, which increments by 1 each time the promotion is updated. To prevent conflicting changes, the current revision must be passed when updating the promotion.  | validation: format int64
        - name: createdDate | type: string | description: Date and time the promotion was created.  | validation: format date-time
        - name: updatedDate | type: string | description: Date and time the promotion was last updated.  | validation: format date-time
        - name: name | type: string | description: Promotion name.  | validation: minLength 1, maxLength 50
        - name: media | type: PromotionMedia | description: Promotion media.  
           - ONE-OF: 
              - name: id | type: string | description: Set media by GUID of an existing file in Wix Media Manager.  | validation: minLength 1, maxLength 200
              - name: url | type: string | description: Set media using an external media URL.  When provided, Wix Media Manager imports the media asynchronously. During import: - `image` is empty. - The promotion is saved as disabled regardless of the requested `enabled` value.  Once the import completes successfully, the promotion's `image` is populated and `enabled` is set to the originally requested value. If the import fails, the promotion's entire `media` object is cleared and the promotion stays disabled. To retry, set new media.  | validation: format WEB_URL
           - name: altText | type: string | description: Image alt text.  | validation: minLength 1, maxLength 1000
           - name: displayName | type: string | description: Media display name.  Overrides the default media name. Can be passed only when the media is set by a URL in this item's `url` field.  | validation: maxLength 80
           - name: mediaType | type: MediaType | description: Media type.  
                 - enum:
                 -     IMAGE: Image media type.
           - name: uploadId | type: string | description: GUID of the asynchronous media import that Wix Media Manager runs when media is set with a `url`.  | validation: format GUID
        - name: destinationUrl | type: string | description: URL the promotion redirects to when a customer clicks the banner.  | validation: format WEB_URL
        - name: categories | type: array<CategoryAssignment> | description: Categories the promotion is directly assigned to. A promotion may also appear in subcategories when `appliedToSubcategories` is `true` for a directly assigned category.  | validation: maxItems 1000
           - name: id | type: string | description: Category GUID.  | validation: format GUID
           - name: position | type: integer | description: Position of the promotion within the category, starting from 1.  Must be provided for each category assignment — omitting it fails validation, because positions start from 1.  | validation: minimum 1
           - name: appliedToSubcategories | type: boolean | description: Whether the promotion also appears in this category's subcategories. When inherited by a subcategory, the promotion keeps the same position.  Default: `false`  
        - name: enabled | type: boolean | description: Whether the promotion is enabled.  When creating or updating with `media.url`, this value takes effect only after the media import completes successfully. See `media.url` for details.  Default: `false`  
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the promotion object.  [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: tags | type: Tags | description: Tags for organizing and filtering promotions.  
           - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
              - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
           - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Metadata for the bulk create operation.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  | validation: minimum 0
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  | validation: minimum 0
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  | validation: minimum 0

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: DUPLICATE_CATEGORY_ASSIGNMENT | Description: A category is assigned to the same promotion more than once.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MEDIA_NOT_FOUND | Description: Couldn't find the media in Media Manager.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PROMOTIONS_LIMIT_EXCEEDED | Description: The maximum number of promotions per site has been reached.


```

### Examples

### Bulk Create Promotions
Creates two promotions and returns the created entities.

```curl
curl -X POST \
  'https://www.wixapis.com/stores/v3/bulk/promotions/create' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
    "promotions": [
      {
        "name": "Winter Sale",
        "media": {
          "id": "b7a91c_3d5f8e2a41c6497f8b219d0e6c53a7f2~mv2.png",
          "altText": "Winter sale banner"
        },
        "destinationUrl": "https://www.example.com/winter-sale",
        "categories": [
          {
            "id": "f6c2e4a1-8b3d-4e5f-9a1b-2c3d4e5f6a7b",
            "position": 2
          }
        ],
        "enabled": true
      },
      {
        "name": "Spring Clearance",
        "media": {
          "id": "c53f08_9a4b7d1e5f28436c8e02b6a91d47c5e3~mv2.png",
          "altText": "Spring clearance banner"
        },
        "categories": [
          {
            "id": "9b1d2f3e-6a5c-4d7b-8e9f-0a1b2c3d4e5f",
            "position": 1,
            "appliedToSubcategories": true
          }
        ],
        "enabled": false
      }
    ],
    "returnEntity": true
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.stores.promotionsV3.bulkCreatePromotions(promotions, options)
 Description: Creates multiple promotions. Works synchronously.  To create a single promotion, call [Create Promotion](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/promotions-v3/create-promotion.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  promotions, promotions.name, promotions.media
 Method parameters: 
   param name: options | type: BulkCreatePromotionsOptions  none  
        - name: returnEntity | type: boolean | description: Whether to return the created promotions in the response.  
   param name: promotions | type: array<array> | description: List of promotions to create. | required: true | validation: minItems 1, maxItems 100
              - name: name | type: string | description: Promotion name. | required: true | validation: minLength 1, maxLength 50
              - name: media | type: PromotionMedia | description: Promotion media. | required: true 
                 - ONE-OF: - required: true
                    - name: _id | type: string | description: Set media by GUID of an existing file in Wix Media Manager.  | validation: minLength 1, maxLength 200
                    - name: url | type: string | description: Set media using an external media URL.  When provided, Wix Media Manager imports the media asynchronously. During import: - `image` is empty. - The promotion is saved as disabled regardless of the requested `enabled` value.  Once the import completes successfully, the promotion's `image` is populated and `enabled` is set to the originally requested value. If the import fails, the promotion's entire `media` object is cleared and the promotion stays disabled. To retry, set new media.  | validation: format WEB_URL
                 - name: altText | type: string | description: Image alt text.  | validation: minLength 1, maxLength 1000
                 - name: displayName | type: string | description: Media display name.  Overrides the default media name. Can be passed only when the media is set by a URL in this item's `url` field.  | validation: maxLength 80
              - name: destinationUrl | type: string | description: URL the promotion redirects to when a customer clicks the banner.  | validation: format WEB_URL
              - name: categories | type: array<CategoryAssignment> | description: Categories the promotion is directly assigned to. A promotion may also appear in subcategories when `appliedToSubcategories` is `true` for a directly assigned category.  | validation: maxItems 1000
                 - name: _id | type: string | description: Category GUID.  | validation: format GUID
                 - name: position | type: integer | description: Position of the promotion within the category, starting from 1.  Must be provided for each category assignment — omitting it fails validation, because positions start from 1.  | validation: minimum 1
                 - name: appliedToSubcategories | type: boolean | description: Whether the promotion also appears in this category's subcategories. When inherited by a subcategory, the promotion keeps the same position.  Default: `false`  
              - name: enabled | type: boolean | description: Whether the promotion is enabled.  When creating or updating with `media.url`, this value takes effect only after the media import completes successfully. See `media.url` for details.  Default: `false`  
              - name: extendedFields | type: ExtendedFields | description: Custom field data for the promotion object.  [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
                 - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
              - name: tags | type: Tags | description: Tags for organizing and filtering promotions.  
                 - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
                    - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
                 - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
 Return type: PROMISE<BulkCreatePromotionsResponse>
  - name: results | type: array<BulkPromotionResult> | description: List of the bulk create operation results including the promotions and metadata.  | validation: minItems 1, maxItems 100
     - name: itemMetadata | type: ItemMetadata | description: Metadata for this specific create operation.  
        - name: _id | type: string | description: Item GUID. Provided only whenever possible. For example, `itemId` can't be provided when item creation has failed.  | validation: format GUID
        - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items.  | validation: minimum 0
        - name: success | type: boolean | description: Whether the requested action for this item was successful. When `false`, the `error` field is returned.  
        - 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: Promotion | description: Created promotion. Returned only when `returnEntity` is `true` in the request.  
        - name: _id | type: string | description: Promotion GUID.  | validation: format GUID
        - name: revision | type: string | description: Revision number, which increments by 1 each time the promotion is updated. To prevent conflicting changes, the current revision must be passed when updating the promotion.  | validation: format int64
        - name: _createdDate | type: Date | description: Date and time the promotion was created.  
        - name: _updatedDate | type: Date | description: Date and time the promotion was last updated.  
        - name: name | type: string | description: Promotion name.  | validation: minLength 1, maxLength 50
        - name: media | type: PromotionMedia | description: Promotion media.  
           - ONE-OF: 
              - name: _id | type: string | description: Set media by GUID of an existing file in Wix Media Manager.  | validation: minLength 1, maxLength 200
              - name: url | type: string | description: Set media using an external media URL.  When provided, Wix Media Manager imports the media asynchronously. During import: - `image` is empty. - The promotion is saved as disabled regardless of the requested `enabled` value.  Once the import completes successfully, the promotion's `image` is populated and `enabled` is set to the originally requested value. If the import fails, the promotion's entire `media` object is cleared and the promotion stays disabled. To retry, set new media.  | validation: format WEB_URL
           - name: altText | type: string | description: Image alt text.  | validation: minLength 1, maxLength 1000
           - name: displayName | type: string | description: Media display name.  Overrides the default media name. Can be passed only when the media is set by a URL in this item's `url` field.  | validation: maxLength 80
           - name: mediaType | type: MediaType | description: Media type.  
                 - enum:
                 -     IMAGE: Image media type.
           - name: uploadId | type: string | description: GUID of the asynchronous media import that Wix Media Manager runs when media is set with a `url`.  | validation: format GUID
        - name: destinationUrl | type: string | description: URL the promotion redirects to when a customer clicks the banner.  | validation: format WEB_URL
        - name: categories | type: array<CategoryAssignment> | description: Categories the promotion is directly assigned to. A promotion may also appear in subcategories when `appliedToSubcategories` is `true` for a directly assigned category.  | validation: maxItems 1000
           - name: _id | type: string | description: Category GUID.  | validation: format GUID
           - name: position | type: integer | description: Position of the promotion within the category, starting from 1.  Must be provided for each category assignment — omitting it fails validation, because positions start from 1.  | validation: minimum 1
           - name: appliedToSubcategories | type: boolean | description: Whether the promotion also appears in this category's subcategories. When inherited by a subcategory, the promotion keeps the same position.  Default: `false`  
        - name: enabled | type: boolean | description: Whether the promotion is enabled.  When creating or updating with `media.url`, this value takes effect only after the media import completes successfully. See `media.url` for details.  Default: `false`  
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the promotion object.  [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: tags | type: Tags | description: Tags for organizing and filtering promotions.  
           - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
              - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
           - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Metadata for the bulk create operation.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  | validation: minimum 0
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  | validation: minimum 0
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  | validation: minimum 0

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: DUPLICATE_CATEGORY_ASSIGNMENT | Description: A category is assigned to the same promotion more than once.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MEDIA_NOT_FOUND | Description: Couldn't find the media in Media Manager.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PROMOTIONS_LIMIT_EXCEEDED | Description: The maximum number of promotions per site has been reached.


```

### Examples

### Create multiple promotions in one call
```javascript
import { promotionsV3 } from "@wix/stores";

const promotions = [
  { name: "Spring Sale", media: { url: "https://static.wixstatic.com/media/spring.jpg" } },
  { name: "Clearance", media: { url: "https://static.wixstatic.com/media/clearance.jpg" } },
];

async function bulkCreatePromotions() {
  const response = await promotionsV3.bulkCreatePromotions(promotions, { returnEntity: true });
  return response;
}

/* Promise resolves to:
 * {
 *   "results": [
 *     {
 *       "itemMetadata": { "originalIndex": 0, "success": true, "_id": "0aeeee8a-7039-4d01-975c-5786d4238222" },
 *       "item": { "_id": "0aeeee8a-7039-4d01-975c-5786d4238222", "revision": "1", "name": "Spring Sale", "enabled": false }
 *     }
 *   ],
 *   "bulkActionMetadata": { "totalSuccesses": 2, "totalFailures": 0, "undetailedFailures": 0 }
 * }
 */

```

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

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


async function bulkCreatePromotions(promotions,options) {
  const response = await myWixClient.promotionsV3.bulkCreatePromotions(promotions,options);
};
```

---