Create new Segment

Create new Customer/Visitor segment

POST http://api.ants.tech/access/api/segment/create

Request

Body

  • segmentDisplay: Segment name

  • itemTypeId: Type to define the Customer segment or Visitor segment (-1003 for Customer segment, -1007 for Visitor segment)

  • conditions:

    • file_path: Path of the file, taken from the Upload API

    • file_name: File name saved on the CDP system, taken from the Upload API

    • original_file_name: File name when the user uploads, taken from the Upload API

    • extension: File extension, taken from Upload API

    • delimiter: Delimiter of the file, taken from the Upload API

    • method: Method to upload segment, value is:

      • create: When creating a new segment

    • criteria_logic: Matching method to update audiences, one of the following types

      • or: Just need to satisfy one of the mapping_fields conditions to update the audiences

      • and: All mapping_fields conditions must be met to update audiences

    • mapping_fields: Array of conditions to map the file header with BO attributes to update audiences, maximum 5 conditions

      • item_attribute_code: Attribute internal code of the BO

      • header_code: Header of the uploaded file, taken from the Upload API

      • header_index: Index of the uploaded file, taken from Upload API

      • operator: Condition for matching between header file and BO attribute, one of the following types

        • exactly: Same between header and attribute, used for datatype STRING

        • equals: Same between header and attribute, used for datatype NUMBER, DATETIME, BOOLEAN

        • not_equals: Not same between header and attribute, used for datatype NUMBER, DATETIME, BOOLEAN

  • computeSchedule: Segment's computation schedule

    • type: Segment calculation type, one of the following types

      • static: Calculate once when creating a Segment

      • dynamic: Calculate according to schedule, update audiences according to setup time

    • repeatType [optional]: Calculation type of type "dynamic", one of the following

      • none: Only counted once after creating Segment

      • hours: Recalculate segments in hours (1-24)

      • days: Recalculate by days (1-365)

      • weeks: Recalculate by week (1-52)

      • months: Recalculate by month (1-12)

    • repeatValue [optional]: Repeat value of repeatType (eg repeatValue = 5, repeatType = "hours", the segment will be recalculated every 5 hours)

    • repeatOnValue [optional]: Array containing a specific day or date to repeat (used when repeatType = "weeks" | "months")

    • repeatStartTime [optional]: Segment calculation start time

      • day: Calculation start date (format YYYY-MM-DD)

      • hour: Calculation start time (format HH:mm)

    • endTime [optional]: End time of Segment calculation

      • type: Type of endTime, one of the following types

        • none: Never ends

        • on_day: Ends at a specific time

        • after_num_running: Ends after running enough times

      • onDay [optional]: Value for type is "on_day"

        • day: End date (format YYYY-MM-DD)

        • hour: End time (format HH:mm)

      • numRunning [optional]: Value for type is "after_num_running"

  • shareAccess: Share permissions for other accounts to act on this segment

    • description: Description of shared access rights

    • is_public: Whether the segment is public or not (0 | 1)

    • public_role: Action permission for Segment, one of the following types

      • 2: Editor

      • 3: Viewer

    • list_access: List of users and action rights for the Segment

      • user_id: ID of the user

      • allow_edit: 1 | 0

      • allow_view: 1 | 0

      • allow_comment: 1 | 0

      • role: The user's role for the Segment, one of the following types

        • 1: Owner

        • 2: Editor

        • 3: Viewer

        • 4: Commenter

  • alertSetting: Setting notification when Segment calculation succeeds or fails

    • alertAccountIds: List of user IDs to receive notifications

    • alertScopes: Scope notifies when the calculation is complete

      • success: Array containing "email" | "app_push", notification when Segment calculation is successful

      • failure: Array containing "email" | "app_push", notification when Segment calculation fails

{
    "conditions": {
        "file_path": "/S3/cdp-import-export/import/segment/33167",
        "method": "replace",
        "file_name": "-1003_1600083836_1707120681099.csv",
        "extension": "csv",
        "delimiter": "\t",
        "mapping_fields": [
            {
                "item_attribute_code": "id",
                "operator": "exactly",
                "header_code": "id",
                "header_index": 0
            },
            {
                "item_attribute_code": "name",
                "operator": "exactly",
                "header_code": "message",
                "header_index": 5
            },
            {
                "item_attribute_code": "date_created",
                "operator": "equals",
                "header_code": "created_date",
                "header_index": 1
            },
            {
                "item_attribute_code": "phone",
                "operator": "exactly",
                "header_code": "from_user",
                "header_index": 2
            }
        ],
        "original_file_name": "test_upload.csv",
        "criteria_logic": "or"
    },
    "itemTypeId": -1003,
    "computeSchedule": {
        "type": "static",
        "repeatType": "none"
    },
    "segmentDisplay": "[dat] test upload 5",
    "shareAccess": {
        "description": "",
        "is_public": 0,
        "public_role": null,
        "list_access": [
            {
                "user_id": "1600080515",
                "allow_edit": 1,
                "allow_view": 1,
                "allow_comment": 1,
                "role": 1
            }
        ]
    },
    "alertSetting": {
        "alertAccountIds": [
            1600080515
        ],
        "alertScopes": {
            "success": [],
            "failure": [
                "email",
                "app_push"
            ]
        }
    }
}

Headers

Name
Description

Authorization*

Bearer <ACCESS_TOKEN>

Response

{
    "code": 200,
    "message": "Success",
    "data": {
        "meta": {
            "total": 1
        },
        "entries": [
            5546595
        ]
    },
    "duration": "0.915 ms"
}

Last updated