Segment jobs endpoint
A segment job is an asynchronous process that creates an audience segment on demand. It references a segment definition, as well as any merge policies controlling how Real-Time Customer Profile merges overlapping attributes across your profile fragments. When a segment job successfully completes, you can gather various information about the segment, such as any errors that may have occurred during processing and the ultimate size of your audience.
This guide provides information to help you better understand segment jobs and includes sample API calls for performing basic actions using the API.
Getting started
The endpoints used in this guide are part of the ۶Ƶ 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 jobs retrieve-list
You can retrieve a list of all segment jobs for your organization by making a GET request to the /segment/jobs
endpoint.
API format
The /segment/jobs
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 export jobs available for your organization. Multiple parameters can be included, separated by ampersands (&
).
GET /segment/jobs
GET /segment/jobs?{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 jobs returned. | start=1 |
limit |
Specifies the number of segment jobs returned per page. | limit=20 |
status |
Filters the results based on status. The supported values are NEW, QUEUED, PROCESSING, SUCCEEDED, FAILED, CANCELLING, CANCELLED | status=NEW |
sort |
Orders the segment jobs returned. Is written in the format `[attributeName]:[desc | asc]`. |
property |
Filters segment jobs and gets exact matches for the filter given. It can be written in either of the following formats:
|
property=segments~segmentId==workInUS |
Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with a list of segment jobs for the specified organization as JSON. However, the response will differ, depending on the number of segment definitions within the segment job.
If you have less than 1500 segment definitions being run in your segment job, a full list of all the segment definitions will be displayed within the children.segments
attribute.
note note |
---|
NOTE |
The following response has been truncated for space, and will only show the first returned job. |
accordion | ||
---|---|---|
A sample response when retrieving a list of segment jobs. | ||
|
If you have more than 1500 segment definitions being run in your segment job, the children.segments
attribute will display *
, indicating that all the segment definitions are being evaluated.
note note |
---|
NOTE |
The following response has been truncated for space, and will only show the first returned job. |
accordion | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A sample response when viewing a list of segment jobs. | ||||||||||||||||||||||||||||||
|
Create a new segment job create
You can create a new segment job by making a POST request to the /segment/jobs
endpoint and including in the body the ID of the segment definition from which you would like to create a new audience.
API format
POST /segment/jobs
When creating a new segment job, the request and response will differ depending on the number of segment definitions within the segment job.
Request
accordion | ||||||||
---|---|---|---|---|---|---|---|---|
A sample request for creating a new segment job | ||||||||
|
Response
A successful response returns HTTP status 200 with information about your newly created segment job.
accordion | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A sample response when creating a new segment job. | ||||||||||||||||
|
Request
note note |
---|
NOTE |
While you can create a segment job with more than 1500 segment definitions, this is highly not recommended. |
accordion | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
A sample request for creating a segment job. | ||||||||||
|
Response
A successful response returns HTTP status 200 with details of your newly created segment job.
accordion | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A sample response when creating a segment job. | ||||||||||||||
|
Retrieve a specific segment job get
You can retrieve detailed information about a specific segment job by making a GET request to the /segment/jobs
endpoint and providing the ID of the segment job you wish to retrieve in the request path.
API format
GET /segment/jobs/{SEGMENT_JOB_ID}
{SEGMENT_JOB_ID}
id
value of the segment job you want to retrieve.Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with detailed information about the specified segment job. However, the response will differ depending on the number of segment definitions within the segment job.
If you have less than 1500 segment definitions being run in your segment job, a full list of all the segment definitions will be displayed within the children.segments
attribute.
accordion | ||
---|---|---|
A sample response for retrieving a segment job. | ||
|
If you have more than 1500 segment definitions being run in your segment job, the children.segments
attribute will display *
, indicating that all the segment definitions are being evaluated.
accordion | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A sample response for retrieving a segment job. | ||||||||||||||||||
|
Bulk retrieve segment jobs bulk-get
You can retrieve detailed information about multiple segment jobs by making a POST request to the /segment/jobs/bulk-get
endpoint and providing the id
values of the segment jobs in the request body.
API format
POST /segment/jobs/bulk-get
Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 207 with the requested segment jobs. However, the value of the children.segments
attribute differs depending if the segment job is running for more than 1500 segment definitions.
code language-json |
---|
|
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 | |
---|---|
Property | Description |
id |
A system-generated read-only identifier for the segment job. |
status |
The current status for the segment job. Potential values for the status include “NEW”, “PROCESSING”, “CANCELLING”, “CANCELLED”, “FAILED”, and “SUCCEEDED”. |
segments |
An object that contains information about the segment definitions returned within the segment job. |
segments.segment.id |
The ID of the segment definition. |
segments.segment.expression |
An object that contains information about the segment definition’s expression, written in PQL. |
Cancel or delete a specific segment job delete
You can delete a specific segment job by making a DELETE request to the /segment/jobs
endpoint and providing the ID of the segment job you wish to delete in the request path.
API format
DELETE /segment/jobs/{SEGMENT_JOB_ID}
{SEGMENT_JOB_ID}
id
value of the segment job you want to delete.Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 204 with an empty response body.
Next steps
After reading this guide you now have a better understanding of how segment jobs work.