Calling the Personalized Search API

a request is comprised of three parts search token a token used to authenticate the search request that you must calling the personalized search api docid\ h unb5tzxaag0gurczbzb before making the personalized search api request suggestions auto suggestions docid 2r40txzvqay3wn8uz 7dl based on the text currently typed into the search field suggestions are updated live as the customer continues to type record queries a search of the mapped product catalog for products that meet the search criteria an individual result is called a record queries occur when the customer formally sends their search request by pressing enter or clicking a button that triggers the full search you can include both suggestions and queries in a request endpoint a monetate personalized search api request is a post call to the following url personalized search api endpoint https //engine monetate net/api/search/v1/site search/{name}/{instance}/{domain}/search basic request code here's the basic personalized search api request basic personalized search api request { "request" { "searchtoken" "monetate 12345678987654321", "suggestions" \[ { suggestions query 1 }, { suggestions query 2 } ], "recordqueries" \[ { record query 1 }, { record query 2 } ] } } refer to auto suggestions docid 2r40txzvqay3wn8uz 7dl for the required and optional objects, arrays, and key value pairs for the suggestions array in the request body refer to personalized site search queries docid\ gwgtooic olmkssgmarow and personalized category page queries docid\ k29ktfoksjadmvobo 1q3 , respectively, the required and optional objects, arrays, and key value pairs for the recordqueries array in the request body basic response code the basic response is as follows basic personalized search api response { "meta" { }, "suggestionresults" \[ { results of suggestions query 1 }, { results of suggestions query 2 } ], "queryresults" \[ { results of record query 1 }, { results of record query 2 } ] } obtaining a search token each personalized search api request must include a search token ( searchtoken ) this opaque token contains information about the customer—such as the customer's user identity persistence in requests and products that the customer previously viewed—as well as information about the experience and its configuration so that the personalization components can be applied to the results contained in the personalized search api response the first step of obtaining a search token is to create and activate an omnichannel personalized search experience in the monetate platform once you activate that experience, send a omnichannel personalized search action request on page load to receive the search token in the response include the token in requests that you send to the personalized search api calling the personalized search api docid\ h unb5tzxaag0gurczbzb while the customer is on that page when the customer moves to a different page, request a new search token from the engine api ensure that you send a decision request to the engine api on every page load so that the returned seach token includes the latest information about what products the customer has viewed and other relevant context necessary for the personalization aspect of the personalized search api response the endpoint for the search token request is as follows engine api endpoint https //engine monetate net/api/engine/v1/decide/{retailershortname} replace {retailershortname} with the parent value of your account this identifier is provided by your dedicated services team you can also find it on the api tab of the integration page of the monetate platform settings ensure that you include the content type header parameter in the request monetate request requirements setting its value to text/plain furthermore, ensure that the value of channel in the request body correctly specifies the account , instance, and domain you can find this information in the url when you are logged into the monetate platform callout of the account, instance, and domain of a monetate client as it appears in the url of the monetate platform refer to the model monetate\ decision\ decisionrequest as well as request requirements docid\ mchjagbkmagu2x17bretp and annotated example engine api request docid 9cg lczaqtiaflswbjpb2 for more information about the engine api models included in the request body here's an example of the search token request body example engine api request for personalized search experience { "channel" "a 76ca7dd3/p/example com", "events" \[ { "eventtype" "monetate\ decision\ decisionrequest", "requestid" "11111" }, { "eventtype" "monetate\ context\ ipaddress", "ipaddress" "79 173 135 170" }, { "eventtype" "monetate\ context\ useragent", "useragent" "mozilla/5 0 (macintosh; u; intel mac os x; en) applewebkit/522 11 (khtml, like gecko) safari/3 0 2" }, { "eventtype" "monetate\ context\ pageview", "url" "https //www example com/" } ] } here's the response to the example engine api request example engine api response for personalized search experience { "meta" { "code" 200, "monetateid" "5 1580506437 1738689374564" }, "data" { "responses" \[ { "requestid" "2e7c7073 42c6 4523 a1f4 512bf4d7b6c4", "actions" \[ { "actionevents" \[ "op click", "op impression" ], "actionid" 5285641, "searchtoken" "6 18 ejxdkmtugzaqrf9l1lyebypdtu2qkyiippuqqszmagkyypsehpnfc7rsqu5g58zjau7ahalamvufjpsj0sj0cedqqelhavuhjmauqdnrocufmo96urjeq1lhbb3e4tqdbdryjcrspfsjyr1ekw0ozi4vcpqmzu8ojibkcygtkn7qzbntbtajb6pp4mgv48exr5uhi3 wwqqlxwfe gg2zntzo qx7sfkwdz6toz6bfdfwiwdpofdcnwyb5vxj3223auv f3qcer6fbnwxldat6 y46nkuc1bv8lo3p0zn0dbjrm4w\ vokf2fcxdo41izaz93tqd4hij1 yxeqvyzgnbgpwrmg", "actiontype" "monetate\ action\ sitesearchapiaction" } ] } ] } }