Segments API
Last updated
Last updated
Segments are used for both Program & Rules logic and reporting. Functional examples of Segments are:
Create a segment of "Power Users," and restrict cash bonuses to these users only
Create a segment of "Churned Users" to report on high-risk users as soon as possible
Most Segments will be maintained programmatically using Program & Rule logic. However the Segments API allows you to directly add or remove users from a segment through an API request.
Functional use cases for using the Segments API instead of Program & Rules logic:
You want to assign users to a geographical region as soon as they sign up (Example: "User from Miami" based on GPS location data at signup)
You want to override Rules logic for a consistent use case (Example: "Developer Test Account")
To see more about real-world Segment use cases, check out our Guides->.
You must create a Segment on the Admin Dashboard before it will be accepted via the Segments API.
If an Activity is sent through the Activity API without having been defined on the Admin Dashboard, it be rejected. Any Network Admin can create or edit segments.
To create a Segment, navigate to Side Menu -> Incentives -> Segments -> New Segment. For more information visit Segments ->.
POST
/networks/YOUR_NETWORK_ID/segments
Where 'YOUR_NETWORK_ID' is replaced with your actual Network ID.
Warning: Adding a user to a Segment via the Segments API will override any automated Program & Rule logic that manages segments.
The Segments API allows you to take the following actions:
Add a user to a Segment. This adds the user to a segment and overrides any existing Program & Rule logic that might remove them in the future.
Block a user from a Segment. This removes a user from the segment if they were already a member, and blocks them from being added via Program & Rule logic in the future.
Reset a user's existing Add or Block overrides. This does not change Segment status but it allows Program and Rule logic to affect this user's Segment membership going forward.
Field Name | JSON Key | Type | Description | Required |
---|---|---|---|---|
Field Name | JSON Key | Type | Description | Required |
---|---|---|---|---|
User
user
string
The user. May be email or user_id.
Yes
Segment ID
segment_id
integer
The unique segment ID associated with this segment. It is created automatically when a new segment is created, and is viewable on the Village Admin Dashboard.
Yes
User Status
user_status
string
Options include: 1. "add" -> Adds the user to the segment. Adding a user via Segments API overrides automation logic. 2. "block" -> Blocks the user from being a member. Overrides automation logic. 3. "reset" -> Removes automation override from previous Add or Block overrides.
Yes
Metadata
metadata
object
Additional metadata for the user status change. See Metadata fields for options.
No
Reference ID
reference_id
string
An optional identifier that can be used for reporting purposes.
No
Status Change Timestamp
status_change_timestamp
integer
The Unix timestamp of when the segment status change occurred. If this is blank, Village will use the timestamp the data was received via the Village API as the Status Change Timestamp.
No
Description
description
string
A reason and description for the segment status change.
No