Segments
Segments
Reusable audience segments with condition sets
Overview
Segments are reusable, rule-based audiences within a project. A segment contains a key, a name, an optional description, and a set of conditions. Targeting rules can reference segments when determining which variation an evaluation context receives.
The Segments resource provides two project-scoped operations:
Create a segment with
POST /v1/projects/{projectId}/segments.List a project's segments with
GET /v1/projects/{projectId}/segments.
Both operations require a server API key. The projectId route parameter identifies the project whose segments you manage.
Note:
Use the running API's OpenAPI contract at /docs or /openapi.json to inspect the generated condition schema and the exact request and response definitions.
Schema
The create request and segment response use the following fields. The conditions field is an array of condition objects; its member fields are defined by the API's condition schema.
| Field | Type | Required state | Description |
|---|---|---|---|
id | string | Response only | Unique segment identifier returned by the API. |
projectId | string | Response only | Identifier of the project that owns the segment. |
key | string | Required when creating | Segment key used to identify the reusable audience. |
name | string | Required when creating | Segment name. Must contain at least one character and no more than 120 characters. |
description | string | Optional when creating; nullable in responses | Optional segment description. A create request can contain up to 500 characters. |
conditions | array of condition objects | Required when creating and returned in responses | Condition set that defines the segment audience. |
createdAt | string | Response only | Segment creation timestamp. |
updatedAt | string | Response only | Timestamp of the most recent segment update. |
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /v1/projects/{projectId}/segments | Create a segment whose conditions can be referenced from targeting rules. Returns the created segment with status 201. |
GET | /v1/projects/{projectId}/segments | List the segments for a project. Returns the collection in a data array with status 200. |