REST API

Visitor Segments API Endpoint

Use Visitor Segments API Endpoint to work with PersonalizeWP programmatically.

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

ParameterTypeRequiredNotes
uidstringYesThe 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 You product collection recipe