Segment definitions endpoint
Adobe Experience Platform allows you to create segment definitions that define a group of specific attributes or behaviors from a group of profiles. A segment definition is an object that encapsulates a query written in Profile Query Language (PQL). Segment definitions are applied to profiles to create audiences. This object (segment definition) is also called a PQL predicate. PQL predicates define the rules for the segment definition based on conditions related to any record or time-series data you supply to Real-Time Customer Profile. See the PQL guide for more information on writing PQL queries.
This guide provides information to help you better understand segment definitions and includes sample API calls for performing basic actions using the API.
Getting started
The endpoints used in this guide are part of the Adobe Experience Platform Segmentation Service API. Before continuing, please review the getting started guide for important information that you need to know in order to successfully make calls to the API, including required headers and how to read example API calls.
Retrieve a list of segment definitions list
You can retrieve a list of all segment definitions for your organization by making a GET request to the /segment/definitions
endpoint.
API format
The /segment/definitions
endpoint supports several query parameters to help filter your results. While these parameters are optional, their use is strongly recommended to help reduce expensive overhead. Making a call to this endpoint with no parameters will retrieve all segment definitions available for your organization. Multiple parameters can be included, separated by ampersands (&
).
GET /segment/definitions
GET /segment/definitions?{QUERY_PARAMETERS}
Query parameters
table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 5-row-3 | ||
---|---|---|
Parameter | Description | Example |
start |
Specifies the starting offset for the segment definitions returned. | start=4 |
limit |
Specifies the number of segment definitions returned per page. | limit=20 |
page |
Specifies which page the results of segment definitions will start from. | page=5 |
sort |
Specifies which field to sort the results by. Is written in the following format: [attributeName]:[desc/asc] . |
sort=updateTime:desc |
evaluationInfo.continuous.enabled |
Specifies if the segment definition is streaming-enabled. | evaluationInfo.continuous.enabled=true |
Request
The following request will retrieve the last two segment definitions posted within your organization.
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with a list of segment definitions for the specified organization as JSON.
code language-json |
---|
|
Create a new segment definition create
You can create a new segment definition by making a POST request to the /segment/definitions
endpoint.
API format
POST /segment/definitions
Request
When creating a new segment definition, you can create it in either the pql/text
or pql/json
format.
accordion | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A sample request to create a segment definition. | ||||||||||||||||||||||
|
accordion | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A sample request to create a segment definition. | ||||||||||||||||||||||
|
Response
A successful response returns HTTP status 200 with details of your newly created segment definition.
code language-json |
---|
|
table 0-row-2 1-row-2 2-row-2 | |
---|---|
Property | Description |
id |
A system-generated ID of your newly created segment definition. |
evaluationInfo |
An object that indicates what type of evaluation the segment definition will undergo. It can be batch, streaming (also known as continuous), or edge (also known as synchronous) segmentation. |
Retrieve a specific segment definition get
You can retrieve detailed information about a specific segment definition by making a GET request to the /segment/definitions
endpoint and providing the ID of the segment definition you wish to retrieve in the request path.
API format
GET /segment/definitions/{SEGMENT_ID}
{SEGMENT_ID}
id
value of the segment definition you want to retrieve.Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with detailed information about the specified segment definition.
code language-json |
---|
|
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 9-row-2 | |
---|---|
Property | Description |
id |
A system-generated read-only ID of the segment definition. |
name |
A unique name by which to refer to the segment definition. |
schema |
The schema associated with the entities in the segment. Consists of either an id or name field. |
expression |
An entity that contains fields information about the segment definition. |
expression.type |
Specifies the expression type. Currently, only “PQL” is supported. |
expression.format |
Indicates the structure of the expression in value. Currently, the following format is supported:
|
expression.value |
An expression that conforms to the type indicated in expression.format . |
description |
A human readable description of the definition. |
evaluationInfo |
An object that indicates what type of evaluation, batch, streaming (also known as continuous), or edge (also known as synchronous), the segment definition will undergo. |
Bulk retrieve segment definitions bulk-get
You can retrieve detailed information about multiple specified segment definitions by making a POST request to the /segment/definitions/bulk-get
endpoint and providing the id
values of the segment definitions in the request body.
API format
POST /segment/definitions/bulk-get
Request
code language-shell |
---|
|
table 0-row-2 1-row-2 | |
---|---|
Property | Description |
ids |
An array that contains objects that state the IDs of the segment definitions you want to retrieve. |
Response
A successful response returns HTTP status 207 with the requested segment definitions.
code language-json |
---|
|
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 9-row-2 | |
---|---|
Property | Description |
id |
A system-generated read-only ID of the segment definition. |
name |
A unique name by which to refer to the segment definition. |
schema |
The schema associated with the entities in the segment. Consists of either an id or name field. |
expression |
An entity that contains fields information about the segment definition. |
expression.type |
Specifies the expression type. Currently, only “PQL” is supported. |
expression.format |
Indicates the structure of the expression in value. Currently, the following format is supported:
|
expression.value |
An expression that conforms to the type indicated in expression.format . |
description |
A human readable description of the definition. |
evaluationInfo |
An object that indicates what type of evaluation, batch, streaming (also known as continuous), or edge (also known as synchronous), the segment definition will undergo. |
Delete a specific segment definition delete
You can request to delete a specific segment definition by making a DELETE request to the /segment/definitions
endpoint and providing the ID of the segment definition you wish to delete in the request path.
API format
DELETE /segment/definitions/{SEGMENT_ID}
{SEGMENT_ID}
id
value of the segment definition you want to delete.Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with no message.
Update a specific segment definition
You can update a specific segment definition by making a PATCH request to the /segment/definitions
endpoint and providing the ID of the segment definition you wish to update in the request path.
API format
PATCH /segment/definitions/{SEGMENT_ID}
{SEGMENT_ID}
id
value of the segment definition you want to update.Request
The following request will update the work address country from the USA to Canada.
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with details of your newly updated segment definition.
code language-json |
---|
|
Convert segment definition
You can convert a segment definition between pql/text
and pql/json
or pql/json
to pql/text
by making a POST request to the /segment/conversion
endpoint.
API format
POST /segment/conversion
Request
The following request will change the segment definition’s format from pql/text
to pql/json
.
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with details of your newly converted segment definition.
code language-json |
---|
|
Next steps
After reading this guide you now have a better understanding of how segment definitions work. For more information on creating a segment, please read the creating a segment tutorial.