For the complete documentation index, see llms.txt. This page is also available as Markdown.

Import user choices

Upsert or delete user choices in bulk with a USER_CHOICE document import.

Your goal

Load consent decisions into the datamart from a file, so the platform can apply them.

Expected outcome

UserChoice records created or updated for the users in your file, against the processing activities you reference.

This page is the command reference for the USER_CHOICE document import. For the wider job - where consent comes from, which route to use, and what has to exist first - see Import user consent.

Run a user choice import

1

Create the document import

Document type USER_CHOICE, mime type APPLICATION_X_NDJSON. Only ndjson is supported for user choices.

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>"
}'
2

Create an execution with your choice commands

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": "UPSERT",
        "compartment_id": "<COMPARTMENT_ID>",
        "user_account_id": "<USER_ACCOUNT_ID>",
        "force_replace": true,
        "user_choice": {
              "$processing_id": "<PROCESSING_ID>",
              "$choice_ts": "<CHOICE_TS>"
        }
      }'
3

Read the result

Check total_success, total_failure, and the error file. See reading the result.

The user choice command

Field
Type
Description

operation

Enum

UPSERT or DELETE.

compartment_id

String, optional

The compartment ID, as an identifier together with user_account_id.

user_account_id

String, optional

The account ID, as an identifier together with compartment_id.

email_hash

String, optional

The email hash, as an identifier.

user_agent_id

String, optional

The device technical identifier, as an identifier.

force_replace

Boolean

Mandatory when the operation is UPSERT. true replaces the user choice entirely with the object in user_choice. false merges that object into the existing choice.

user_choice

JSON object

Mandatory when the operation is UPSERT. The user choice object.

Inside user_choice:

  • $processing_id is always mandatory.

  • $choice_ts is mandatory when the operation is UPSERT.

Verify

  • The execution reports the expected success count.

  • A user choice can be read back for a test user - see Server-side events for the read endpoints.

  • The processing ID referenced exists as a processing activity.

Last updated

Was this helpful?