User choices import

Use this feature to UPSERT or DELETE user_choices in your datamart.

How-to

Use the bulk import endpoints to create a document import with theUSER_CHOICEdocument type and APPLICATION_X_NDJSON mime type. Only ndjson data is supported for user choices.

Then, create an execution with your user choice import commands formatted in ndjson .

User choice import 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_CHOICE",
	"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/1162/document_imports/<DOCUMENT_IMPORT_ID>/executions \
  -H 'Authorization: <API_TOKEN>' \
  -H 'Content-Type: application/x-ndjson' \
  -d '{ 
        "operation": "UPSERT",
        "compartment_id": "<COMPARTMENT_ID>", 
        "user_account_id": "<USER_ACCOUNT_ID>",
        "force_replace": true,
        "user_choice": {
              "$processing_id": "<PROCESSING_ID>",
              "$choice_ts": "<CHOICE_TS>"
        }
      }'

You can, of course, upload multiple user choices at once. Note the uploaded data is in ndjson format and not json. That means the different choices are not separated by commas, but by a line separator \n

When importing choices with identifiers, only one identifier is allowed per line. For example, you shouldn't specify the user agent ID if the Email Hash is already used in a line.

Last updated