logo

Segment

Segment it is a collection of clients with common features, e.g. VIP clients

Table of contents

GET all segments

There is possible to get whole list of segments. Use GET /api/v1/account/integrations/auth-required/segments
The diagram below shows the dependency of communicating with the API:
Image without caption
To get all segments you need to put requred the following data in request:
  • pageNumber (query)
  • pageSize(query)
Example request
json
curl -X GET "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/segments?pageNumber=1&pageSize=100" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"
In response you get all segment with full information about them
Example response
json
[ { "id": "ab9e32db-48a1-47b3-9fda-975b9ed8a9d6", -- identifier of segment "name": "Hurtownie", -- name of segment "externalId": "Hurt", -- external identifier of segment "parentSegmentId": null -- parent identifier of segment }, { "id": "eb11f451-1c82-4b61-89fd-cf3a5e8801ea", "name": "VIP Client", "externalId": "VIP", "parentSegmentId": "segment" }, { "id": "fb800655-125a-44f7-a5eb-a63647caf045", "name": "Detaliczni", "externalId": "100", "parentSegmentId": "segment" }, { "id": "fcc98538-8957-4178-8f60-df14d7c24567", "name": "Podhurt", "externalId": "1", "parentSegmentId": "ab9e32db-48a1-47b3-9fda-975b9ed8a9d6" }, { "id": "segment", "name": "segment", "externalId": null, "parentSegmentId": null } ]

POST - create segment

Segments can be created both in the external system and in ONe. Check here how to create segments in ONe platform.
Use to create segments in external system POST /api/v1/account/integrations/auth-required/segments
The diagram below shows the dependency of communicating with the API:
Image without caption
To create segment you need in request to put required the following data:
  • name
You can also put additionally the following data:
  • externalID
  • parnetSegmentId
Example request
json
curl -X POST "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/segments" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}" -H "Content-Type: application/json" -d "{ { "externalId": "VIP", -- Identifier from external system "name": "VIP Client", -- name of segment "parentSegmentId": "segment" }"
In response you will receive identifier of segment
Example response
json
{ "id": "eb11f451-1c82-4b61-89fd-cf3a5e8801ea" }

GET segments for synchronization

As previously mentioned, There is possible to create segments in ONe.
The diagram below shows the dependence of communicating with the API when segments was created in ONe platform:
Image without caption
In this case first of all you have to use GET /api/v1/account/integrations/auth-required/segments/synchronization to find the specified segment created or edited in ONe.
To create segment you need in request to put required the following data:
  • contexts - list of the event context, default: APPLICATION, BACKOFFICE, INTERNAL, INTEGRATIONS
  • startId - the step from which start synchronization
Example request
json
curl -X GET "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/segments/synchronization?contexts=INTEGRATIONS&startId=9" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"
In response you will receive a information about next step ID, segment ID and type
Example response
json
{ "nextId": 10, -- next step identifier "events": [ { "segmentId": "eb11f451-1c82-4b61-89fd-cf3a5e8801ea", -- segment identifier "type": "CREATE" -- kind of type (create, update or delete) } ] }
When we see that the segment has changed, we can use his ID to check the current data. Here's how to do it.

GET segment

Now as you have segmentId you can use GET /api/v1/account/integrations/auth-required/segments/{segmentId} to receive information about specific client using his ID
The diagram below shows the dependency of communicating with the API:
Image without caption
To get information about selected segment you need to put required the following data in request:
  • segmentId (path)
Example request
json
curl -X GET "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/segments/eb11f451-1c82-4b61-89fd-cf3a5e8801ea" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"
In response you get whole information about selected segment.
Example response
json
{ "id": "eb11f451-1c82-4b61-89fd-cf3a5e8801ea", "name": "VIP Client", "externalId": "VIP", "parentSegmentId": "segment" }

PUT - update segment

Segment information can be edited both in an external system and in ONe platform. If segment is edited in ONe, the further process is exactly the same as in the case of creating/editing a new segment in ONe. Click here to go back to these steps.
If information about segments is to be edited by API use PUT /api/v1/account/integrations/auth-required/segments/{segmentId}
The diagram below shows the dependency of communicating with the API:
Image without caption
To update segment you need in request to put required the following data:
  • segmentId (path)
  • name (body)
You can also put additionally the following data:
  • externalId
  • parentSegmentId
Example request
json
curl -X PUT "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/segments/eb11f451-1c82-4b61-89fd-cf3a5e8801ea" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}" -H "Content-Type: application/json" -d "{ { "externalId": "Client VIP", "name": "Client VIP", "parentSegmentId": "ab9e32db-48a1-47b3-9fda-975b9ed8a9d6" -- ID of segment }"

DELETE segment

At the end you have the option to delete the segment. Use DELETE /api/v1/account/integrations/auth-required/segments/{segmentId}
The diagram below shows the dependency of communicating with the API:
Image without caption
To delete segment you need in request to put required the following data:
  • segmentId (path)
Example request
json
curl -X DELETE "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/segments/eb11f451-1c82-4b61-89fd-cf3a5e8801ea" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"

Powered by Notaku