A segment is a cohort of users. Targeting and allocation define the cohort:Documentation Index
Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
Use this file to discover all available pages before exploring further.
- Targeting: A set of criteria that filter users based on attributes
- Allocation: What percentage (0% to 100%) of the targeted users should be in the segment
Confidence makes no assumptions about the entity that you target or randomize on. Usually, the entity is a type of user (represented by an identifier). Because of this, the examples on this page involve users. Your unit could be something else.
Create a Basic Segment
To create a segment that targets 100% of all users:Create a Segment with Targeting
To create a segment that targets users from Sweden with 10% allocation:Set the Randomization Unit
By default, Confidence randomizes based on thetargeting_key field in the evaluation context. You can specify a different field using targetingKeySelector:
If the randomization field is missing from the evaluation context or is
null, the segment doesn’t match. The empty string ("") is a valid value for randomization.Allocate a Segment
Segments start in anUNALLOCATED state. To use a segment in a flag rule, you must first allocate it:
When coordinating with other segments, the allocation operation may fail if there’s not enough space to make the segment mutually exclusive with overlapping segments. See Coordinate Segments for more details.
Get a Segment
To retrieve a segment’s configuration:Update a Segment
You can update a segment’s targeting or allocation using the PATCH endpoint:Archive a Segment
When a segment is no longer needed, archive it:Next Steps
After creating segments:- Add targeting criteria for more sophisticated audience targeting
- Set up coordination to make segments mutually exclusive
- Create flag rules to assign variants to segments

