Reserve timeslots for desired window
List timeslots for Delivery
GET api.foodin.ai/users/{user_id}/service_options/{service_option_id}/reserve
Reserves the selected time slot for a desired window (service_option_reference) for the specified user ID. Time slots are reserved for 10 minutes. If the reservation expires before you can create the order, you can attempt to reserve the same time slot. If the time slot still has capacity, the request is successful. For more information about desired windows, see Desired windows.
A user ID can have one reserved time slot at a time. If you send another reservation request for this user, even if it specifies the same time slot, the currently reserved time slot is canceled before the new reservation request is processed.
Best practice: To reduce the chance that the reservation expires before you can create an order, send the reservation request near the end of the checkout process.
Request
Parameters
Field | Type | Description |
---|---|---|
user_id | string | The ID of the user. |
var request = require("request");
var options = {
method: "POST",
url: "https://api.foodin.ai/users/{user_id}/service_options/{service_option_id}/reserve",
headers: {
Accept: "application/json",
Authorization: "Bearer <token>",
"Content-Type": "application/json",
},
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Response
Field | Type | Description |
---|---|---|
service_option_hold | Object | The created service option hold. |
Service_option_hold Object
Field | Type | Description |
---|---|---|
id | integer | The ID of the service option hold. |
expires_at | string | The expiration time of the service option hold in ISO 8601 format. |
service_option | Object | The held service option. |
service_option Object
Field | Type | Description |
---|---|---|
id | integer | The ID of the service option. |
service_option_reference | string | The reference of the service option. |
date | string | The date the service will take place in ISO 8601 format. |
handoff_time | string | The ETA for deliverer to arrive at store. |
window | Object | The time window when the service will take place. |
availability | Object | The availability of this service option. |
Availability Object
Field | Type | Description |
---|---|---|
available | boolean | Indicates if this service option is available for the user. |
reasons | Array(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_codes | Array(string) | The item codes which caused the option to be unavailable. |
Window Object
Field | Type | Description |
---|---|---|
start_at | string | The start of the delivery window in ISO 8601 format. |
end_at | string | The end of the delivery window in ISO 8601 format. |
type | string | The type of service option. One of 'scheduled', 'eta' or 'asap’. |
asap | boolean | Indicates if delivery will happen as soon as possible. Only true when type is asap. |
Reasons for unavailability of a service option
Reason | Description |
---|---|
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 county | The city and county of the store and customer must match. |
Cannot deliver alcohol to this postal code | Partner can’t deliver alcohol to this postal code. |
State law doesn't allow delivery of alcohol in this window | Partners can’t deliver alcohol in this delivery window because of state law. |
Response
200 Service option hold returned
{
"service_option_hold": {
"id": 4,
"expires_at": "2022-02-22T00:10:00Z",
"service_option": {
"id": 103,
"service_option_reference": "PEluc3RhY2FydDo6QXZhaWxhYmlsaXR5OjpWMTo6T3B0aW9uOiBpZDogMTQs\nIGJ1c3lfc3VyY2hhcmdlOiAwLjAsIHRpbWVfd2luZG93OiA8SW5zdGFjYXJ0\nOjpBdmFpbGFiaWxpdHk6OlYxOjpUaW1lc3RhbXBXaW5kb3c6IHN0YXJ0c19h\ndDogPEdvb2dsZTo6UHJvdG9idWY6OlRpbWVzdGFtcDogc2Vjb25kczogMTUx\nOTI2NDgwMCwgbmFub3M6IDA+LCBlbmRzX2F0OiA8R29vZ2xlOjpQcm90b2J1\nZjo6VGltZXN0YW1wOiBzZWNvbmRzOiAxNTE5MjcyMDAwLCBuYW5vczogMD4+\nLCB6b25lX2lkOiAxNCwgd2FyZWhvdXNlX2lkOiAxNCwgdHlwZTogOlNDSEVE\nVUxFRF9ERUxJVkVSWV9PUFRJT04sIGlzX3ByaW9yaXR5X3N1cmdlOiBmYWxz\nZSwgc2VydmljZV9vcHRpb25fcmVmOiAiIj4=\n",
"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": []
}
}
}
}
4XX Errors
Code | Cause | Error Message |
---|---|---|
400 | Retry later | "Please try again in a little while" |
400 | User Not Found | "User Not Found |
400 | Blank service option id | "can't be blank" |
403 | Inactive user | "User Not Active" |
404 | Resource not found | "Resource not found" |