Stateless Segmentation
This endpoint accepts a list of events for a given user and optionally some pre-existing state for the user. It uses these to determine the full list of cohorts of which they are a member, and returns these along with the updated state for the user. State is not persisted, so will not be used in the next request unless it is passed back in as part of that request.
It is likely that this endpoint is more performant than the stateful segmentation endpoint, since it does not need to read state for the user from a database. It is also useful for testing purposes.
Events provided to this endpoint are published to the Permutive Events API, meaning that they will be reflected in other areas of Permutive, for example Insights.
When to Use Stateless Segmentation
The stateless endpoint is ideal for:- Testing and debugging: Verify cohort logic without affecting production state
- High-performance scenarios: Skip database reads/writes for faster response times
- Client-managed state: When you want to manage user state in your own systems
User State
You can optionally provide pre-existing user state in the request. The response will include the updated state that you should store and pass back in subsequent requests.Example Usage
First Request (No State)
Subsequent Request (With State)
Response
The response includes:user_id: The Permutive User IDstate: The updated user state (including cohort memberships)
state and include it in your next request to maintain continuity.Authorizations
Query Parameters
Validate provided event(s) against their schema before proceeding with segmentation.
By default validation is performed asynchronously after segmentation has been performed and the response has been returned. This can make it difficult to debug issues with invalid events.
It is recommended to use this option only during development and debugging, as validation can be expensive and slow.
Body
A user identifier and a list of events to be used for segmentation, plus optional pre-existing state for the user.
The user identifier must be either a user_id, an alias, or a list of prioritised aliases.
The largest number of events that can currently be included in a single request is 10.
State is in the JSON format returned by this endpoint. It is not intended to be parsed or understood outside the context of this API or a Permutive SDK.