POST
/predictions/predict-for-user/Predict for user
You can return a list of personalized product recommendations tailored to a specific contact.
NO AUTHORIZATION REQUIRED
This API endpoint does not require an API authorization key, to allow direct querying from the contact's browser.
| Attributes | Type | Required | Description |
|---|---|---|---|
| user_id | string | no* | The unique identifier for a contact from your system (must match the contact's custom_id in User.com). One of user_id or user_key is required. |
| user_key | string | no* | The User.com system identifier for a contact (from __ca__chat cookie). One of user_id or user_key is required. |
| limit | number | no | Maximum number of products to return (max 25). |
| segment_id | number | no | ID of a product segment to filter recommendations (e.g., "Available Products"). |
| categories | array | no | Array of category names to filter by. |
| tags | array | no | Array of tag names to filter by. |
| extra_data | number | no | Controls behavior when filters result in fewer products than limit. 0 (Strict) returns only matching products. 1 (Default) fills remaining slots with general recommendations. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/predictions/predict-for-user/" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user_12345",
"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-for-user/");
xhr.setRequestHeader("Content-Type", "application/json");
var data = JSON.stringify({
"user_id": "user_12345",
"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-for-user/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode(array(
"user_id" => "user_12345",
"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({
"user_id": "user_12345",
"limit": 5,
"segment_id": 101,
"extra_data": 0
})
headers = { 'Content-Type': "application/json" }
conn.request("POST", "/predictions/predict-for-user/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response
{
"recommended_products": [
{
"id": 85,
"name": "Faux Patent Sneakers",
"custom_id": "1820",
"description": "Step into style with these glossy pastel pink sneakers, designed to make a bold yet elegant statement. Perfectly blending fashion and function, these sneakers feature a shiny finish that adds a touch of sophistication to any outfit. Lightweight and comfortable, they’re ideal for day-long wear. Whether paired with casual denim or a sleek skirt, these sneakers are a versatile addition to your wardrobe, perfect for adding a pop of color to your look.",
"product_url": "https://ecommerce.demouser.eu/product/faux-patent-sneakers/",
"image_url": "https://ecommerce.demouser.eu/wp-content/uploads/2018/02/5408231050_1_1_1.jpg",
"qty": 1,
"created_at": "2024-11-22T09:35:49.802241Z",
"updated_at": "2025-12-12T13:59:13.299549Z",
"attributes": [
{
"name": "condition",
"name_std": "condition",
"value": "New",
"description": "",
"value_type": 4
},
{
"name": "identifier_exists",
"name_std": "identifier_exists",
"value": "no",
"description": "",
"value_type": 4
},
{
"name": "item_id",
"name_std": "item_id",
"value": 1820,
"description": "",
"value_type": 2
},
{
"name": "sale_start_date",
"name_std": "sale_start_date",
"value": "2025-12-12",
"description": "",
"value_type": 3
},
{
"name": "brand",
"name_std": "brand",
"value": "Shop",
"description": "",
"value_type": 4
},
{
"name": "item_name",
"name_std": "item_name",
"value": "Faux Patent Sneakers",
"description": "",
"value_type": 4
},
{
"name": "price",
"name_std": "price",
"value": 45.0,
"description": "",
"value_type": 7
},
{
"name": "sku",
"name_std": "sku",
"value": 1820,
"description": "",
"value_type": 2
},
{
"name": "stockstatus",
"name_std": "stockstatus",
"value": "instock",
"description": "",
"value_type": 4
},
{
"name": "google_business_vertical",
"name_std": "google_business_vertical",
"value": "retail",
"description": "",
"value_type": 4
},
{
"name": "availability",
"name_std": "availability",
"value": [
"in_stock"
],
"description": "",
"value_type": 6
},
{
"name": "item_category",
"name_std": "item_category",
"value": "Shoes",
"description": "",
"value_type": 4
},
{
"name": "sale_price",
"name_std": "sale_price",
"value": 38.25,
"description": "",
"value_type": 7
},
{
"name": "sale_end_date",
"name_std": "sale_end_date",
"value": "2025-12-12",
"description": "",
"value_type": 3
}
],
"categories": [
{
"id": 83,
"name": "Women, Limited time offer, Shoes",
"description": "",
"custom_id": null
}
]
}
]
}