Skip to main content

Find replacement items (frontend)

POST /v2/recommendations/replacement_items

Returns the recommended replacement items for a list of items. For each item in the request body, returns an array of suggested replacement items that are available in the selected store. By default, an item can have up to five replacement items.

info

Use this endpoint with a user access token for frontend implementations. For backend implementations, see Find replacement items for an order (backend).

Security

NameInDescription
AuthorizationheaderThe Authorization header with the bearer token acquired during authentication.

Parameters

None.

Request

FieldTypeRequiredDescription
location_codestringRequiredThe location code of the store to use for inventory. Replacement items are selected from this store.
cart_idstringOptionalThe ID of the cart.
max_replacement_itemsintegerOptionalThe maximum number of suggested replacement items to be returned for each item. Defaults to 5.
itemsArray(Line)RequiredAn array of items. Replacement items are retrieved for each of these items.

Line Object

FieldTypeRequiredDescription
line_numstringOptionalThe line number.
itemItemRequiredThe item.

Item Object

One of the following:

FieldTypeRequiredDescription
rrcstringRequiredThe item's retailer reference code (rrc).

or

FieldTypeRequiredDescription
upcstringRequiredThe item's universal product code (upc).

Request examples

curl --request POST \
--url https://connect.instacart.com/v2/recommendations/replacement_items \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"location_code": "string",
"cart_id": "string",
"max_replacement_items": 1,
"items": [
{
"line_num": "string",
"item": {
"rrc": "string"
}
}
]
}'

Response

FieldTypeRequiredDescription
itemsArray(Line)OptionalThe items and their suggested replacement items.

Line Object

FieldTypeRequiredDescription
line_numstringOptionalThe line number.
itemItemRequiredThe item.
replacement_itemsArray(Item)OptionalThe suggested replacement items.

Item Object

FieldTypeRequiredDescription
rrcstringOptionalThe item's retailer reference code (rrc).
upcstringOptionalThe item's universal product code (upc).
stock_levelstringRequiredThe stock level of the item. One of IN_STOCK, LOW_STOCK, or OUT_OF_STOCK.

Response examples

200 Success

{
"items": [
{
"line_num": "1",
"item": {
"upc": "00000000000000",
"stock_level": "in_stock"
},
"replacement_items": [
{
"upc": "11111111111111",
"stock_level": "in_stock"
}
]
}
]
}

4XX Errors

Error responses return either a single error or multiple errors.

HTTP CodeCauseError MessageError CodeError Meta
400Store not found"Could not find specified store."1001{"key":"location_code"}