Skip to main content

Get sponsored products

POST /v2/ian/sp

Retrieves sponsored products ad content that you can display in a component on your site, such as an item card or carousel. Specify the context in the request body.

Sponsored products are supported in the following contexts:

NameDescriptionPage QueryAvailable Placement Types
SearchAds are shown in the grid of search results.SearchQueryInGrid
Buy It Again (department page)Ads are shown in the grid on a dedicated Buy It Again page.UserPreviouslyPurchasedQueryInGrid
Buy It Again (carousel)Ads are shown in a Buy It Again carousel.StorefrontQueryInCarousel
BrowseAds are shown in the grid when a customer browses by category.ProductCategoryQueryInGrid
Candidate CarouselAds are shown in a carousel based on provided UPC list.CandidateCarouselQueryMixedAdsCarousel

Security

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

Parameters

NameInTypeRequiredDescription
X-Retailer-IdheaderstringOptional

The retailer slug. This is only required for a retailer with multiple banners. Retailers with single banners can leave this empty.

Request

FieldTypeRequiredDescription
page_contextSponsoredProductsPageContextRequired

Specific page context for the requested ads.

placement_contextSponsoredProductsPlacementContextRequired

Specific placement context for the requested ads.

session_contextSessionContextRequired

Context related to the user session.

store_contextStoreContextRequired

Context related to the selected store.

SponsoredProductsPageContext Object

FieldTypeRequiredDescription
page_querySponsoredProductsQueryRequired

Define one SponsoredProductsQuery object per request. This object sets the query for the page to show ads.

filter_queryFilterQueryOptional

A query used to filter the returned ads to only those that match the filter. The filter query is independent of the page type. Note: To use the FilterQuery object, your catalog inventory file must contain the product tags, category IDs, or brand IDs that you want to use as filters. For more information, see the Filters concept in this documentation.

ad_load_queryAdLoadQueryOptional

The query used to specify the number of ads to return.

SponsoredProductsQuery Object

FieldTypeRequiredDescription
search_querySearchQueryOptional

Specify only one of the options described in this table. This option retrieves the search page. Supported corresponding placement kind: ['in_grid'].

user_previously_purchased_queryUserPreviouslyPurchasedQueryOptional

Specify only one of the options described in this table. This option retrieves the user previously purchased page. Supported corresponding placement kind: ['in_grid'].

storefront_queryStorefrontQueryOptional

Specify only one of the options described in this table. This option retrieves the storefront page. Supported corresponding placement kind: ['mixed_ads_carousel'].

product_category_queryProductCategoryQueryOptional

Specify only one of the options described in this table. This option retrieves the product category page. Supported corresponding placement kind: ['in_grid'].

candidate_carousel_queryCandidateCarouselQueryOptional

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:

  • Provided UPC list contains all ad-eligible items: All appear in the response, ranked by SP auction
  • Provided UPC list contains no eligible items: Response is (empty payload)
  • Provided UPC list is mixed eligibility: Only eligible items returned; others ignored
  • UPC list contains duplicates: Duplicates are deduplicated before auction
  • Location code does not match an active Thrive facility: Response is (empty payload)

SearchQuery Object

FieldTypeRequiredDescription
page_view_idstringOptional

Unique identifier of a search page view. Must be a UUID (Universal Unique Identifier). Required for retailers. Optional for third-party partners.

search_termstringRequired

Search query term.

enable_auto_correctbooleanOptional

Apply auto correction for the input search term. This option increases the latency of the endpoint. Defaults to true.

UserPreviouslyPurchasedQuery Object

FieldTypeRequiredDescription
page_view_idstringOptional

Unique identifier of a user previously purchased page view. Must be a UUID (Universal Unique Identifier). Required for retailers. Optional for third-party partners.

StorefrontQuery Object

FieldTypeRequiredDescription
page_view_idstringOptional

Unique identifier of a retailer location storefront page view. Must be a UUID (Universal Unique Identifier). Required for retailers. Optional for third-party partners.

ProductCategoryQuery Object

FieldTypeRequiredDescription
category_idsArray(integer)Required

Product category identifiers for the request.

page_view_idstringOptional

Unique identifier of a retailer product category page view. Must be a UUID (Universal Unique Identifier).

CandidateCarouselQuery Object

FieldTypeRequiredDescription
page_view_idstringOptional

Page view id for ad event tracking. Must be a UUID (Universal Unique Identifier). Required for retailers. Optional for third-party partners.

upc_listArray(string)Required

List of UPCs to display in the carousel.

FilterQuery Object

FieldTypeRequiredDescription
filter_tagsFilterTagsOptional

Filter tags that are used to filter the ads result. If a tag is included here, then sponsored products are included in the response only if the product has the corresponding tags. This filter is only applicable to shoppable display and shoppable video requests.

product_category_filter_queryProductCategoryFilterQueryOptional

An array of product category IDs to use to filter the available ads. Ads are returned if an advertised product matches any of the category IDs. Only applies to Search and Buy It Again. Note: To specify product category filtering for the Product Category placement, use the PageQuery object rather than the FilterQuery object.

brand_idsArray(integer)Optional

An array of brand IDs to use to filter the available ads. Ads are returned if they match any of the brand IDs. This filter is only applicable to shoppable display and shoppable video requests.

FilterTags Object

FieldTypeRequiredDescription
tagsArray(string)Required

An array of tags or filter names as strings.

ProductCategoryFilterQuery Object

FieldTypeRequiredDescription
category_idsArray(integer)Required

Product category IDs for the request.

AdLoadQuery Object

FieldTypeRequiredDescription
ads_countstringOptional

The maximum number of ads to return. The actual number of returned ads depends on the ad inventory available.

SponsoredProductsPlacementContext Object

FieldTypeRequiredDescription
placement_kindSponsoredProductsKindRequired

Define one SponsoredProductsKind object per request. This object sets the kind of placement for showing ads.

SponsoredProductsKind Object

FieldTypeRequiredDescription
in_gridInGridOptional

Specify only one of the options described in this table. This option serves ads to show in the main grid of the page. Supported corresponding page query: ['search_query', 'user_previously_purchased_query', 'product_category_query'].

mixed_ads_carouselMixedAdsCarouselOptional

Specify only one of the options described in this table. This option serves ads to show in the carousel mixed with organic product. Supported corresponding page query: ['storefront_query'].

InGrid Object

FieldTypeRequiredDescription
supported_formatArray(string)Required

The ads format. Supported value: ['item_card'].

MixedAdsCarousel Object

FieldTypeRequiredDescription
supported_formatArray(string)Required

The ads format. Supported value: 'item_card'.

carousel_queryInCarouselQueryRequired

Define one InCarouselQuery object per request. This object sets the organic query for the carousel that ads should be relevant to.

InCarouselQuery Object

FieldTypeRequiredDescription
user_previously_purchased_queryUserPreviouslyPurchasedQueryOptional

Specify only one of the options described in this table. This option retrieves the user previously purchased page.

SessionContext Object

FieldTypeRequiredDescription
user_idstringOptional

Unique user ID of the user performing the query. Maximum 50 characters.

user_ipstringOptional

The IP address of the end user. Maximum 50 characters.

user_agentstringOptional

The user agent of the device making the request. Maximum 50 characters.

test_onlybooleanOptional

When true, the campaigns created for Carrot Ads testing are guaranteed to participate in the ads auction along with other campaigns. Default is false.

StoreContext Object

FieldTypeRequiredDescription
location_codestringRequired

The store location code used to perform the query. Maximum 100 characters.

Request examples

curl --request POST \
--url https://connect-ian.instacart.com/v2/ian/sp \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Retailer-Id: string' \
--data '{
"page_context": {
"page_query": {
"search_query": {
"page_view_id": "string",
"search_term": "string",
"enable_auto_correct": true
}
},
"filter_query": {
"filter_tags": {
"tags": [
"string"
]
}
},
"ad_load_query": {
"ads_count": "string"
}
},
"placement_context": {
"placement_kind": {
"in_grid": {
"supported_format": [
"string"
]
}
}
},
"session_context": {
"user_id": "string",
"user_ip": "string",
"user_agent": "string",
"test_only": true
},
"store_context": {
"location_code": "string"
}
}'

Response

FieldTypeRequiredDescription
productsArray(SponsoredProduct)Optional

List of sponsored products. When no ads are returned, the response is an empty array.

SponsoredProduct Object

FieldTypeRequiredDescription
object_tracking_idstringRequired

The unique tracking identifier for this ad.

rrcstringOptional

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.

upcstringOptional

Non-normalized universal product code (UPC). Either RRC or UPC is returned depending on the retailer's configuration.

product_idintegerRequired

Instacart product ID.

display_positionintegerRequired

Suggested display position when mixed with the organic products. The first position is 1.

ad_formatstringOptional

The ad format for this ad placement. Supported value: ['item_card'].

Response examples

200 Success

{
"products": [
{
"object_tracking_id": "urn:i-ic-v1:spid:78219bd2-981d-49fb-a485-aaee5ddd8dfa",
"rrc": "fake_rrc",
"product_id": 1,
"display_position": 1,
"ad_format": "item_card"
},
{
"object_tracking_id": "urn:i-ic-v1:spid:12319bd2-981d-49fb-a485-aaee5ddd8123",
"rrc": "fake_rrc_2",
"product_id": 2,
"display_position": 2,
"ad_format": "item_card"
}
]
}

4XX Errors

Error responses return either a single error or multiple errors.

HTTP CodeCauseError MessageError CodeError Meta
400invalid search page query with mixed ads carousel placement kind"No internal placements match the given page query type and placement kind"1001Not applicable
400invalid storefront page query with in grid placement kind"No internal placements match the given page query type and placement kind"1001Not applicable
400empty page query"the number of attributes given for page_query is 0"1001{"key":"page_context.page_query"}
400Request 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"}
400empty placement kind"the number of attributes given for placement_kind is 0"1001{"key":"placement_context.placement_kind"}
400more than one attribute used in placement kind"the number of attributes given for placement_kind is 2"1001{"key":"placement_context.placement_kind"}
400too long user_id in the session context"User ID length must be less than 51 characters"1001{"key":"session_context.user_id"}
400too long location code in the store context"Location code length must be less than 101 characters"1001{"key":"store_context.location_code"}
401store that doesn't match the oauth token used"the given location code doesn't match the oauth token used."nullNot applicable