Usage Examples


This section describes the operations available for segment definitions. It allows you to create segments, update them, and query their data.


NOTE: Some APIs allow you to retrieve data on pages only. In that case, the following parameters must be specified in the query string.


PrerequisitesRequiredDescription
numberOfResultsYesSpecifies the requested page size. The maximum allowed page size is 100.
orderByYesSpecifies the result order. This can be any response field. Use one of the following formats to order the result:
- Ascending Order: &orderBy={fieldName} ASC
- Descending Order: &orderBy={fieldName} DESC
- Sort by multiple fields: Specify several &orderBy= parameters.
startingIndexOptionalSpecifies the index of the first item that you want to retrieve on the requested page. The default value is 0.

Create a New Segment

To create a new segment, you have to make the following POST request to the service:


POST https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments


This request will create a new active (statusId: 1) segment and automatically schedule the calculation of customers matching this segment. The following is a sample response:

This service returns a unique segment identifier and jobId that can be used to monitor the progress of segment recalculation.

Update an Existing Segment

To update segment, send new data to api/v1/segments/{segmentId} endpoint:


PUT https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/12


The update starts an asynchronous process of recalculating the segment customers. The returned response is the same as in the create request:

Retrieve Customer Segment Information

This section provides various examples to retrieve information about the customer segment.

Get a Single Segment by ID


GET https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/12


Response

Get Paged List of Segments


GET https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments?numberOfResults=10&orderBy=id


Response

Get a Paged List of Customers Assigned to a Segment


GET https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/12/customers?numberOfResults=10&orderBy=id


Response

Get a Paged List of Segments Assigned to Customer


GET https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/customers/1?request.numberOfResults=2&request.orderBy=id


Response

Activate or Deactivate a Segment

This section provides examples to activate and deactivate a segment.

Activate a Segment


PUT https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/12/status


Response

Deactivate a Segment


PUT https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/12/status


Response

Get Status of Segment Recalculation

Segment recalculation is done asynchronously in the background. If you want to check the current status of the running or finished job, you must use the jobId GUID returned by the CRUD endpoints and call the GET request to /api/v1/Segments/RecalculationStatus/{jobId}.


GET http://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/Segments/RecalculationStatus/a3681b4b-acd6-4b5a-8225-0c3bad329371


Response

Force Segments Recalculation Assigned to a Given Customer


GET https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/customers/1/recalculate


Response

Force Segment Recalculation by the Segment ID


GET https://dn-retail-segmentation-erp-eapi-dev.de-c1.eu1.cloudhub.io/api/v1/segments/1/recalculate


Response