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:

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