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.

FieldTypeRequired stateDescription
idstringResponse onlyUnique segment identifier returned by the API.
projectIdstringResponse onlyIdentifier of the project that owns the segment.
keystringRequired when creatingSegment key used to identify the reusable audience.
namestringRequired when creatingSegment name. Must contain at least one character and no more than 120 characters.
descriptionstringOptional when creating; nullable in responsesOptional segment description. A create request can contain up to 500 characters.
conditionsarray of condition objectsRequired when creating and returned in responsesCondition set that defines the segment audience.
createdAtstringResponse onlySegment creation timestamp.
updatedAtstringResponse onlyTimestamp of the most recent segment update.

Endpoints

MethodPathDescription
POST/v1/projects/{projectId}/segmentsCreate a segment whose conditions can be referenced from targeting rules. Returns the created segment with status 201.
GET/v1/projects/{projectId}/segmentsList the segments for a project. Returns the collection in a data array with status 200.