Loading...
Area: Optimizely Profile Store
Applies to versions: 1.6.0 and higher

Exporting profiles data based on a segment

Recommended reading 

Closed preview. This information is not publicly available, access is restricted. By using this feature you are committing to doing it under consultancy with your Optimizely representative. You will be held liable if using the feature without sign-off.

This topic describes how to export profile data requests based on a segment, check status of export request, and get the exported URL.

In this topic

Steps to export profiles data

  1. Send an export profiles data request using the {segmentId}/Export endpoint. The RequestId is returned and used in next step.
  2. Send an export request with RequestId using {segmentId}/Export/{requestId} endpoint. Status is returned.
    • If Status is InProgress, ResultUrl returns an endpoint to continue checking the export process. Currently, it just the same endpoint with the requestId above.
    • When the export process is done (Status is Finished), ResultUrl returns the destination of the file contains the result and the file URL's authentication header.
    • Request the file using the URL returned in the previous step with the authentication header
  3. Use ExportUrl for getting profiles data.

Response data structure

  • SegmentId. Gets a list of profiles.
  • RequestId. Returned from ProfileAPI.

    Note: A requestId expires after one day.

  • Status. The export request status:
    • Invalid. Export RequestId that a user sent is not valid.
    • SourceNotFound. The source object (segment) that a user requested does not exist or was already deleted.
    • InProgress. Export request that a user sent is processing.
    • Error. Export request generates an error while exporting list of profile data; resend the export request.
    • Expired. Export request exceeds the request's time limit, which is 1 day.
    • Finished. Export job completed successfully.
  • ResultUrl. The endpoint of the export process to check if it is still in progress. If the export process is completed, return the file URL instead. Otherwise, this field will not appear.
  • Headers. The authentication header of ResultUrl after the export process is competed.
    • It appears only when the Status is Finished.
    • It contains 3 headers: x-ms-date, x-ms-version and Authorization; you need all 3 headers to authenticate the URL.

1. Send an export profiles data request

Endpoint

GET /api/v1.0/Segments/{segmentId}/Export

Note: Based on a number in the ProfileAPI configuration, only the specified number of export requests are executed at the same time; others wait for on-going export requests to finish. This may affect execution time of a request.

Response

{ 
  "RequestId" : "cX1AXkJXQk8GQ3F3QFlLOkIVARZ3fEkNQwYRQg", 
  "SegmentId" : "b6314c4c-8808-4e54-b547-01106b7031f6", 
  "Status"    : "Accepted", 
  "ResultUrl" : "" 
}

The Status should be Accepted, which means the export request was accepted and will process soon.

2. Send an export request with RequestId

After using the API endpoint in section 1 to send a request, you receive a requestId in return and use it to check the export status.

Endpoint

GET /api/v1.0/Segments/{segmentId}/Export/{requestId}

Usage

  • segmentId. Gets a list of profile data. The segmentId must be the same with the segmentId used in section 1.
  • requestId. Checks the status of export request. The requestId is returned when using send and export requests in section 1.

Response

{
  "RequestId" : "cX1AXkJXQk8GQ3F3QFlLOkIVARZ3fEkNQwYRQg",
  "SegmentId" : "b6314c4c-8808-4e54-b547-01106b7031f6",
  "Status"    : "Finished",
  "ResultUrl" : "https://export.blob.core.windows.net/your-path/export-file.json",
  "Headers"   : {
                  "x-ms-date"     : "Thu, 12 Jul 2018 02:36:25 GMT",
                  "x-ms-version"  : "2018-03-27", 
                  "Authorization" : "SharedKey thngsfus4jx7hqvzeexport:9ngTVYkyJP1jQ4JOvAT/f1VSGodvT25RJ7gPQ+kc/EI="
                }
}

If the Status is InProgress, allow more time for processing then send the request again until Status is Finished.

Not Found Response (404)

  • If the requestId is invalid and it cannot be found in the database, or
  • If the requestId is expired

3. Use ExportUrl for getting profiles data

After the export is done (Status is set to Finished), request using the link in ResultUrl, with the header in Headers

The JSON data returned:

[
  {"ProfileId":"6243d1c0-70dd-453e-9cc4-63c577cb25ab","Email":"example1@optimizely.com"},
  {"ProfileId":"4c181385-1143-4cff-b867-41675bc798ad","Email":"example2@optimizely.com"},
  {"ProfileId":"2040a1d8-3b36-4978-8ad6-96cbdc6d9c1c","Email":"example3@optimizely.com"},
  {"ProfileId":"c08d47ee-6f51-4db5-8b36-cd4deb052817","Email":"..."} 
]
Do you find this information helpful? Please log in to provide feedback.

Last updated: Mar 08, 2021

Recommended reading