Create a dispatch last mile delivery order
POST /v2/fulfillment/lastmile/orders
Sends a request to create a dispatch last mile delivery order with the desired delivery window.
When you send a request to create an order, Instacart validates the order. If the request passes validations, Instacart creates the order. If the request fails validations, Instacart returns errors. For example, the request fails if the customer provides an invalid address. Your site can prompt your customers to correct the information and then try to create the order again. If Instacart cannot fulfill the order, Instacart cancels the order and sends the canceled callback. For more information, see How to handle errors.
To define a desired delivery window, use the start_at
and end_at
fields. The window must be a minimum of one hour long and must start and end on the hour.
For carts with alcohol, it is the retailer's responsibility to ensure that alcohol type, alcohol quantity, and the age of the customer are in compliance with regional laws. For alcohol delivery, retailers must also ensure that the city and county of the store and customer match. For more information, see Alcohol compliance.
You can see which delivery window was used for the order in the fulfillment_details
section of the response.
Instead of failing order creation when there isn't capacity to fulfill the order, Instacart can substitute your desired window with the soonest alternative on the same day. To enable, set the fallback_to_soonest_sameday
flag to true
.
Security
Name | In | Description |
---|---|---|
Authorization | header | The Authorization header with the bearer token acquired during authentication. |
Parameters
None.Request
Field | Type | Required | Description |
---|---|---|---|
order_id | string | The unique retailer-generated order ID to use for the order. The ID can be used later for lookup. | |
location_code | string | Location code of the store where the delivery driver picks up the order. | |
start_at | string | The requested delivery window start time in ISO 8601 format. | |
end_at | string | The requested delivery window end time in ISO 8601 format. | |
locale | string | The order's locale in IETF Language Tag format. Example: en-US. | |
first_name | string | The user's first name. | |
last_name | string | The user's last name. | |
user_phone | string | The user's phone number. | |
user_id | string | Unique user ID to use for this user. If not specified, a new user will be created. | |
initial_tip_cents | integer | The pre-delivery tip in cents. | |
items_count | integer | The number of items in the order. | |
bags_count | integer | The number of bags in the order. | |
items_weight | number | The weight of the items in lbs. | |
cart_total_cents | integer | The total value of all items for the order in cents. | |
bag_label | string | A user-friendly label that helps shoppers identify the order. | |
alcoholic | boolean | Indicates whether the order contains alcohol. Defaults to false. | |
leave_unattended | boolean | Indicates whether the user wants the driver to leave the order unattended. Defaults to false. | |
special_instructions | string | Special instructions about the order to pass on to the shopper. | |
customer_sms_opt_out | boolean | Indicator whether the user has opted-out from receiving SMS communication. Defaults to false. | |
applied_instacartplus | boolean | Indicates whether the retailer applied Instacart+ membership benefits to the order. Defaults to false. | |
fallback_to_soonest_sameday | boolean | Indicates whether the order should be fulfilled by the soonest sameday service option if the requested delivery window is not available. Defaults to true. | |
address | Address | The address of the user. |
Address Object
Field | Type | Required | Description |
---|---|---|---|
address_line_1 | string | The first address line. | |
address_line_2 | string | The second address line. | |
address_type | string | The type of address, e.g., "residential". | |
postal_code | string | The postal/zip code of the address. |
Request examples
- cURL
- Java
- Python
- Go
curl --request POST \
--url https://connect.instacart.com/v2/fulfillment/lastmile/orders \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"order_id": "string",
"location_code": "string",
"start_at": "string",
"end_at": "string",
"locale": "string",
"first_name": "string",
"last_name": "string",
"user_phone": "string",
"user_id": "string",
"initial_tip_cents": 1,
"items_count": 1,
"bags_count": 1,
"items_weight": 1,
"cart_total_cents": 1,
"bag_label": "string",
"alcoholic": true,
"leave_unattended": true,
"special_instructions": "string",
"customer_sms_opt_out": true,
"applied_instacartplus": true,
"fallback_to_soonest_sameday": true,
"address": {
"address_line_1": "string",
"address_line_2": "string",
"address_type": "string",
"postal_code": "string"
}
}'
HttpResponse<String> response = Unirest.post("https://connect.instacart.com/v2/fulfillment/lastmile/orders")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer <token>")
.body("{\n \"order_id\": \"string\",\n \"location_code\": \"string\",\n \"start_at\": \"string\",\n \"end_at\": \"string\",\n \"locale\": \"string\",\n \"first_name\": \"string\",\n \"last_name\": \"string\",\n \"user_phone\": \"string\",\n \"user_id\": \"string\",\n \"initial_tip_cents\": 1,\n \"items_count\": 1,\n \"bags_count\": 1,\n \"items_weight\": 1,\n \"cart_total_cents\": 1,\n \"bag_label\": \"string\",\n \"alcoholic\": true,\n \"leave_unattended\": true,\n \"special_instructions\": \"string\",\n \"customer_sms_opt_out\": true,\n \"applied_instacartplus\": true,\n \"fallback_to_soonest_sameday\": true,\n \"address\": {\n \"address_line_1\": \"string\",\n \"address_line_2\": \"string\",\n \"address_type\": \"string\",\n \"postal_code\": \"string\"\n }\n}")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
payload = "{\n \"order_id\": \"string\",\n \"location_code\": \"string\",\n \"start_at\": \"string\",\n \"end_at\": \"string\",\n \"locale\": \"string\",\n \"first_name\": \"string\",\n \"last_name\": \"string\",\n \"user_phone\": \"string\",\n \"user_id\": \"string\",\n \"initial_tip_cents\": 1,\n \"items_count\": 1,\n \"bags_count\": 1,\n \"items_weight\": 1,\n \"cart_total_cents\": 1,\n \"bag_label\": \"string\",\n \"alcoholic\": true,\n \"leave_unattended\": true,\n \"special_instructions\": \"string\",\n \"customer_sms_opt_out\": true,\n \"applied_instacartplus\": true,\n \"fallback_to_soonest_sameday\": true,\n \"address\": {\n \"address_line_1\": \"string\",\n \"address_line_2\": \"string\",\n \"address_type\": \"string\",\n \"postal_code\": \"string\"\n }\n}"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer <token>"
}
conn.request("POST", "/v2/fulfillment/lastmile/orders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://connect.instacart.com/v2/fulfillment/lastmile/orders"
payload := strings.NewReader("{\n \"order_id\": \"string\",\n \"location_code\": \"string\",\n \"start_at\": \"string\",\n \"end_at\": \"string\",\n \"locale\": \"string\",\n \"first_name\": \"string\",\n \"last_name\": \"string\",\n \"user_phone\": \"string\",\n \"user_id\": \"string\",\n \"initial_tip_cents\": 1,\n \"items_count\": 1,\n \"bags_count\": 1,\n \"items_weight\": 1,\n \"cart_total_cents\": 1,\n \"bag_label\": \"string\",\n \"alcoholic\": true,\n \"leave_unattended\": true,\n \"special_instructions\": \"string\",\n \"customer_sms_opt_out\": true,\n \"applied_instacartplus\": true,\n \"fallback_to_soonest_sameday\": true,\n \"address\": {\n \"address_line_1\": \"string\",\n \"address_line_2\": \"string\",\n \"address_type\": \"string\",\n \"postal_code\": \"string\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response
Field | Type | Required | Description |
---|---|---|---|
id | string | The ID of the order. | |
status | string | The current order status. | |
order_url | string | Link to view the order. | |
created_at | string | The time of order creation in ISO 8601 format. | |
cancellation_reason | string | The reason the order was canceled. | |
locale | string | The order's locale in POSIX format. Example: en_US. | |
is_express | boolean | Deprecated. Use `is_instacartplus` instead. Indicates whether the order received Instacart+ membership benefits. Defaults to false. | |
is_instacartplus | boolean | Indicates whether the order received Instacart+ membership benefits. Defaults to false. | |
fulfillment_details | OrderFulfillmentDetails | The order delivery details. |
OrderFulfillmentDetails Object
Field | Type | Required | Description |
---|---|---|---|
store_location | string | The location code of the store where the order was fulfilled. The store_location is often the same as the location_code that was used to create the order. However, orders can be fulfilled from a different store location. | |
window_starts_at | string | The start time of the delivery window in ISO 8601 format. | |
window_ends_at | string | The end time of the delivery window in ISO 8601 format. | |
delivered_at | string | The time the order was delivered in ISO 8601 format. | |
bag_count | integer | The number of bags in the order. | |
handoff_window_starts_at | string | The start time of the handoff window in ISO 8601 format. | |
handoff_window_ends_at | string | The end time of the handoff window in ISO 8601 format. |
Response examples
200 Success
200
Order created200
Order created with a fallback service option200
Order created with handoff window
{
"id": "12345676789012345678780",
"status": "created",
"order_url": "https://example.com/example-order",
"created_at": "2018-02-22T00:00:00Z",
"cancellation_reason": "shopper_driven",
"locale": "en_US",
"is_express": true,
"is_instacartplus": true,
"fulfillment_details": {
"window_starts_at": "2018-02-22T00:00:00Z",
"window_ends_at": "2018-02-22T00:30:00Z"
},
"is_fallback_window": false
}
{
"id": "12345676789012345678780",
"status": "created",
"order_url": "https://example.com/example-order",
"created_at": "2018-02-22T00:00:00Z",
"cancellation_reason": "shopper_driven",
"locale": "en_US",
"is_express": true,
"is_instacartplus": true,
"fulfillment_details": {
"window_starts_at": "2018-02-22T00:00:00Z",
"window_ends_at": "2018-02-22T00:30:00Z"
},
"is_fallback_window": true
}
{
"id": "12345676789012345678780",
"status": "created",
"order_url": "https://example.com/example-order",
"created_at": "2018-02-22T00:00:00Z",
"cancellation_reason": "shopper_driven",
"locale": "en_US",
"is_express": true,
"is_instacartplus": true,
"fulfillment_details": {
"window_starts_at": "2018-02-22T00:00:00Z",
"window_ends_at": "2018-02-22T00:30:00Z",
"handoff_window_starts_at": "2018-02-22T09:00:00Z",
"handoff_window_ends_at": "2018-02-22T10:00:00Z"
},
"is_fallback_window": false
}
4XX Errors
Error responses return either a single error or multiple errors.
HTTP Code | Cause | Error Message | Error Code | Error Meta |
---|---|---|---|---|
400 | Invalid postal code | "not found" | 1001 | {"key":"postal_code"} |
400 | Unsupported postal code | "not supported" | 1001 | {"key":"postal_code"} |
400 | User without phone number | "can't be blank" | 1001 | {"key":"user.phone_number"} |
400 | Invalid order params* | "There were issues with your request" | 9999 | Not applicable |
400 | Fails alcohol compliance check | "Alcoholic items can not be added to this order. Please remove and retry." | 2001 | Not applicable |
400 | Time window is not available | "Specified delivery time is not available - please select another time." | 1001 | Not applicable |
400 | Time window is invalid | "Invalid start / end at." | 1001 | Not applicable |
400 | Address not serviceable | "We do not currently support delivery from this store to the selected address." | 1001 | {"key":"address"} |