Product API
Fulfillment guide
Service Options
Delivery Options

Delivery options

List timeslots for Delivery

GET api.foodin.ai/users/{user_id}/service_options/cart/delivery

Lists the available delivery service options for the customer's location and cart items. In this context, service options are time slots, such as Within 5 hours or Friday 9am-11am. Availability is based on current and anticipated deliverer availability for the relevant store and delivery location.

By default, the time slots returned are immediate and scheduled time slots. If ETA options are enabled in your store configuration, you can retrieve ETA time slots instead of immediate time slots. To get a standard ETA time slot with the scheduled time slots, set the with_eta_options field to true. To also retrieve a priority ETA time slot, set the with_priority_eta_options field to true. For more information, see Retrieve an ETA time slot.

If the customer address is more than 30 minutes away from the selected store, the long_distance_delivery flag is set to true. You can deliver to this address if long distance delivery is enabled for the store. For more information, see Service areas for delivery.

If you’d like more flexibility with your time slots, you can send Foodin your desired windows. Foodin uses your desired windows to map to available service options and returns the available time slots for the desired windows.

Parameters

FieldTypeDescription
user_idstringThe ID of the user.

Request

FieldTypeDescription
addressObjectThe address for the delivery
ItemsArray(Items)The items for delivery.
desired_windowsArray(Desired_windows)The desired windows for service options.
location_codestringThe location code of the store fulfilling the order.
with_eta_optionsbooleanReturns ETA options instead of immediate when true. Defaults to false.
with_priority_eta_optionsbooleanReturns Priority ETA options instead of immediate when true. Defaults to false.

Address Object

FieldTypeDescription
address_line_1stringThe first address line.
address_line_2stringThe second address line.
address_typestringThe type of address, e.g., "residential".
postal_codestringThe postal/zip code of the address.

Items Object

FieldTypeDescription
line_numStringThe item's line number in the order.
countIntegerThe count of the item. Must be a non-negative integer.
weightnumberThe weight of the item (defaults to kg in the US). Must be a non-negative number.
special_instructionsstringAny special instructions about the item selection.
replacement_policystringOne of "no_replacements", "users_choice" (default if replacement_items specified), or "deliverers_choice" (default otherwise).
replacement_itemsArrayA list of requested replacement items if the original item could not be found. This field needs to be turned on via configuration.
itemObjectThe item's code.

Replacement_items Object

FieldTypeDescription
upcstringThe item's universal product code (upc).

Item Object

FieldTypeDescription
upcstringThe item's universal product code (upc).

Desired_windows Object

FieldTypeDescription
starts_atstringStart time of the desired window in ISO 8601 format.
ends_atstringEnd time of the desired window in ISO 8601 format.

Request examples

const axios = require("axios");
 
async function sendDeliveryRequest(token) {
  const deliveryData = {
    address: {
      address_line_1: "string",
      address_line_2: "string",
      address_type: "string",
      postal_code: "string",
    },
    items: [
      {
        line_num: "string",
        count: 1,
        weight: 1,
        special_instructions: "string",
        replacement_policy: "no_replacements",
        replacement_items: [
          {
            upc: "string",
          },
        ],
        item: {
          upc: "string",
        },
      },
    ],
    desired_windows: [
      {
        starts_at: "string",
        ends_at: "string",
      },
    ],
    location_code: "string",
    with_eta_options: true,
    with_priority_eta_options: true,
  };
 
  const config = {
    headers: {
      Accept: "application/json",
      Authorization: `Bearer ${token}`,
      "Content-Type": "application/json",
    },
  };
 
  try {
    const response = await axios.post(
      "https://api.foodin.ai/ users/{user_id}/service_options/cart/delivery",
      deliveryData,
      config
    );
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
}

Response

FieldTypeDescription
service_optionsArrayThe item's line number in the order.
warningsIntegerThe count of the item. Must be a non-negative integer.
flagsObjectAdditional properties of the address.

Service_options Object

FieldTypeDescription
idintegerThe ID of the service option.
service_option_referenceStringThe reference of the service option.
dateStringThe date the service will take place in ISO 8601 format.
handoff_timeStringThe ETA for deliverer to arrive at store.
WindowObjectThe time window when the service will take place.
AvailabilityObjectThe availability of this service option.

Availability Object

FieldTypeDescription
availablebooleanIndicates if this service option is available for the user.
reasonsArray(string)The reasons for unavailability of a service option. Currently, the reasons are related to the laws governing the sale of alcohol. For example, restrictions on quantity, delivery time, pickup, and matched city and county of stores and customers. The reasons are subject to change without notice.
item_codesArray(string)The item codes which caused the option to be unavailable.

Window Object

FieldTypeDescription
start_atstringThe start of the delivery window in ISO 8601 format.
end_atstringThe end of the delivery window in ISO 8601 format.
typestringThe type of service option. One of 'scheduled', 'eta' or 'asap’.
asapbooleanIndicates if delivery will happen as soon as possible. Only true when type is asap.

Warnings Object

FieldTypeDescription
errorObjectInformation relevant to the error.
end_atstringThe end of the delivery window in ISO 8601 format.
typestringThe type of service option. One of 'scheduled', 'eta' or 'asap’.
asapbooleanIndicates if delivery will happen as soon as possible. Only true when type is asap.

Reasons for unavailability of a service option

ReasonDescription
State law restricts amount of {beer/wine/spirits} to {#} fl oz, cart quantity is: {#} fl oz.The quantity of this alcohol type exceeds the country/state law limit..
Error validating alcohol quantities. Please try again.The quantity of alcohol can’t be validated.
Unmatched city and countyThe city and county of the store and customer must match.
Cannot deliver alcohol to this postal codePartner can’t deliver alcohol to this postal code.
State law doesn't allow delivery of alcohol in this windowPartners can’t deliver alcohol in this delivery window because of state law.

Success 200 With unavailability reasons

{
  "service_options": [
    {
      "id": 13,
      "service_option_reference": "ezppZD0-MTMsIDp0eXBlPT4iU2NoZWR1bGVkRGVsaXZlcnlPcHRpb24iLCA6d2luZG93PT48SW5zdGFjYXJ0OjpFbnRlcnByaXNlOjpCb2JhOjpDb3JlOjpUeXBlczo6VjE6OlNlcnZpY2VPcHRpb25TY2hlZHVsZWRXaW5kb3c6IGRlc2NyaXB0b3I6ICIiLCBzdGFydF9hdDogPEdvb2dsZTo6UHJvdG9idWY6OlRpbWVzdGFtcDogc2Vjb25kczogMTUxOTI1NzYwMCwgbmFub3M6IDA-LCBlbmRfYXQ6IDxHb29nbGU6OlByb3RvYnVmOjpUaW1lc3RhbXA6IHNlY29uZHM6IDE1MTkyNjQ4MDAsIG5hbm9zOiAwPj59",
      "date": "2022-02-22",
      "window": {
        "start_at": "2022-02-22T00:00:00Z",
        "end_at": "2022-02-22T02:00:00Z",
        "type": "scheduled",
        "asap": false
      },
      "availability": {
        "available": false,
        "reasons": [
          "State law doesn't allow delivery of alcohol in this window"
        ],
        "item_codes": ["000000004011"]
      }
    }
  ],
  "warnings": []
}

Success 200 Cart service options returned

{
  "service_options": [
    {
      "id": 198,
      "service_option_reference": "ezppZD0-MTk4LCA6dHlwZT0-IlNjaGVkdWxlZERlbGl2ZXJ5T3B0aW9uIiwgOndpbmRvdz0-PEluc3RhY2FydDo6RW50ZXJwcmlzZTo6Qm9iYTo6Q29yZTo6VHlwZXM6OlYxOjpTZXJ2aWNlT3B0aW9uU2NoZWR1bGVkV2luZG93OiBkZXNjcmlwdG9yOiAiIiwgc3RhcnRfYXQ6IDxHb29nbGU6OlByb3RvYnVmOjpUaW1lc3RhbXA6IHNlY29uZHM6IDE1MTkyNTc2MDAsIG5hbm9zOiAwPiwgZW5kX2F0OiA8R29vZ2xlOjpQcm90b2J1Zjo6VGltZXN0YW1wOiBzZWNvbmRzOiAxNTE5MjY0ODAwLCBuYW5vczogMD4-fQ==",
      "date": "2022-02-22",
      "window": {
        "start_at": "2022-02-22T00:00:00Z",
        "end_at": "2022-02-22T02:00:00Z",
        "type": "scheduled",
        "asap": false
      },
      "availability": {
        "available": true,
        "reasons": [],
        "item_codes": []
      }
    },
    {
      "id": 199,
      "service_option_reference": "ezppZD0-MTk5LCA6dHlwZT0-IkltbWVkaWF0ZURlbGl2ZXJ5T3B0aW9uIiwgOndpbmRvdz0-PEluc3RhY2FydDo6RW50ZXJwcmlzZTo6Qm9iYTo6Q29yZTo6VHlwZXM6OlYxOjpTZXJ2aWNlT3B0aW9uSW1tZWRpYXRlV2luZG93OiBkZXNjcmlwdG9yOiAiIiwgaW1tZWRpYXRlX2hvdXI6IDU-fQ==",
      "date": "2022-02-22",
      "window": {
        "immediate_hour": 5,
        "type": "immediate"
      },
      "availability": {
        "available": true,
        "reasons": [],
        "item_codes": []
      }
    },
}

4XX Errors

CodeCauseError Message
400User Not Found"User Not Found"
400Invalid location code"Could not find specified store."
400No weight or count provided*"There were issues with your request"
400No stores found"No store location found for given address."
400Invalid items"1 item not found."
400Cannot deliver to address"Unfortunately, we cannot deliver to that area."
400Store does not support delivery to address"We do not currently support delivery from this store to the selected address."
400Invalid Quantity, expected weight"One of these items had an invalid quantity amount, 0001234567892 expected weight"
400Invalid Quantity, expected count"One of these items had an invalid quantity amount, 0001234567892 expected count"
400Duplicate items were provided"Duplicate items provided for this order."
400Priority ETA options not configured"Priority ETA options are not configured for this store."
400ETA options not configured"ETA options are not configured for this store."
400Without address"can't be blank"
403User Not Active"User Not Active"
404Resource not found"Resource not found"