Segments import

Use this feature to add or remove user points from segments.

How-to

  1. Use the bulk import endpoints to create a document import with theUSER_SEGMENTdocument type and APPLICATION_X_NDJSON or TEXT_CSV mime type.

  2. Create an execution with your user segment commands formatted in ndjson or csv depending on the mime type you chose.

User segment command

Each line in the uploaded file can have the following properties:

field

type

description

operation

Enum (Mandatory)

Either UPDATE or DELETE

compartment_id

String (Optional)

The Compartment ID acting as a user identifier in correlation with the user account ID

user_account_id

String (Optional)

The User Account ID acting as a user identifier in correlation with the user account ID.

email_hash

String (Optional)

The Email Hash acting as a user identifier.

user_agent_id

String (Optional)

The User Agent ID acting as a user identifier.

segment_id

String (Optional)

The Id of the segment in which the User is inserted/deleted.

segment_technical_name

String (Optional)

The technical name of the segment in which the User is inserted/deleted.

expiration_duration

Integer (Mandatory)

The number of minutes before the user will be removed from the segment. 0 means that the User will never leave the segment

expiration_ts

Number (Optional)

The timestamp of the expiration date of the User in the segment. A value of 0 means that the user will never leave the segment

data_bag

Escaped JSON String (Optional)

The data bag associated with the user/segment relationship

Example

# Create the document import
curl -X POST \
  https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
  -H 'Authorization: <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
	"document_type": "USER_SEGMENT",
	"mime_type": "APPLICATION_X_NDJSON",
	"encoding": "utf-8",
	"name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'
# Create the execution
curl -X POST \
  https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
  -H 'Authorization: <API_TOKEN>' \
  -H 'Content-Type: application/x-ndjson' \
  -d '{ 
        "operation": "UPDATE",
        "expiration_duration": <INTEGER>,
        "compartment_id": "<COMPARTMENT_ID>", 
        "user_account_id": "<USER_ACCOUNT_ID>",
        "segment_id": "<SEGMENT_ID"
      }'

You can have UPDATE and DELETE operations in the same file upload.

Please note, if not using csv, that the uploaded data is in ndjson and not json. That means the different profiles are not separated by commas, but by a line separator \n

Last updated