What is the best way to verify if a user ID (or key) exist in a specific segment? Using Admin API we have to fetch all the keys for all segments and loop through them to find the segment names.
The Admin API does not have a call to check if a user is part of a specific segment, however, an easier and much faster way of getting this data is to use the Mobile and Web SDK GET HTTP call that fetches list of Segment names for a given user ID.
Here is the curl format, please note you need to use a browser type API Key to authenticate.
curl -H "Authorization: Bearer [Browser API Key]" -H "Accept: application/json" https://sdk.split.io/api/mySegments/[user id]
curl -H "Authorization: Bearer ebj1kXXXXXXXXXXXXXXXXX" -H "Accept: application/json" https://sdk.split.io/api/mySegments/testing4321
Please sign in to leave a comment.