User Segmentation

The APIs to create, read, update and delete user segments

post
Create a Segment

https://api.customerglu.com/segment/v1/segment
Create a segment of users. Returns the ID for the created segment Live Segments CustomerGlu segmentation engine Live Segment can be created by defining a set of filter arrays. Filter array can choose any property or subProperty from device registration call.To use any customAttributes that is unique to your company, pass them under customAttributes in the registration call. Current version does not support AND/OR functionality In-house Segmentation Engine If you have wish to use segmentation capability of third party platform or your in house engine, use add/remove endpoints to add or remove users to segment. For such segments, You can leave the the filter property as empty array while creating the segment
Request
Response
Request
Headers
Content-Type
optional
string
application/json
X-API-KEY
required
string
WriteKey provided by CustomerGlu
Body Parameters
name
required
string
Name of the segment
filter
required
array
Array of filter object. Can be let as empty array if not using live segmentation feature . Live segmentation feature only supports array of single object currently
filter.$.property
required
string
Base property to filter on
filter.$.subProperty
required
string
Name of subProperty to filter on. null if not applicable
filter.$.operator
required
string
Operator. Accepted values ["gt", "gte", "lt", "lte", "eq"]
filter.$.value
required
string
value for the property. Can be string/number/boolean
description
required
string
Description for the segment
Response
200: OK
{
"success": true,
"data": {
"id": "5fd385b22777090013c3374e",
"name": "Test Segment 43",
"description": "All the users in the test segment",
"filter": [
{
"property": "customAttributes",
"subProperty": "gameLevel",
"operator": "gt",
"value": 0,
"_id": "602433b4b92e24001803a4cf"
}],
"createdAt": "2020-12-11T14:44:02.146Z"
}
}

post
Add Users to a Segment

https://api.customerglu.com/segment/v1/user/add
Add a list of users to a existing campaign
Request
Response
Request
Headers
X-API-KEY
required
string
Write key provided by CustomerGlu
Content-Type
required
string
application
Body Parameters
users
required
string
Array of userIds to be added
segmentId
required
string
Segment Id to which users are to be added
Response
200: OK
{
"success": true,
"data": {
"users": [
"testuser1",
"testuser2"
],
"segmentId": "5fd34923c25a4768aa59e807",
"createdAt": "2020-12-11T14:45:06.867Z"
}
}

post
Remove users from Segment

https://api.customerglu.com/segment/v1/user/remove
Remove a list of users from a existing campaign
Request
Response
Request
Headers
X-API-KEY
required
string
Write Key provided by CutomerGlu
Content-Type
required
string
application
Body Parameters
segmentId
required
string
Segment Id to which users are to be removed
users
required
array
Array of userIds to be removed
Response
200: OK
{
"success": true,
"data": {
"users": [
"testuser1",
"testuser2"
],
"segmentId": "5fd34923c25a4768aa59e807",
"createdAt": "2020-12-11T14:45:06.867Z"
}
}

get
Retrieve Segment(s) that a User is a part of

https://api.customerglu.com/segment/v1/user/:userId
Get the list of segments the user is part of
Request
Response
Request
Path Parameters
userId
required
string
userId of the user
Headers
X-API-KEY
required
string
WriteKey Provided by CustomerGlu
Content-Type
required
string
application
Response
200: OK
{
"success": true,
"data": {
"userId": "testuser4",
"segments": [
"5ffef4444c390f7d4f1b9c8b",
"5ffef2ec4c390f7d4f1b9c86"
]
}
}

get
Get a Segment using Segment ID

https://api.customerglu.com/segment/v1/segment/:segmentId
Retrieve a segment detail from its id
Request
Response
Request
Path Parameters
segmentId
required
string
ID of the segment
Headers
Content-Type
required
string
application/json
X-API-KEY
required
string
writeKey provided by CustomerGu
Response
200: OK