When exporting, the segment can be based as a guid or an inline segment.

Get a Segment Reference ID

The guid can can be found in the URL bar in your browser. For example, in the screenshot below, the segment guid is “training.segments.68978”.

image.png

You can then plug this into the body as seen here: Example 4 - [segment] basic with template guid

Get an Inline Segment Body Schema based on UI

The easiest way to create an inline segment is to create the segment in Element451 first and either look at the network tab under developer tools or to call the API GET the segment.  You’ll be looking for the users, analytics , decisions , todos, surveys, documents, appointments  objects.

Using the API:

Call the API endpoint below, which will require the feature token and authorization. Call then endpoint and then copy any objects listed above (users, decisions, etc).It’ll look similar to the screenshot from the network tab.

GET https://{{client}}.api.451.io/v2/data/segments/{{segemnt ID}}

Using the network developer tools:

After loading the segment, left click in your browser and select “inspect” and navigate to the network tab. Return to the Element451 segment, and click “save”. This should create one network call  View the preview and copy the object. You’ll need any objects listed above, which in this case is “users”.

image.png

Building the Inline Segment Body

Your final export should look something similar to the example below which pulls all applicants with a submitted date in the last month, and has a root repeater showing all the majors for every applications for that applicant.

Request:
POST https://{{client}}.{{api}}/v2/users/export

URL parameters:
{{client}}: Assigned client subdomain.
{{api}}: URL of the Element451 API. "api.451.io" for Production API.

Request headers:
Feature: Feature token for that client
Content-Type: 'application/json'

Request body parameters:
{
    "item": {
        "template": {
            "columns": [
                {
                    "field": "First Name",
                    "mode": "slug",
                    "slug": "user-first-name",
                    "transformations": [],
                    "validations": [],
                    "empty": ""
                },
                {
                    "field": "Application Root",
                    "mode": "slug",
                    "slug": "user-applications-root",
                    "columns": [
                        {
                            "field": "Application - Major",
                            "mode": "slug",
                            "slug": "user-applications-major",
                            "transformations": [],
                            "validations": [],
                            "empty": ""
                        }
                    ]
                }
            ]
        },
        "segment": {
            "users": {
                "filters": {
                    "key": "application",
                    "negative":false,
                    "type": "metafilter",
                    "properties": {
                        "operator": "$and",
                        "conditions": [
                            {
                                "type": "filter",
                                "target": "<mapping:user-applications-status>",
                                "value": "submitted",
                                "operator": "$eq"
                            },
                            {
                                "operator": "$gte",
                                "value": "-1m",
                                "type": "filter",
                                "target": "<mapping:user-applications-submitted-time>"
                            },
                            {
                                "operator": "$lte",
                                "value": "-0m",
                                "type": "filter",
                                "target": "<mapping:user-applications-submitted-time>"
                            }
                        ]
                    }
                }
            }
        }
    }
}

Expected Response:
Status 200
{
    "data": [
        {
            "id": "611bf5aabd86ae7914",
            "First Name": "Molly",
            "Application Root": [
                {
                    "Application - Major": "client.major.3461"
                },
                {
                    "Application - Major": "client.major.109423"
                },
                {
                    "Application - Major": "client.major.5934"
                },
                {
                    "Application - Major": ""
                }
            ]
        },
        {
            "id": "6369ba9c467d0b22c8",
            "First Name": "Amber",
            "Application Root": [
                {
                    "Application - Major": ""
                },
                {
                    "Application - Major": "client.major.4470"
                },
                {
                    "Application - Major": "client.major.5934"
                }
            ]
        },
        {
            "id": "64d3a8520106152a1a03c",
            "First Name": "Sagar",
            "Application Root": [
                {
                    "Application - Major": "client.major.130260"
                }
            ]
        }
    ],
    "meta": {
        "count": 3
    }
}