Predict
You can return a list of recommended products based on a specified set of "seed" products (e.g., "products related to what's in the cart" or "contacts who viewed X also viewed Y"). Seed products that don't exist are skipped, so you still get general recommendations.
This API endpoint does not require an API authorization key, to allow direct querying from the contact's browser.
This endpoint isn't under /api/public: the full URL is https://<your_app_subdomain>.user.com/predictions/predict/. Under /api/public it answers 404. Send JSON with Content-Type: application/json.
Attributes
Optional unless marked required
- custom_ids
- Custom IDs of the seed products. Send
custom_idsorproduct_ids, not both (400). - product_ids
- User IDs of the seed products. Seed products that don't exist are skipped; you still get general recommendations.
- limit
- How many products to return, from 1 to 25. Defaults to 10. Outside that range gives
400. - segment_id
- ID of a product segment to pick recommendations from (e.g. "Available products"). An unknown ID gives
404. - categories
- Category names; recommendations are limited to products in these categories. Unknown names aren't an error, they just match nothing.
- tags
- Tag names; recommendations are limited to products with these tags. Unknown names match nothing.
- extra_data
- What to do when the filters leave fewer products than
limit.0returns only the matching products (possibly none).1, the default, fills the rest with general recommendations; any other number works like1.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/predictions/predict/" \
-H "Content-Type: application/json" \
-d '{
"custom_ids": ["SKU123", "SKU456"],
"limit": 5,
"segment_id": 101,
"extra_data": 0
}'
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/predictions/predict/");
xhr.setRequestHeader("Content-Type", "application/json");
var data = JSON.stringify({
"custom_ids": ["SKU123", "SKU456"],
"limit": 5,
"segment_id": 101,
"extra_data": 0
});
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/predictions/predict/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode(array(
"custom_ids" => array("SKU123", "SKU456"),
"limit" => 5,
"segment_id" => 101,
"extra_data" => 0
)),
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
import http.client
import json
conn = http.client.HTTPSConnection("<your_app_subdomain>.user.com")
payload = json.dumps({
"custom_ids": ["SKU123", "SKU456"],
"limit": 5,
"segment_id": 101,
"extra_data": 0
})
headers = { 'Content-Type': "application/json" }
conn.request("POST", "/predictions/predict/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response examples
- 200 OK
- 400 Bad Request
- 404 Not Found
{"recommended_products": [{"id": 85,"name": "Classic Sneakers","custom_id": "SKU123","description": "Lightweight sneakers for everyday wear.","product_url": "https://www.example.com/product/classic-sneakers/","image_url": "https://www.example.com/images/classic-sneakers.jpg","qty": 1,"created_at": "2026-11-10T14:20:02.361287Z","updated_at": "2026-11-10T14:20:02.361297Z","attributes": ,2 items"categories": 1 item}]}{"non_field_errors": ["Must fill one of product_ids or custom_ids"]}{
"detail": "Segment with id=999999999 does not exist"
}
A 400 also comes when both product_ids and custom_ids are sent ("Cannot fill both product_ids and custom_ids"), when a list is empty, or when limit is outside 1–25. A 404 comes only from an unknown segment_id; unknown seed products don't cause one.
Response fields
Fields returned in the 200 OK response body.
- recommended_products
- Recommended products, most relevant first. At most
limitproducts.- recommended_products[].
id - A unique identifier for the product which is given by User automatically.
- recommended_products[].
name - A product name.
- recommended_products[].
custom_id - A unique identifier for the product which is provided by the client, or
nullif it has none. Usually related to the product’s SKU. - recommended_products[].
description - Description of the product, or
null. - recommended_products[].
product_url - A URL of a product.
- recommended_products[].
image_url - A URL of a product image.
- recommended_products[].
qty - Quantity of the product, or
nullif not set. - recommended_products[].
created_at - A creation date of a product.
- recommended_products[].
updated_at - A date of last product update.
- recommended_products[].
attributes - Custom product attributes that have a value, each with
name,name_std,value,descriptionandvalue_type.- recommended_products[].
attributes[]. name - Name of the attribute.
- recommended_products[].
attributes[]. name_std - Standardized name of the attribute, used as its key in the API.
- recommended_products[].
attributes[]. value - Value of the attribute for this product.
- recommended_products[].
attributes[]. description - Description of the attribute.
- recommended_products[].
attributes[]. value_type - Value type of the attribute:
1boolean,2integer,3date,4string,5datetime,6fixed (a list of choices),7float or8JSON.
- recommended_products[].
- recommended_products[].
categories - Categories the product belongs to.
- recommended_products[].
categories[]. id - A unique identifier for the category which is given by User automatically.
- recommended_products[].
categories[]. name - A category name.
- recommended_products[].
categories[]. description - Description of the category.
- recommended_products[].
categories[]. custom_id - A unique identifier for the category which is provided by the client, or
null.
- recommended_products[].
- recommended_products[].