---
title: [Tech] Exploring the Segmentation Service API
slug: ikea-summer-2025-hol/tech-exploring-the-segmentation-service-api
docTags: 
createdAt: 2023-12-14T10:25:55.483Z
---

In this exercise, you’ll use Postman and Adobe I/O to create a audience and store the results of that audience as a dataset, by making use of Adobe Experience Platform’s APIs.

In the Real-time Customer Profile, all profile data is shown alongside event data and existing audience memberships. The data that is shown can come from anywhere, from Adobe applications and external solutions. This is the most powerful view in Adobe Experience Platform, the experience system of record.

# Create a Segment

Creating a audience using the AEP API's require a number of steps in Postman. But first...

- Locate the **AEP Bootcamp** collection.
- Open the **Segmentation Service API** folder.

## Step 1 - Create a Segment definition

We will first create a segment definition.

- Select **Segment Definition** >  <font color="#ff6900">**POST**</font> **Create a new segment definition**.
- Click on the **Body** tab to see the body of the request.&#x20;

You see the segment expression defined in the Profile Query Language, PQL. You can find more [information and documentation](https://experienceleague.adobe.com/docs/experience-platform/segmentation/pql/overview.html?lang=en) about PQL.

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/rrPiP4GB152UCNZfDWSdZ_image.png)

- Update the `name` value within the **Body** request. E.g. replace `demo` with your user identification.
- The body should look like:

```json
{
    "name" : "sacker - API - All Female Customers",
    "expression" : {"type":"PQL", "format":"pql/json", "value":"{\"nodeType\":\"fnApply\",\"fnName\":\"in\",\"params\":[{\"nodeType\":\"fieldLookup\",\"fieldName\":\"gender\",\"object\":{\"nodeType\":\"fieldLookup\",\"fieldName\":\"person\",\"object\":{\"nodeType\":\"literal\",\"literalType\":\"XDMObject\",\"value\":\"profile\"}}},{\"literalType\":\"List\",\"nodeType\":\"literal\",\"value\":[\"female\"]}]}"},
    "createdBy": "labs",
    "schema" : { "name" : "_xdm.context.profile"},
    "ttlInDays" : 90
}
```

You should also verify the headers of your request.

- Select **Headers** tab.
- You will see same set of header key/value pairs as in the earlier Postman example requests.

To create the segment:

- Click on **Send**.
- View the results in the **Body** section at the bottom.

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/ITIEXWlM-XCh81HWoBwY1_image.png)

You can now also view your segment definition in the UI.

- Login to Adobe Experience Platform.
- Go to **Audiences**.
- Select **Browse** tab.

You should see your created segment in the list of Audiences:

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/-aNyvJcbW1W2EPGoamL9n_image.png)

## Step 2 - Create a Preview Job

In the previous exercise, you created a *streaming* audience. When building a segment definition, you can calculate an estimate of the size of the resulting segment definition, allowing you to adjust your segment definition as needed.

Let’s now POST a Preview Job.

- Go to Postman.
- Open the **Segmentation Service API** folder (if not already open).
- Open the **Segmentation Preview** folder
- Select the <font color="#ff6900">**POST**</font> **Create a segment preview request**.
- Click on **Send**.

The segment preview has been created. Copy the value of `previewId`.

## Step 3 - GET Estimation Result

Once you have created a preview job, you can use its `previewId`in the path of a GET request to the `/estimate`endpoint to view statistical information about the segment definition, including projected audience size, confidence interval, and error standard deviation.

- Go to Postman.
- Select the <font color="#3b9f0f">**GET**</font> **Retrieve estimation result**.
- In Params, Path Variables replace `YOUR_PREVIEW_ID_HERE` with the value returned by the previous call.
- Click on **Send**.

This is the type of response you'll receive. It includes the `estimatedSize `field that tells you the estimation of number of profiles that match the audience condition.

```javascript
{
    "_links": {
        "preview": "https://platform.adobe.io/data/core/ups/preview/app-89b4780c-1b70-4971-a388-e1b2a14a4cc8/execution/0?previewQueryId=98589ead-e9ce-4f40-8f95-c4204fa9fea5"
    },
    "confidenceInterval": "95%",
    "error": {
        "description": "",
        "traceback": ""
    },
    "estimatedConsentDistribution": [],
    "estimatedNamespaceDistribution": [
        {
            "estimatedSize": 1855,
            "namespaceId": "12537677"
        }
    ],
    "estimatedSize": 1855,
    "isExact": true,
    "numRowsToRead": 5294,
    "profilesMatchedSoFar": 1855,
    "profilesReadSoFar": 5294,
    "standardError": 0,
    "state": "RESULT_READY",
    "totalRows": 5294
}
```

:::hint{type="success"}
You have now successfully created a streaming and a batch audience using the Adobe Experience Platform APIs.
:::

