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.
Run a user choice import
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>"
}'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>"
}
}'Read the result
Check total_success, total_failure, and the error file. See reading the result.
The user choice command
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_idis always mandatory.$choice_tsis mandatory when the operation isUPSERT.
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.
Related pages
Last updated
Was this helpful?