Please note: this set of APIs is scheduled for deprecation in 2017. New implementations should start by using the newly released Evaluation API


A segment can be evaluated if the following preconditions are met

  1.  A segment is created using the segments resource.
  2. The segment is enabled.
  3. The profile on which the segment is to be evaluated exists.

Segment evaluation can be done by making a request to url /v1/companies/<companyId>/buckets/<bucketId>/segment-evaluation. The request should be GET and a successful segment evaluation will result in a 200 OK. The segment-evaluation resource must be called with query parameters profile_id and segment_id.


Required permission segment.evaluation


Request Headers

Header

Required

Acceptable Value(s)

Description

AcceptYesapplication/json
Content-encodingNogzipCaller can send a gzipped request to the API and set the Content-encoding as gzip.
Accept-encodingNogzip

Caller can request a gzipped response from the API and set the Accept-encoding as gzip.


Query parameter

Required

Description

app_keyNoAn app key refers to a collectApp. If an app key is specified, the profile data is added as the collectApp corresponding to that app key. If no app key is specified then profile data is added using the default collectApp "web". Similarly, the response will return the collectApp data corresponding to the app key. The returned data will additionally be filtered though any whitelists and/or blacklists configured for this collect app. If no collect app is specified, data and; blacklist and whitelist configurations of collectApp "web" will be used.
profile_idYesReferences an existing profile.
segment_idYesReferences an existing segment. The segments are created using the Config API's segments resource.
filteredProfileNofilteredProfile can have a value of "true" or "false". If filteredProfile is set to true and the result of the segment evaluation is true, then the response json will contain an additional field called filteredProfile. The filtered profile contains the parts of the profile which matched the segment evaluation.


Example: Response of requesting a Segment Evaluation


Response Body
{
 
   "segment-evaluation":{
      "result":<true|false>
   },
   "links":{
      "self":"http://&lt;hostname&gt;/v1/companies/&lt;companyId&gt;/buckets/&lt;bucketId>/segment-evaluation"
   }
 
}


Example: Response of requesting a Segment Evaluation with filteredProfile set to true and a successful evaluation


Response Body
{
 
   "segment-evaluation":{
      "result":true,
      "filteredProfile":{
         "id":"<profileId>",
         "sessions":[
            ...
         ],
         "attributes":[
            ...
         ]
      }
   },
   "links":{
      "self":"https://&lt;hostname&gt;/v1/companies/&lt;companyId&gt;/buckets/&lt;bucketId>/segment-evaluation"
   }
 
}