> 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

# CalculateFirstAvailableTimeSlotsForItem

# Package: onlineOrders

# Namespace: OperationsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/online-orders/operations/calculate-first-available-time-slots-for-item.md

## Permission Scopes:
Manage Restaurants - all permissions: SCOPE.RESTAURANTS.MEGA-SCOPES

## Introduction

Calculates the first available time slot of each fulfillment type for a specific menu item.

The time slots reflect the operation's order scheduling and fulfillment methods, as well as the availability of the item, its section, and its menu.
A time slot when the item can't be ordered isn't returned.

When you specify a delivery address, only delivery fulfillment methods whose delivery area contains the address are considered. Without an address, all delivery fulfillment methods are considered, regardless of their delivery area.

---

## REST API

### Schema

```
 Method: calculateFirstAvailableTimeSlotsForItem
 Description: Calculates the first available time slot of each fulfillment type for a specific menu item.  The time slots reflect the operation's order scheduling and fulfillment methods, as well as the availability of the item, its section, and its menu. A time slot when the item can't be ordered isn't returned.  When you specify a delivery address, only delivery fulfillment methods whose delivery area contains the address are considered. Without an address, all delivery fulfillment methods are considered, regardless of their delivery area.
 URL: https://www.wixapis.com/restaurants-operations/v1/operations/{operationId}/first-available-time-slots-per-item
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  operationId, menuId, sectionId, itemId
 Method parameters: 
   param name: deliveryAddress | type: Address | description: Physical address  
    - ONE-OF: 
     - name: streetAddress | type: StreetAddress | description: Street name and number.  
        - name: number | type: string | description: Street number.  
        - name: name | type: string | description: Street name.  
        - name: apt | type: string | description: Apartment number.  
        - name: formattedAddressLine | type: string | description: Optional address line 1  
     - name: addressLine | type: string | description: Main address line, usually street and number as free text.  
        - name: country | type: string | description: Country code.  | validation: format COUNTRY
        - name: subdivision | type: string | description: Subdivision. Usually a state, region, prefecture, or province code, according to [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2).  
        - name: city | type: string | description: City name.  
        - name: postalCode | type: string | description: Zip/postal code.  
        - name: addressLine2 | type: string | description: Free text providing more detailed address info. Usually contains Apt, Suite, and Floor.  
        - name: formattedAddress | type: string | description: A string containing the full address of this location.  
        - name: hint | type: string | description: Free text to help find the address.  
        - name: geocode | type: AddressLocation | description: Coordinates of the physical address.  
           - name: latitude | type: number | description: Address latitude.  | validation: format double
           - name: longitude | type: number | description: Address longitude.  | validation: format double
        - name: countryFullname | type: string | description: Country full name.  
        - name: subdivisionFullname | type: string | description: Subdivision full name.  
        - name: subdivisions | type: array<Subdivision> | description: Multi-level subdivisions from top to bottom.  | validation: maxItems 6
           - name: code | type: string | description: Short subdivision code.  
           - name: name | type: string | description: Subdivision full name.  
   query param name: itemId | type: itemId | description: GUID of the item to retrieve the first available time slots for. | required: true | validation: format GUID
   query param name: menuId | type: menuId | description: GUID of the menu that contains the item. | required: true | validation: format GUID
   param name: operationId | type:   none | required: true 
   query param name: sectionId | type: sectionId | description: GUID of the menu section that contains the item. | required: true | validation: format GUID
 Return type: CalculateFirstAvailableTimeSlotsForItemResponse
  - name: timeslotsPerFulfillmentType | type: array<TimeSlotForFulfillment> | description: First available time slot of each fulfillment type.  Delivery time slots are limited to the delivery area only when a delivery address was specified.  
     - name: timeSlot | type: TimeSlot | description: Time slot details.  
        - name: startTime | type: string | description: Start date and time of the time slot in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format.  | validation: format date-time
        - name: endTime | type: string | description: End date and time of the time slot in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format.  | validation: format date-time
        - name: orderSchedulingType | type: OrderSchedulingType | description: Order scheduling type used by the operation.  
             - enum:
             -     ASAP: Immediate ordering.
             -     PREORDER: Scheduled ordering.
     - name: fulfillmentInfo | type: array<FulfillmentInfo> | description: Details for each available fulfillment option in the time slot.  | validation: maxItems 500
        - ONE-OF: 
           - name: maxTime | type: integer | description: Maximum time to fulfill the order.  
           - name: durationRange | type: DurationRange | description: Time range in which to fulfill the order.  
              - name: minDuration | type: integer | description: Minimum duration in minutes.  
              - name: maxDuration | type: integer | description: Maximum duration in minutes.  
        - name: fee | type: string | description: Fee for using this fulfillment option.  | validation: decimalValue {"gte":"0.00","maxScale":3}
        - name: minOrderPrice | type: string | description: Minimum order price to qualify for using this fulfillment option.  | validation: decimalValue {"gte":"0.00","maxScale":3}
        - name: freeFulfillmentPriceThreshold | type: string | description: Minimum order price to qualify for free fulfillment. If the order price exceeds this amount, the `fee` is waived.  | validation: decimalValue {"gte":"0.00","maxScale":3}
        - name: address | type: Address | description: Details on the address of the fulfillment. For pickup, this is the address to pick the order up from. For delivery, this is the address to deliver the order to.  
           - ONE-OF: 
              - name: streetAddress | type: StreetAddress | description: Street name and number.  
                 - name: number | type: string | description: Street number.  
                 - name: name | type: string | description: Street name.  
                 - name: apt | type: string | description: Apartment number.  
                 - name: formattedAddressLine | type: string | description: Optional address line 1  
              - name: addressLine | type: string | description: Main address line, usually street and number as free text.  
           - name: country | type: string | description: Country code.  | validation: format COUNTRY
           - name: subdivision | type: string | description: Subdivision. Usually a state, region, prefecture, or province code, according to [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2).  
           - name: city | type: string | description: City name.  
           - name: postalCode | type: string | description: Zip/postal code.  
           - name: addressLine2 | type: string | description: Free text providing more detailed address info. Usually contains Apt, Suite, and Floor.  
           - name: formattedAddress | type: string | description: A string containing the full address of this location.  
           - name: hint | type: string | description: Free text to help find the address.  
           - name: geocode | type: AddressLocation | description: Coordinates of the physical address.  
              - name: latitude | type: number | description: Address latitude.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
           - name: countryFullname | type: string | description: Country full name.  
           - name: subdivisionFullname | type: string | description: Subdivision full name.  
           - name: subdivisions | type: array<Subdivision> | description: Multi-level subdivisions from top to bottom.  | validation: maxItems 6
              - name: code | type: string | description: Short subdivision code.  
              - name: name | type: string | description: Subdivision full name.  
     - name: fulfilmentType | type: FulfillmentType | description: Fulfillment type.  
         - enum:
         -     PICKUP: Pickup fulfillment. The customer picks up the order from the restaurant.
         -     DELIVERY: Delivery fulfillment. The restaurant, or a representative, delivers the order to the customer.
  - name: cursorPagingMetadata | type: CursorPagingMetadata | description: Metadata for the paginated results.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.restaurants.operations.calculateFirstAvailableTimeSlotsForItem(operationId, menuId, options)
 Description: Calculates the first available time slot of each fulfillment type for a specific menu item.  The time slots reflect the operation's order scheduling and fulfillment methods, as well as the availability of the item, its section, and its menu. A time slot when the item can't be ordered isn't returned.  When you specify a delivery address, only delivery fulfillment methods whose delivery area contains the address are considered. Without an address, all delivery fulfillment methods are considered, regardless of their delivery area.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  operationId, menuId, options.sectionId, options.itemId, options
 Method parameters: 
   param name: operationId | type: string | description: Operation GUID. | required: true | validation: format GUID
   param name: menuId | type: CalculateFirstAvailableTimeSlotsForItem   | required: true 
        - name: value | type: string | description:   
   param name: options | type: CalculateFirstAvailableTimeSlotsForItemOptions  none | required: true 
        - name: sectionId | type: string | description: GUID of the menu section that contains the item. | required: true | validation: format GUID
        - name: itemId | type: string | description: GUID of the item to retrieve the first available time slots for. | required: true | validation: format GUID
        - name: deliveryAddress | type: Address | description: Delivery address.  When you specify a delivery address, only delivery fulfillment methods whose delivery area contains the address are considered. Without an address, all delivery fulfillment methods are considered, regardless of their delivery area.  
           - ONE-OF: 
              - name: streetAddress | type: StreetAddress | description: Street name and number.  
                 - name: number | type: string | description: Street number.  
                 - name: name | type: string | description: Street name.  
                 - name: apt | type: string | description: Apartment number.  
                 - name: formattedAddressLine | type: string | description: Optional address line 1  
              - name: addressLine | type: string | description: Main address line, usually street and number as free text.  
           - name: country | type: string | description: Country code.  | validation: format COUNTRY
           - name: subdivision | type: string | description: Subdivision. Usually a state, region, prefecture, or province code, according to [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2).  
           - name: city | type: string | description: City name.  
           - name: postalCode | type: string | description: Zip/postal code.  
           - name: addressLine2 | type: string | description: Free text providing more detailed address info. Usually contains Apt, Suite, and Floor.  
           - name: formattedAddress | type: string | description: A string containing the full address of this location.  
           - name: hint | type: string | description: Free text to help find the address.  
           - name: geocode | type: AddressLocation | description: Coordinates of the physical address.  
              - name: latitude | type: number | description: Address latitude.  
              - name: longitude | type: number | description: Address longitude.  
           - name: countryFullname | type: string | description: Country full name.  
           - name: subdivisionFullname | type: string | description: Subdivision full name.  
           - name: subdivisions | type: array<Subdivision> | description: Multi-level subdivisions from top to bottom.  | validation: maxItems 6
              - name: code | type: string | description: Short subdivision code.  
              - name: name | type: string | description: Subdivision full name.  
 Return type: PROMISE<CalculateFirstAvailableTimeSlotsForItemResponse>
  - name: timeslotsPerFulfillmentType | type: array<TimeSlotForFulfillment> | description: First available time slot of each fulfillment type.  Delivery time slots are limited to the delivery area only when a delivery address was specified.  
     - name: timeSlot | type: TimeSlot | description: Time slot details.  
        - name: startTime | type: Date | description: Start date and time of the time slot in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format.  
        - name: endTime | type: Date | description: End date and time of the time slot in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format.  
        - name: orderSchedulingType | type: OrderSchedulingType | description: Order scheduling type used by the operation.  
             - enum:
             -     ASAP: Immediate ordering.
             -     PREORDER: Scheduled ordering.
     - name: fulfillmentInfo | type: array<FulfillmentInfo> | description: Details for each available fulfillment option in the time slot.  | validation: maxItems 500
        - ONE-OF: 
           - name: maxTime | type: integer | description: Maximum time to fulfill the order.  
           - name: durationRange | type: DurationRange | description: Time range in which to fulfill the order.  
              - name: minDuration | type: integer | description: Minimum duration in minutes.  
              - name: maxDuration | type: integer | description: Maximum duration in minutes.  
        - name: fee | type: string | description: Fee for using this fulfillment option.  | validation: decimalValue {"gte":"0.00","maxScale":3}
        - name: minOrderPrice | type: string | description: Minimum order price to qualify for using this fulfillment option.  | validation: decimalValue {"gte":"0.00","maxScale":3}
        - name: freeFulfillmentPriceThreshold | type: string | description: Minimum order price to qualify for free fulfillment. If the order price exceeds this amount, the `fee` is waived.  | validation: decimalValue {"gte":"0.00","maxScale":3}
        - name: address | type: Address | description: Details on the address of the fulfillment. For pickup, this is the address to pick the order up from. For delivery, this is the address to deliver the order to.  
           - name: city | type: string | description: none  
           - name: subdivision | type: string | description: none  
           - name: country | type: string | description: none  
           - name: postalCode | type: string | description: none  
           - name: addressLine1 | type: string | description: none  
           - name: addressLine2 | type: string | description: none  
     - name: fulfilmentType | type: FulfillmentType | description: Fulfillment type.  
         - enum:
         -     PICKUP: Pickup fulfillment. The customer picks up the order from the restaurant.
         -     DELIVERY: Delivery fulfillment. The restaurant, or a representative, delivers the order to the customer.
  - name: cursorPagingMetadata | type: CursorPagingMetadata | description: Metadata for the paginated results.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### calculateFirstAvailableTimeSlotsForItem
```javascript
import { operations } from '@wix/restaurants';

async function calculateFirstAvailableTimeSlotsForItem(operationId,menuId,options) {
  const response = await operations.calculateFirstAvailableTimeSlotsForItem(operationId,menuId,options);
};
```

### calculateFirstAvailableTimeSlotsForItem (with elevated permissions)
```javascript
import { operations } from '@wix/restaurants';
import { auth } from '@wix/essentials';

async function myCalculateFirstAvailableTimeSlotsForItemMethod(operationId,menuId,options) {
  const elevatedCalculateFirstAvailableTimeSlotsForItem = auth.elevate(operations.calculateFirstAvailableTimeSlotsForItem);
  const response = await elevatedCalculateFirstAvailableTimeSlotsForItem(operationId,menuId,options);
}
```

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

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


async function calculateFirstAvailableTimeSlotsForItem(operationId,menuId,options) {
  const response = await myWixClient.operations.calculateFirstAvailableTimeSlotsForItem(operationId,menuId,options);
};
```

---