> 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

# BulkCreateFulfillment

# Package: orders

# Namespace: Fulfillments

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-fulfillments/bulk-create-fulfillments.md

## Permission Scopes:
Manage Orders: SCOPE.DC-STORES.MANAGE-ORDERS

## Introduction

Creates fulfillments for multiple orders.

You can specify up to 100 orders in a single call. Each order can appear once in `ordersWithFulfillments`.

To create a single fulfillment, call [Create Fulfillment](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-fulfillments/create-fulfillment.md).

---

## REST API

### Schema

```
 Method: bulkCreateFulfillment
 Description: Creates fulfillments for multiple orders.  You can specify up to 100 orders in a single call. Each order can appear once in `ordersWithFulfillments`.  To create a single fulfillment, call [Create Fulfillment](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-fulfillments/create-fulfillment.md).
 URL: https://www.wixapis.com/ecom/v1/fulfillments/orders/bulk/create-fulfillments
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  ordersWithFulfillments, ordersWithFulfillments.orderId, ordersWithFulfillments.fulfillments, ordersWithFulfillments.fulfillments.lineItems, ordersWithFulfillments.fulfillments.lineItems.id
 Method parameters: 
   param name: ordersWithFulfillments | type: array<ordersWithFulfillments> | description: List of order GUIDs and their associated fulfillments. | required: true | validation: minItems 1, maxItems 100
              - name: orderId | type: string | description: Order GUID. | required: true | validation: minLength 1, maxLength 100
              - name: fulfillments | type: array<Fulfillment> | description: Fulfillments associated with the order. | required: true | validation: minItems 1
                 - ONE-OF: 
                    - name: trackingInfo | type: FulfillmentTrackingInfo | description: Tracking info.  
                       - name: trackingNumber | type: string | description: Shipping/delivery tracking number.  | validation: minLength 1, maxLength 100
                       - name: shippingProvider | type: string | description: Shipping provider name. Specify a predefined provider to have `trackingLink` generated automatically, or any other name for a custom provider.  Predefined providers: + `"fedex"`: FedEx. + `"ups"`: UPS. + `"usps"`: United States Postal Service. + `"dhl"`: DHL. + `"canadaPost"`: Canada Post. + `"hermes"`: Hermes.  For a custom provider, specify `trackingLink` yourself. It isn't generated.  | validation: minLength 1, maxLength 100
                       - name: trackingLink | type: string | description: URL where customers can track the shipment.  When you don't specify `trackingLink` and `shippingProvider` is a predefined provider, the URL is generated from `trackingNumber` in the carrier's tracking URL format. For a custom provider, specify the URL of the carrier's tracking page.  | validation: minLength 1, maxLength 2048, format WEB_URL
                    - name: customInfo | type: CustomFulfillmentInfo | description: Custom fulfillment info.  
                       - name: fieldsData | type: object | description: Custom fulfillment info in key:value form.  | validation: minItems 0, maxItems 100, format map
                 - name: lineItems | type: array<FulfillmentLineItem> | description: Line items being fulfilled.  | validation: minItems 0, maxItems 300
                    - name: id | type: string | description: Line item GUID (mirrors the GUID of the order line item).  | validation: format GUID
                    - name: quantity | type: integer | description: Line item quantity.  If the order doesn't have enough unfulfilled units of this line item, the fulfillment isn't created and an error is returned.  Default: When creating a fulfillment, the line item's remaining unfulfilled quantity.  | validation: minimum 1, maximum 100000, format int32
                 - name: status | type: string | description: The current status of the fulfillment process.  Supported values (case-sensitive, any other value is rejected): + `"Pending"` - Initial state when fulfillment is created but processing hasn't started. + `"Accepted"` - Order has been received and validated for fulfillment. + `"Ready"` - Items have been picked and packed, ready for shipping. + `"In_Delivery"` - Items have been handed over to the shipping carrier. + `"Fulfilled"` - Delivery has been completed successfully.  The status typically progresses from `Pending` to `Accepted`, `Ready`, `In_Delivery`, and finally `Fulfilled`. Update the status manually or automatically depending on your fulfillment workflow.  This field is informational. The order's `fulfillmentStatus` is primarily derived from the fulfilled line item quantities, not from this field.  | validation: minLength 1, maxLength 100
                 - name: completed | type: boolean | description: Whether the fulfillment is complete.  When `false`, the fulfillment's line items don't count as fulfilled when the order's `fulfillmentStatus` is calculated. When not set, they count as fulfilled.  Line items can't be updated in a fulfillment where `completed` is `true`.  
 Return type: BulkCreateFulfillmentResponse
  - name: results | type: array<BulkOrderFulfillmentsResult> | description: Result for each order in the request.  
     - name: itemMetadata | type: ItemMetadata | description: Item 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: ordersWithFulfillments | type: OrderWithFulfillments | description: Order GUID and all of the order's fulfillments, including fulfillments that existed before the call.  Returned only when `itemMetadata.success` is `true`.  
        - name: orderId | type: string | description: Order GUID.  | validation: minLength 1, maxLength 100
        - name: fulfillments | type: array<Fulfillment> | description: Fulfillments associated with the order.  
           - ONE-OF: 
              - name: trackingInfo | type: FulfillmentTrackingInfo | description: Tracking info.  
                 - name: trackingNumber | type: string | description: Shipping/delivery tracking number.  | validation: minLength 1, maxLength 100
                 - name: shippingProvider | type: string | description: Shipping provider name. Specify a predefined provider to have `trackingLink` generated automatically, or any other name for a custom provider.  Predefined providers: + `"fedex"`: FedEx. + `"ups"`: UPS. + `"usps"`: United States Postal Service. + `"dhl"`: DHL. + `"canadaPost"`: Canada Post. + `"hermes"`: Hermes.  For a custom provider, specify `trackingLink` yourself. It isn't generated.  | validation: minLength 1, maxLength 100
                 - name: trackingLink | type: string | description: URL where customers can track the shipment.  When you don't specify `trackingLink` and `shippingProvider` is a predefined provider, the URL is generated from `trackingNumber` in the carrier's tracking URL format. For a custom provider, specify the URL of the carrier's tracking page.  | validation: minLength 1, maxLength 2048, format WEB_URL
              - name: customInfo | type: CustomFulfillmentInfo | description: Custom fulfillment info.  
                 - name: fieldsData | type: object | description: Custom fulfillment info in key:value form.  | validation: minItems 0, maxItems 100, format map
           - name: id | type: string | description: Fulfillment GUID.  | read-only: true | validation: format GUID
           - name: createdDate | type: string | description: Date and time the fulfillment was created.  | read-only: true | validation: format date-time
           - name: lineItems | type: array<FulfillmentLineItem> | description: Line items being fulfilled.  | validation: minItems 0, maxItems 300
              - name: id | type: string | description: Line item GUID (mirrors the GUID of the order line item).  | validation: format GUID
              - name: quantity | type: integer | description: Line item quantity.  If the order doesn't have enough unfulfilled units of this line item, the fulfillment isn't created and an error is returned.  Default: When creating a fulfillment, the line item's remaining unfulfilled quantity.  | validation: minimum 1, maximum 100000, format int32
           - name: status | type: string | description: The current status of the fulfillment process.  Supported values (case-sensitive, any other value is rejected): + `"Pending"` - Initial state when fulfillment is created but processing hasn't started. + `"Accepted"` - Order has been received and validated for fulfillment. + `"Ready"` - Items have been picked and packed, ready for shipping. + `"In_Delivery"` - Items have been handed over to the shipping carrier. + `"Fulfilled"` - Delivery has been completed successfully.  The status typically progresses from `Pending` to `Accepted`, `Ready`, `In_Delivery`, and finally `Fulfilled`. Update the status manually or automatically depending on your fulfillment workflow.  This field is informational. The order's `fulfillmentStatus` is primarily derived from the fulfilled line item quantities, not from this field.  | validation: minLength 1, maxLength 100
           - name: completed | type: boolean | description: Whether the fulfillment is complete.  When `false`, the fulfillment's line items don't count as fulfilled when the order's `fulfillmentStatus` is calculated. When not set, they count as fulfilled.  Line items can't be updated in a fulfillment where `completed` is `true`.  
  - 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 Fulfillments
Creates a fulfillment for each of 2 orders.

```curl
curl -X POST \
  'https://www.wixapis.com/ecom/v1/fulfillments/orders/bulk/create-fulfillments' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "ordersWithFulfillments": [
      {
        "orderId": "eb4b91d3-51f3-494d-94df-479ff2c6eb08",
        "fulfillments": [
          {
            "lineItems": [
              {
                "id": "00000000-0000-0000-0000-000000000001",
                "quantity": 1
              }
            ],
            "trackingInfo": {
              "trackingNumber": "12345",
              "shippingProvider": "fedex"
            }
          }
        ]
      },
      {
        "orderId": "719f96d3-80c7-45c2-b4c1-f15eb610f8a8",
        "fulfillments": [
          {
            "lineItems": [
              {
                "id": "00000000-0000-0000-0000-000000000001",
                "quantity": 1
              }
            ],
            "trackingInfo": {
              "trackingNumber": "67890",
              "shippingProvider": "usps"
            }
          }
        ]
      }
    ]
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.orderFulfillments.bulkCreateFulfillments(ordersWithFulfillments)
 Description: Creates fulfillments for multiple orders.  You can specify up to 100 orders in a single call. Each order can appear once in `ordersWithFulfillments`.  To create a single fulfillment, call [Create Fulfillment](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-fulfillments/create-fulfillment.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  ordersWithFulfillments, ordersWithFulfillments.orderId, ordersWithFulfillments.fulfillments, ordersWithFulfillments.fulfillments.lineItems, ordersWithFulfillments.fulfillments.lineItems._id
 Method parameters: 
   param name: ordersWithFulfillments | type: array<BulkCreateOrderWithFulfillments> | description: List of order GUIDs and their associated fulfillments. | required: true | validation: minItems 1, maxItems 100
              - name: orderId | type: string | description: Order GUID. | required: true | validation: minLength 1, maxLength 100
              - name: fulfillments | type: array<Fulfillment> | description: Fulfillments associated with the order. | required: true | validation: minItems 1
                 - ONE-OF: 
                    - name: trackingInfo | type: FulfillmentTrackingInfo | description: Tracking info.  
                       - name: trackingNumber | type: string | description: Shipping/delivery tracking number.  | validation: minLength 1, maxLength 100
                       - name: shippingProvider | type: string | description: Shipping provider name. Specify a predefined provider to have `trackingLink` generated automatically, or any other name for a custom provider.  Predefined providers: + `"fedex"`: FedEx. + `"ups"`: UPS. + `"usps"`: United States Postal Service. + `"dhl"`: DHL. + `"canadaPost"`: Canada Post. + `"hermes"`: Hermes.  For a custom provider, specify `trackingLink` yourself. It isn't generated.  | validation: minLength 1, maxLength 100
                       - name: trackingLink | type: string | description: URL where customers can track the shipment.  When you don't specify `trackingLink` and `shippingProvider` is a predefined provider, the URL is generated from `trackingNumber` in the carrier's tracking URL format. For a custom provider, specify the URL of the carrier's tracking page.  | validation: minLength 1, maxLength 2048, format WEB_URL
                    - name: customInfo | type: CustomFulfillmentInfo | description: Custom fulfillment info.  
                       - name: fieldsData | type: object | description: Custom fulfillment info in key:value form.  | validation: minItems 0, maxItems 100, format map
                 - name: lineItems | type: array<FulfillmentLineItem> | description: Line items being fulfilled.  | validation: minItems 0, maxItems 300
                    - name: _id | type: string | description: Line item GUID (mirrors the GUID of the order line item).  | validation: format GUID
                    - name: quantity | type: integer | description: Line item quantity.  If the order doesn't have enough unfulfilled units of this line item, the fulfillment isn't created and an error is returned.  Default: When creating a fulfillment, the line item's remaining unfulfilled quantity.  | validation: minimum 1, maximum 100000, format int32
                 - name: status | type: string | description: The current status of the fulfillment process.  Supported values (case-sensitive, any other value is rejected): + `"Pending"` - Initial state when fulfillment is created but processing hasn't started. + `"Accepted"` - Order has been received and validated for fulfillment. + `"Ready"` - Items have been picked and packed, ready for shipping. + `"In_Delivery"` - Items have been handed over to the shipping carrier. + `"Fulfilled"` - Delivery has been completed successfully.  The status typically progresses from `Pending` to `Accepted`, `Ready`, `In_Delivery`, and finally `Fulfilled`. Update the status manually or automatically depending on your fulfillment workflow.  This field is informational. The order's `fulfillmentStatus` is primarily derived from the fulfilled line item quantities, not from this field.  | validation: minLength 1, maxLength 100
                 - name: completed | type: boolean | description: Whether the fulfillment is complete.  When `false`, the fulfillment's line items don't count as fulfilled when the order's `fulfillmentStatus` is calculated. When not set, they count as fulfilled.  Line items can't be updated in a fulfillment where `completed` is `true`.  
 Return type: PROMISE<BulkCreateFulfillmentResponse>
  - name: results | type: array<BulkOrderFulfillmentsResult> | description: Result for each order in the request.  
     - name: itemMetadata | type: ItemMetadata | description: Item 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: ordersWithFulfillments | type: OrderWithFulfillments | description: Order GUID and all of the order's fulfillments, including fulfillments that existed before the call.  Returned only when `itemMetadata.success` is `true`.  
        - name: orderId | type: string | description: Order GUID.  | validation: minLength 1, maxLength 100
        - name: fulfillments | type: array<Fulfillment> | description: Fulfillments associated with the order.  
           - ONE-OF: 
              - name: trackingInfo | type: FulfillmentTrackingInfo | description: Tracking info.  
                 - name: trackingNumber | type: string | description: Shipping/delivery tracking number.  | validation: minLength 1, maxLength 100
                 - name: shippingProvider | type: string | description: Shipping provider name. Specify a predefined provider to have `trackingLink` generated automatically, or any other name for a custom provider.  Predefined providers: + `"fedex"`: FedEx. + `"ups"`: UPS. + `"usps"`: United States Postal Service. + `"dhl"`: DHL. + `"canadaPost"`: Canada Post. + `"hermes"`: Hermes.  For a custom provider, specify `trackingLink` yourself. It isn't generated.  | validation: minLength 1, maxLength 100
                 - name: trackingLink | type: string | description: URL where customers can track the shipment.  When you don't specify `trackingLink` and `shippingProvider` is a predefined provider, the URL is generated from `trackingNumber` in the carrier's tracking URL format. For a custom provider, specify the URL of the carrier's tracking page.  | validation: minLength 1, maxLength 2048, format WEB_URL
              - name: customInfo | type: CustomFulfillmentInfo | description: Custom fulfillment info.  
                 - name: fieldsData | type: object | description: Custom fulfillment info in key:value form.  | validation: minItems 0, maxItems 100, format map
           - name: _id | type: string | description: Fulfillment GUID.  | read-only: true | validation: format GUID
           - name: _createdDate | type: Date | description: Date and time the fulfillment was created.  | read-only: true 
           - name: lineItems | type: array<FulfillmentLineItem> | description: Line items being fulfilled.  | validation: minItems 0, maxItems 300
              - name: _id | type: string | description: Line item GUID (mirrors the GUID of the order line item).  | validation: format GUID
              - name: quantity | type: integer | description: Line item quantity.  If the order doesn't have enough unfulfilled units of this line item, the fulfillment isn't created and an error is returned.  Default: When creating a fulfillment, the line item's remaining unfulfilled quantity.  | validation: minimum 1, maximum 100000, format int32
           - name: status | type: string | description: The current status of the fulfillment process.  Supported values (case-sensitive, any other value is rejected): + `"Pending"` - Initial state when fulfillment is created but processing hasn't started. + `"Accepted"` - Order has been received and validated for fulfillment. + `"Ready"` - Items have been picked and packed, ready for shipping. + `"In_Delivery"` - Items have been handed over to the shipping carrier. + `"Fulfilled"` - Delivery has been completed successfully.  The status typically progresses from `Pending` to `Accepted`, `Ready`, `In_Delivery`, and finally `Fulfilled`. Update the status manually or automatically depending on your fulfillment workflow.  This field is informational. The order's `fulfillmentStatus` is primarily derived from the fulfilled line item quantities, not from this field.  | validation: minLength 1, maxLength 100
           - name: completed | type: boolean | description: Whether the fulfillment is complete.  When `false`, the fulfillment's line items don't count as fulfilled when the order's `fulfillmentStatus` is calculated. When not set, they count as fulfilled.  Line items can't be updated in a fulfillment where `completed` is `true`.  
  - 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

### Create a fulfillment for 2 different orders (with elevated permissions)
```javascript
import { orderFulfillments } from '@wix/ecom';
import { auth } from '@wix/essentials';

/* Sample ordersWithFulfillments value:
 * [
 *   {
 *     orderId: 'e613320a-8e8f-4f8f-9d87-b5edc9f99788',
 *     fulfillments: [{
 *       lineItems: [{
 *         _id: '00000000-0000-0000-0000-000000000003',
 *         quantity: 1
 *       }],
 *       trackingInfo: {
 *         trackingNumber: '93645',
 *         shippingProvider: 'canadaPost'
 *       }
 *     }]
 *   },
 *   {
 *     orderId: 'a6c3a817-579d-4cb5-8521-2fe53b2c4bf1',
 *     fulfillments: [{
 *       lineItems: [{
 *         _id: '00000000-0000-0000-0000-000000000001',
 *         quantity: 1
 *       }],
 *       trackingInfo: {
 *         trackingNumber: '28674',
 *         shippingProvider: 'usps'
 *       }
 *     }]
 *   }
 * ];
 */

const elevatedBulkCreateFulfillments = auth.elevate(orderFulfillments.bulkCreateFulfillments);

export async function myBulkCreateFulfillmentsFunction(ordersWithFulfillments) {
  try {
    const newBulkFulfillments = await elevatedBulkCreateFulfillments(ordersWithFulfillments);

    const firstNewFulfillments = newBulkFulfillments.results[0].ordersWithFulfillments.fulfillments;
    const secondNewFulfillments = newBulkFulfillments.results[1].ordersWithFulfillments.fulfillments;

    console.log('Success! Created fulfillments:', newBulkFulfillments);
    return newBulkFulfillments;
  } catch (error) {
    console.error(error);
    // Handle the error
  }

}

/* Promise resolves to:
 *
 * {
 *   "results": [
 *     {
 *       "itemMetadata": {
 *         "_id": "e613320a-8e8f-4f8f-9d87-b5edc9f99788",
 *         "originalIndex": 0,
 *         "success": true
 *       },
 *       "ordersWithFulfillments": {
 *         "orderId": "e613320a-8e8f-4f8f-9d87-b5edc9f99788",
 *         "fulfillments": [
 *           {
 *             "_id": "397788c4-1c5b-40a3-9431-d4da8662a993",
 *             "_createdDate": "2023-03-07T14:26:33.276Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000002",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "93643",
 *               "shippingProvider": "canadaPost",
 *               "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93643"
 *             }
 *           },
 *           {
 *             "_id": "a875e4b7-c25d-4228-98e2-313ea6c07f95",
 *             "_createdDate": "2023-03-07T14:23:59.426Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000001",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "93644",
 *               "shippingProvider": "canadaPost",
 *               "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93644"
 *             }
 *           },
 *           {
 *             "_id": "e75bd872-69c9-427f-983a-280412161700",
 *             "_createdDate": "2023-03-07T14:30:21.535Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000003",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "93645",
 *               "shippingProvider": "canadaPost",
 *               "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93645"
 *             }
 *           }
 *         ]
 *       }
 *     },
 *     {
 *       "itemMetadata": {
 *         "_id": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1",
 *         "originalIndex": 1,
 *         "success": true
 *       },
 *       "ordersWithFulfillments": {
 *         "orderId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1",
 *         "fulfillments": [
 *           {
 *             "_id": "a838877d-3f13-49f3-ab29-1cde478e0949",
 *             "_createdDate": "2023-03-07T14:30:21.535Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000001",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "28674",
 *               "shippingProvider": "usps",
 *               "trackingLink": "https://tools.usps.com/go/TrackConfirmAction.action?tLabels=28674"
 *             }
 *           }
 *         ]
 *       }
 *     }
 *   ],
 *   "bulkActionMetadata": {
 *     "totalSuccesses": 2,
 *     "totalFailures": 0,
 *     "undetailedFailures": 0
 *   }
 * }
 *
 */
```

### Create a fulfillment for 2 different orders
```javascript
import { orderFulfillments } from '@wix/ecom';

/* Sample ordersWithFulfillments value:
 * [
 *   {
 *     orderId: 'e613320a-8e8f-4f8f-9d87-b5edc9f99788',
 *     fulfillments: [{
 *       lineItems: [{
 *         _id: '00000000-0000-0000-0000-000000000003',
 *         quantity: 1
 *       }],
 *       trackingInfo: {
 *         trackingNumber: '93645',
 *         shippingProvider: 'canadaPost'
 *       }
 *     }]
 *   },
 *   {
 *     orderId: 'a6c3a817-579d-4cb5-8521-2fe53b2c4bf1',
 *     fulfillments: [{
 *       lineItems: [{
 *         _id: '00000000-0000-0000-0000-000000000001',
 *         quantity: 1
 *       }],
 *       trackingInfo: {
 *         trackingNumber: '28674',
 *         shippingProvider: 'usps'
 *       }
 *     }]
 *   }
 * ];
 */

export async function myBulkCreateFulfillmentsFunction(ordersWithFulfillments) {
  try {
    const newBulkFulfillments = await orderFulfillments.bulkCreateFulfillments(ordersWithFulfillments);

    const firstNewFulfillments = newBulkFulfillments.results[0].ordersWithFulfillments.fulfillments;
    const secondNewFulfillments = newBulkFulfillments.results[1].ordersWithFulfillments.fulfillments;

    console.log('Success! Created fulfillments:', newBulkFulfillments);
    return newBulkFulfillments;
  } catch (error) {
    console.error(error);
    // Handle the error
  }

}

/* Promise resolves to:
 *
 * {
 *   "results": [
 *     {
 *       "itemMetadata": {
 *         "_id": "e613320a-8e8f-4f8f-9d87-b5edc9f99788",
 *         "originalIndex": 0,
 *         "success": true
 *       },
 *       "ordersWithFulfillments": {
 *         "orderId": "e613320a-8e8f-4f8f-9d87-b5edc9f99788",
 *         "fulfillments": [
 *           {
 *             "_id": "397788c4-1c5b-40a3-9431-d4da8662a993",
 *             "_createdDate": "2023-03-07T14:26:33.276Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000002",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "93643",
 *               "shippingProvider": "canadaPost",
 *               "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93643"
 *             }
 *           },
 *           {
 *             "_id": "a875e4b7-c25d-4228-98e2-313ea6c07f95",
 *             "_createdDate": "2023-03-07T14:23:59.426Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000001",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "93644",
 *               "shippingProvider": "canadaPost",
 *               "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93644"
 *             }
 *           },
 *           {
 *             "_id": "e75bd872-69c9-427f-983a-280412161700",
 *             "_createdDate": "2023-03-07T14:30:21.535Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000003",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "93645",
 *               "shippingProvider": "canadaPost",
 *               "trackingLink": "https://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=93645"
 *             }
 *           }
 *         ]
 *       }
 *     },
 *     {
 *       "itemMetadata": {
 *         "_id": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1",
 *         "originalIndex": 1,
 *         "success": true
 *       },
 *       "ordersWithFulfillments": {
 *         "orderId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1",
 *         "fulfillments": [
 *           {
 *             "_id": "a838877d-3f13-49f3-ab29-1cde478e0949",
 *             "_createdDate": "2023-03-07T14:30:21.535Z",
 *             "lineItems": [
 *               {
 *                 "_id": "00000000-0000-0000-0000-000000000001",
 *                 "quantity": 1
 *               }
 *             ],
 *             "trackingInfo": {
 *               "trackingNumber": "28674",
 *               "shippingProvider": "usps",
 *               "trackingLink": "https://tools.usps.com/go/TrackConfirmAction.action?tLabels=28674"
 *             }
 *           }
 *         ]
 *       }
 *     }
 *   ],
 *   "bulkActionMetadata": {
 *     "totalSuccesses": 2,
 *     "totalFailures": 0,
 *     "undetailedFailures": 0
 *   }
 * }
 *
 */
```

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

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


async function bulkCreateFulfillments(ordersWithFulfillments) {
  const response = await myWixClient.orderFulfillments.bulkCreateFulfillments(ordersWithFulfillments);
};
```

---