The Visitor Segments endpoint returns the active segments for a specific visitor UID.
Endpoint
- URL:
/wp-json/personalizewp/v1/visitor-segments - Method:
POST - Content type:
application/json
Request body
| Parameter | Type | Required | Notes |
|---|---|---|---|
uid | string | Yes | The visitor ID |
Response shape
{
"success": true,
"data": [
{
"id": 12,
"name": "Frequent Buyers",
"type": "lead_score",
"created": "2026-04-15 10:00:00"
}
]
}
Example
async function fetchVisitorSegments(uid) {
const response = await fetch(
`${window.pwpSettings.root}personalizewp/v1/visitor-segments`,
{
method: "POST",
headers: {
"Accept": "application/json, */*;q=0.1",
"Content-Type": "application/json",
"X-PWP-Auth-Token": window.pwpSettings.apiToken
},
body: JSON.stringify({ uid })
}
);
const result = await response.json();
return result.success ? result.data : [];
}
Notes
- Only active segments are returned
- The response wrapper is
{ success, data } - This endpoint is used by the current
Products For Youproduct collection recipe