Get sponsored product candidates
POST /v2/ian/sp_candidate
Retrieves sponsored product candidates for partners that Instacart enables for enhanced integration. The response includes product identifiers and auction metadata. It does not include the rendered item-card payload returned by Get sponsored products. The request body and the supported page and placement pairings match that endpoint. Field tables on this page are generated from the OpenAPI specification. page_context.common_query.partner_request_id is still required. It is a UUID that you generate for the request, and you send the same value on Report sponsored product price candidates. The generated field tables omit it.
After you rank or filter the candidates, report the outcome with Report sponsored product price candidates. For the full workflow, see Enhanced integration.
Security
| Name | In | Description |
|---|---|---|
Authorization | header | The Authorization header with the bearer token acquired during authentication. |
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
X-Retailer-Id | header | string | The retailer slug identifying the banner to serve ads for. Required only for multi-banner accounts. Instacart assigns slugs during onboarding. An unknown or missing slug returns 400 with the message Bad X-Retailer-Id. A slug that does not match your account returns 401 with the message the given location code doesn't match the oauth token used. |
X-Retailer-Id is the retailer slug identifying the banner to serve ads for. Required only for multi-banner accounts. Instacart assigns slugs during onboarding. An unknown or missing slug returns 400 with the message Bad X-Retailer-Id. A slug that does not match your account returns 401 with the message the given location code doesn't match the oauth token used. For more information, see Identifiers.
Request
| Field | Type | Required | Description |
|---|---|---|---|
page_context | SponsoredProductsPageContext | The page context for the ad request, including the page type, filters, and ad load configuration. | |
placement_context | SponsoredProductsPlacementContext | The placement configuration for the ad request. The placement kind must be compatible with the selected page query type. | |
session_context | SessionContext | The user session information, including user ID, IP address, and user agent string. | |
store_context | StoreContext | The store context identifying the retail location for the ad request. | |
pagination_context | PaginationContext | The pagination parameters for fetching a specific page of ads. On the first request, omit the token to receive a fresh result set and a session token. On subsequent requests, include the token and advance the offset to retrieve additional pages. |
SponsoredProductsPageContext Object
| Field | Type | Required | Description |
|---|---|---|---|
page_query | SponsoredProductsQuery | The page type for the ad request. Exactly one page query option must be specified (for example, search_query or storefront_query). The selected option determines which ads are eligible to be served. | |
filter_query | FilterQuery | Filters to narrow the returned ads. Supports tag-based, category-based, or brand-based filtering. Filters are applied independently of the page type. Your catalog inventory file must include the corresponding tags, category IDs, or brand IDs for filtering to take effect. | |
ad_load_query | AdLoadQuery | Controls the maximum number of ads returned in the response. |
SponsoredProductsQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
search_query | SearchQuery | Retrieves sponsored product ads for a search results page. Must be paired with the 'in_grid' placement kind. Only one page query option may be specified per request. | |
user_previously_purchased_query | UserPreviouslyPurchasedQuery | Retrieves sponsored product ads for a Buy It Again or previously purchased products page. Must be paired with the 'in_grid' placement kind. Only one page query option may be specified per request. | |
storefront_query | StorefrontQuery | Retrieves sponsored product ads for the storefront page. Must be paired with the 'mixed_ads_carousel' placement kind. Only one page query option may be specified per request. | |
product_category_query | ProductCategoryQuery | Retrieves sponsored product ads for a product category or browse page. Must be paired with the 'in_grid' placement kind. Only one page query option may be specified per request. | |
candidate_carousel_query | CandidateCarouselQuery | Specify a list of desired UPCs to display in the carousel. For the Candidate Carousel Query the responses are based on the UPC list provided:
|
SearchQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
page_view_id | string | A unique identifier for the current page view. Must be a valid UUID. Pass the string 'None' if a page view identifier is not available. | |
search_term | string | The search term entered by the user. Ads are matched based on relevance to this term. | |
enable_auto_correct | boolean | When set to true, auto-correction is applied to the search term to improve matching for misspellings. Defaults to true. Enabling auto-correction increases response latency. |
UserPreviouslyPurchasedQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
page_view_id | string | A unique identifier for the current page view. Must be a valid UUID. Pass the string 'None' if a page view identifier is not available. |
StorefrontQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
page_view_id | string | A unique identifier for the current page view. Must be a valid UUID. Pass the string 'None' if a page view identifier is not available. |
ProductCategoryQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
category_ids | Array(integer) | An array of product category IDs for the category page being viewed. Sponsored products are matched based on these categories. | |
page_view_id | string | A unique identifier for the current page view. Must be a valid UUID. Pass the string 'None' if a page view identifier is not available. |
CandidateCarouselQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
page_view_id | string | A unique identifier for the current page view. Must be a valid UUID. Pass the string 'None' if a page view identifier is not available. | |
upc_list | Array(string) | An array of UPC strings identifying the products eligible for the carousel ad auction. |
FilterQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
filter_tags | FilterTags | Filters ad results by product tags. When specified, only products matching at least one tag are returned. The object must contain a 'tags' array. Example: { "filter_tags": { "tags": ["tag1", "tag2"] } }. Not applicable to display banner requests. | |
product_category_filter_query | ProductCategoryFilterQuery | Filters available ads by product category. Ads are returned only if the advertised product matches at least one of the specified category IDs. Applies to search, Buy It Again, and storefront placements. For product category placements, specify category IDs in the PageQuery object. | |
brand_ids | Array(integer) | An array of brand IDs to filter available ads. Ads are returned only if they match at least one of the specified brand IDs. |
FilterTags Object
| Field | Type | Required | Description |
|---|---|---|---|
tags | Array(string) | An array of tag strings. Only products matching at least one of the specified tags are returned. |
ProductCategoryFilterQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
category_ids | Array(integer) | An array of product category IDs. Ads are returned only if the advertised product belongs to at least one of the specified categories. |
AdLoadQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
ads_count | string | The maximum number of ads to return, specified as a string (for example, "10"). Must be an integer value between 1 and 100. The actual number of ads returned may be lower depending on available inventory. |
SponsoredProductsPlacementContext Object
| Field | Type | Required | Description |
|---|---|---|---|
placement_kind | SponsoredProductsKind | Specifies how sponsored product ads are displayed on the page. Exactly one placement option must be provided: 'in_grid' for ads within a product grid, or 'mixed_ads_carousel' for ads within a carousel. |
SponsoredProductsKind Object
| Field | Type | Required | Description |
|---|---|---|---|
in_grid | InGrid | Displays sponsored product ads inline within the main product grid. Only one placement option may be specified per request. Must be paired with one of the following page queries: search_query, user_previously_purchased_query, product_category_query, or candidate_carousel_query. | |
mixed_ads_carousel | MixedAdsCarousel | Displays sponsored product ads in a carousel alongside organic products. Only one placement option may be specified per request. Pair mixed_ads_carousel with a storefront_query or candidate_carousel_query page query. The carousel_query supports only user_previously_purchased_query. Do not pair search_query or product_category_query with mixed_ads_carousel. Those page queries must use the in_grid placement kind. Combining search_query or product_category_query with mixed_ads_carousel returns error code 1001. |
InGrid Object
| Field | Type | Required | Description |
|---|---|---|---|
supported_format | Array(string) | The ad format for the placement, specified as an array. The supported value is ["item_card"]. |
MixedAdsCarousel Object
| Field | Type | Required | Description |
|---|---|---|---|
supported_format | Array(string) | The ad format for the placement, specified as an array. The supported value is ["item_card"]. | |
carousel_query | InCarouselQuery | The organic product context for the carousel. Ads are matched to be relevant to this context. Typically uses a user_previously_purchased_query. |
InCarouselQuery Object
| Field | Type | Required | Description |
|---|---|---|---|
user_previously_purchased_query | UserPreviouslyPurchasedQuery | Provides previously purchased product context for the carousel. Only one option may be specified per request. |
SessionContext Object
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | A unique identifier for the end user. Maximum 50 characters. | |
user_ip | string | The IP address of the end user. Must be a valid IPv4 or IPv6 address. | |
user_agent | string | The User-Agent string from the end user's device. Maximum 1000 characters. | |
test_only | boolean | When set to true, only test campaigns are returned in the response. Regular campaigns are excluded. Use this to validate your integration without serving live ads. Defaults to false. |
StoreContext Object
| Field | Type | Required | Description |
|---|---|---|---|
location_code | string | The store location code for the retail location to retrieve ads for. Must match a location code associated with your account. Maximum 100 characters. |
PaginationContext Object
| Field | Type | Required | Description |
|---|---|---|---|
page_size | integer | Number of ads to return per page. Defaults to the placement's configured page size when omitted. | |
offset | integer | How far into the result set to advance, expressed in whole pages, starting at 1. An offset of 1 returns the first page, 2 returns the second, and so on. Defaults to 1 when omitted. | |
token | string | Opaque session token returned by a previous paginated response. Include this token in subsequent requests to retrieve pages from the same cached result set. Omit on the first request to begin a new pagination session. |
Combining search_query or product_category_query with mixed_ads_carousel returns error code 1001.
Request examples
This example uses one search query and an in-grid placement.
- cURL
- Java
- Python
- Go
- Node.js
curl --request POST \
--url https://connect-ian.instacart.com/v2/ian/sp_candidate \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Retailer-Id: the-garden' \
--data '{
"page_context": {
"page_query": {
"search_query": {
"page_view_id": "4291d814-8a75-4fef-9426-123c5840f7bc",
"search_term": "pasta",
"enable_auto_correct": true
}
},
"filter_query": {
"filter_tags": {
"tags": [
"organic"
]
}
},
"ad_load_query": {
"ads_count": "10"
},
"common_query": {
"partner_request_id": "68fe21d8-4802-499f-bf12-f7315ae50091"
}
},
"placement_context": {
"placement_kind": {
"in_grid": {
"supported_format": [
"item_card"
]
}
}
},
"session_context": {
"user_id": "kamalsingh1234",
"user_ip": "192.0.2.146",
"user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)",
"test_only": true
},
"store_context": {
"location_code": "111"
},
"pagination_context": {
"page_size": 10,
"offset": 1
}
}'
HttpResponse<String> response = Unirest.post("https://connect-ian.instacart.com/v2/ian/sp_candidate")
.header("Accept", "application/json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.header("X-Retailer-Id", "the-garden")
.body("{\n \"page_context\": {\n \"page_query\": {\n \"search_query\": {\n \"page_view_id\": \"4291d814-8a75-4fef-9426-123c5840f7bc\",\n \"search_term\": \"pasta\",\n \"enable_auto_correct\": true\n }\n },\n \"filter_query\": {\n \"filter_tags\": {\n \"tags\": [\n \"organic\"\n ]\n }\n },\n \"ad_load_query\": {\n \"ads_count\": \"10\"\n },\n \"common_query\": {\n \"partner_request_id\": \"68fe21d8-4802-499f-bf12-f7315ae50091\"\n }\n },\n \"placement_context\": {\n \"placement_kind\": {\n \"in_grid\": {\n \"supported_format\": [\n \"item_card\"\n ]\n }\n }\n },\n \"session_context\": {\n \"user_id\": \"kamalsingh1234\",\n \"user_ip\": \"192.0.2.146\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 6.1; Win64; x64)\",\n \"test_only\": true\n },\n \"store_context\": {\n \"location_code\": \"111\"\n },\n \"pagination_context\": {\n \"page_size\": 10,\n \"offset\": 1\n }\n}")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect-ian.instacart.com")
payload = "{\n \"page_context\": {\n \"page_query\": {\n \"search_query\": {\n \"page_view_id\": \"4291d814-8a75-4fef-9426-123c5840f7bc\",\n \"search_term\": \"pasta\",\n \"enable_auto_correct\": true\n }\n },\n \"filter_query\": {\n \"filter_tags\": {\n \"tags\": [\n \"organic\"\n ]\n }\n },\n \"ad_load_query\": {\n \"ads_count\": \"10\"\n },\n \"common_query\": {\n \"partner_request_id\": \"68fe21d8-4802-499f-bf12-f7315ae50091\"\n }\n },\n \"placement_context\": {\n \"placement_kind\": {\n \"in_grid\": {\n \"supported_format\": [\n \"item_card\"\n ]\n }\n }\n },\n \"session_context\": {\n \"user_id\": \"kamalsingh1234\",\n \"user_ip\": \"192.0.2.146\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 6.1; Win64; x64)\",\n \"test_only\": true\n },\n \"store_context\": {\n \"location_code\": \"111\"\n },\n \"pagination_context\": {\n \"page_size\": 10,\n \"offset\": 1\n }\n}"
headers = {
'Accept': "application/json",
'Authorization': "Bearer <token>",
'Content-Type': "application/json",
'X-Retailer-Id': "the-garden"
}
conn.request("POST", "/v2/ian/sp_candidate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://connect-ian.instacart.com/v2/ian/sp_candidate"
payload := strings.NewReader("{\n \"page_context\": {\n \"page_query\": {\n \"search_query\": {\n \"page_view_id\": \"4291d814-8a75-4fef-9426-123c5840f7bc\",\n \"search_term\": \"pasta\",\n \"enable_auto_correct\": true\n }\n },\n \"filter_query\": {\n \"filter_tags\": {\n \"tags\": [\n \"organic\"\n ]\n }\n },\n \"ad_load_query\": {\n \"ads_count\": \"10\"\n },\n \"common_query\": {\n \"partner_request_id\": \"68fe21d8-4802-499f-bf12-f7315ae50091\"\n }\n },\n \"placement_context\": {\n \"placement_kind\": {\n \"in_grid\": {\n \"supported_format\": [\n \"item_card\"\n ]\n }\n }\n },\n \"session_context\": {\n \"user_id\": \"kamalsingh1234\",\n \"user_ip\": \"192.0.2.146\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 6.1; Win64; x64)\",\n \"test_only\": true\n },\n \"store_context\": {\n \"location_code\": \"111\"\n },\n \"pagination_context\": {\n \"page_size\": 10,\n \"offset\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Retailer-Id", "the-garden")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
const http = require('https');
const options = {
method: 'POST',
hostname: 'connect-ian.instacart.com',
port: null,
path: '/v2/ian/sp_candidate',
headers: {
Accept: 'application/json',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json',
'X-Retailer-Id': 'the-garden'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
page_context: {
page_query: {
search_query: {
page_view_id: '4291d814-8a75-4fef-9426-123c5840f7bc',
search_term: 'pasta',
enable_auto_correct: true
}
},
filter_query: {filter_tags: {tags: ['organic']}},
ad_load_query: {ads_count: '10'},
common_query: {partner_request_id: '68fe21d8-4802-499f-bf12-f7315ae50091'}
},
placement_context: {placement_kind: {in_grid: {supported_format: ['item_card']}}},
session_context: {
user_id: 'kamalsingh1234',
user_ip: '192.0.2.146',
user_agent: 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)',
test_only: true
},
store_context: {location_code: '111'},
pagination_context: {page_size: 10, offset: 1}
}));
req.end();
The example sets test_only to true for integration testing. Set test_only to false, or omit it, before you launch to production. For more information, see Environments and testing.
Response
| Field | Type | Required | Description |
|---|---|---|---|
ic_request_id | string | Unique ID for tracking the specific API request. | |
is_exploration | boolean | Indicates if the candidates were retrieved purely based on bids. | |
products | Array(SponsoredProductCandidate) | List of sponsored product candidates. When no ads are returned, the response is an empty array. |
SponsoredProductCandidate Object
| Field | Type | Required | Description |
|---|---|---|---|
object_tracking_id | string | The unique tracking identifier for this ad. | |
rrc | string | Retailer reference code (RRC) which can be used by retailers to fetch additional metadata about the product from their own catalog. Either RRC or UPC is returned depending on the retailer's configuration. | |
relative_bid | integer | The relative Bid value associated with the product for ad auctions. | |
demand_source | string | The source of the demand for the product. |
When no ads are returned, products is an empty array.
4xx errors
These 400 responses use error code 1001.
| HTTP code | Error code | Message | What to do |
|---|---|---|---|
400 | 1001 | the given location code is not found | Send a location_code that exists for this account, then retry. |
400 | 1001 | Filter tag not found: followed by the filter tags that were not found | Correct the filter tags and retry. |
When the request is rejected as an invalid argument, the endpoint also returns 400 with error code 1001. error.message is the message returned for that error. Correct the request and retry.
Response examples
Success
200Request with search page query and in_grid placement kind
{
"ic_request_id": "ic_request_id",
"is_exploration": false,
"products": [
{
"object_tracking_id": "candidate_1",
"rrc": "rrc_1",
"relative_bid": 1,
"demand_source": "IC_SOURCED_DEMAND"
},
{
"object_tracking_id": "candidate_2",
"rrc": "rrc_2",
"relative_bid": 2,
"demand_source": "PARTNER_SOURCED_DEMAND"
}
]
}
4XX Errors
Error responses return either a single error or multiple errors.
| HTTP Code | Cause | Error Message | Error Code | Error Meta |
|---|---|---|---|---|
400 | invalid search page query with mixed ads carousel placement kind | "No internal placements match the given page query type and placement kind" | 1001 | Not applicable |
400 | empty page query | "the number of attributes given for page_query is 0" | 1001 | {"key":"page_context.page_query"} |
400 | Request with more than one attribute used in page query | "the number of attributes given for page_query is 2" | 1001 | {"key":"page_context.page_query"} |
400 | empty placement kind | "the number of attributes given for placement_kind is 0" | 1001 | {"key":"placement_context.placement_kind"} |
400 | more than one attribute used in placement kind | "the number of attributes given for placement_kind is 2" | 1001 | {"key":"placement_context.placement_kind"} |
400 | too long user_id in the session context | "User ID length must be less than 51 characters" | 1001 | {"key":"session_context.user_id"} |
400 | too long location code in the store context | "Location code length must be less than 101 characters" | 1001 | {"key":"store_context.location_code"} |
401 | store that doesn't match the oauth token used | "the given location code doesn't match the oauth token used." | null | Not applicable |