Skip to main content

User Featured Recommendations

For You recommendations

POST /api/v1/indexes/{index_name}/recommendations/for-you

Purpose

Surface a product shelf built from the products a shopper has actually interacted with. The endpoint reads the shopper's tracked clicks, cart additions and purchases and returns products similar to the ones they engaged with most recently, so the shelf reflects demonstrated interest rather than a guess.

Background

The event tracking pixel records three kinds of product interaction: ClickEvent, AddToCartEvent and PurchaseEvent. This endpoint takes the shopper's most recently interacted-with products and uses them as the seed for a similarity search across the index, so the shelf follows the shopper's recent behaviour and refreshes as they browse.

When to use

  • Homepage personalization: Show tailored content for returning visitors and logged-in users
  • Email marketing: Create personalized product recommendations in newsletters and campaigns
  • Account dashboards: Display relevant suggestions in user profiles and account pages
  • Re-engagement campaigns: Target users with products based on their historical preferences

Example uses

Use CaseDescriptionInteraction SourceBusiness Impact
Homepage "For You" SectionDisplay personalized recommendations on homepage for logged-in usersAll three interaction typesIncreases engagement, improves homepage relevance
Email RecommendationsInclude "Based on Your Purchases" or "You Might Like" in email campaignsPurchaseEventDrives return visits, increases email CTR
Account DashboardShow "Recommended for You" in user account or profile pagesAll three interaction typesExtends session time, improves loyalty
Retargeting CampaignsTarget users with ads featuring products aligned with their preferencesClickEvent and AddToCartEventImproves ad relevance, increases conversion rates
Mobile App PersonalizationCreate personalized product feeds within mobile applicationsAll three interaction typesEnhances app engagement, drives mobile sales

Input sources (interaction types)

The shelf is seeded from tracked product interactions, and only these three types are available. Use interactionTypes to narrow the seed to a subset; the default uses all three.

Interaction typeRecorded when
PurchaseEventThe shopper bought the product.
AddToCartEventThe shopper added the product to their cart, whether or not they bought it.
ClickEventThe shopper clicked through to the product.

Only the products themselves are used, most recent first. Search queries, page dwell time and other engagement signals are not part of the seed.

Example (cURL)

curl -X POST "https://ecom.marqo-ep.ai/api/v1/indexes/product-catalog/recommendations/for-you" \
-H "x-marqo-index-id: ${MARQO_INDEX_ID}" \
-H "Content-Type: application/json" \
-d '{
"userId": "abc123",
"limit": 12
}'

Prerequisites

This endpoint builds the shelf from the shopper's tracked events, so the event tracking pixel must be installed on the store and personalisation must be enabled for the index. Otherwise every request returns a 400 (see Errors).

Parameters

Filters use the Marqo Filter DSL. The endpoint uses strict validation: any unrecognised parameter returns a 400 error.

NameTypeRequiredDescriptionExample
userIdstringyesShopper identifier, as sent to the event tracking pixel. Must be a non-empty string."abc123"
interactionTypesarray[string]noTypes of interactions to consider (ClickEvent, AddToCartEvent, PurchaseEvent). Default: all types.["ClickEvent", "AddToCartEvent"]
limitintegernoMax number of results to return. Defaults to 10.12
offsetintegernoOffset for pagination. Defaults to 0.0
filterstringnoServer-side constraints (e.g., in_stock, price ranges, brand, category). See Marqo Filter DSL."in_stock:true"
attributesToRetrievearray[string]noAttributes to return for each document. If omitted, the attribute list configured for the index is returned, the same default as search.["title", "price", "image_url"]
sortByobjectnoCustom result ordering, in the same shape as the search sortBy. Fields from the request take precedence over any sort configured for the index.{ "fields": [{ "fieldName": "price", "order": "asc" }] }
sessionIdstringnoShopper session identifier, used together with userId to look up tracked events."xyz789"
profileIdstringnoA named search configuration profile for the request. If the profile does not exist, Marqo falls back to the default configuration."home_default"

documentIds and merchandisingProfileId are not accepted on this endpoint.

limit and offset must be whole, non-negative numbers. The API does not check this itself: a fractional or negative value is passed to the search engine, which rejects the request.

note

Merchandising rules do not apply to this endpoint. To combine a personalised shelf with pins, exclusions or boosts, create a For You widget instead.

Response (example)

{
"hits": [
{
"_id": "sku_51230",
"_score": 0.8127,
"title": "Merino Crew Sweater",
"price": 129.0,
"image_url": "https://cdn.example.com/sku_51230.jpg"
}
],
"processingTimeMs": 71,
"limit": 12,
"offset": 0
}
FieldTypeDescription
hitsarray[object]The recommended documents, each with _id, _score and the retrieved attributes.
processingTimeMsintegerServer processing time in milliseconds.
limitintegerThe limit applied to the request.
offsetintegerThe offset applied to the request.

There is no totalHits field. Whether the results were personalised is reported in a header, not in the body.

HeaderDescription
x-marqo-results-personalizedAlways present. true when the shelf was built from the shopper's tracked events; false when the endpoint fell back to a regular search (see below).
x-marqo-cache-hit-count, x-marqo-cache-miss-countHow many of the underlying searches were served from cache and how many were not.

Fallback when the shopper cannot be personalised

When the shopper has no tracked events (or none of the requested interactionTypes), when their tracked products no longer exist in the index, or when their event history cannot be fetched in time, the endpoint does not return an error. It returns a regular search response for the whole index instead, with the other request parameters (such as filter and limit) applied, and x-marqo-results-personalized: false. That response has the search response shape, including totalHits, facets and query, and carries the x-marqo-cache-hit header. Clients should handle both shapes, for example by rendering hits and ignoring fields they do not expect.

The fallback response carries x-marqo-cache-hit in place of the x-marqo-cache-hit-count and x-marqo-cache-miss-count headers.

A personalised shelf is assembled from several searches run in parallel. If some of them fail but at least one succeeds, the endpoint returns 200 with the results it has and reports x-marqo-results-personalized: false, rather than falling back to a whole-index search.

Errors

Error responses have the body {"error": "<message>"}.

StatusMessage
400Parameter 'userId' is required and must be a non-empty string
400Personalized recommendations not configured, please contact Marqo to enable them when the index has no event tracking pixel or personalisation is switched off
400Unrecognized param(s): '<name>' for any parameter not listed above
400A message from the request validator when a value fails its constraint, for example an interactionTypes entry that is not one of the three event types