> For the complete documentation index, see [llms.txt](https://developer.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.mediarithmics.io/data-ingestion/bulk-processing/imports/user_choices.md).

# User choices import

Use this feature to UPSERT or DELETE [user\_choices](/advanced-usages/data-privacy-compliance/user-choices.md) in your datamart.&#x20;

## How-to

Use the [bulk import ](/data-ingestion/bulk-processing.md)endpoints to create a [document import](/data-ingestion/bulk-processing.md#document-import) with the`USER_CHOICE`document type and `APPLICATION_X_NDJSON` mime type. Only `ndjson` data is supported for user choices.

Then, create an[ execution ](/data-ingestion/bulk-processing.md#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:

| field             | type                   | description                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| operation         | Enum                   | Either `UPSERT` or `DELETE`                                                                                                                                                                                                                                                                                                                                                                                                       |
| compartment\_id   | String (Optional)      | The Compartment ID, acting as a user [identifier ](/user-points.md#user-identifiers)in correlation with `user_account_id`                                                                                                                                                                                                                                                                                                         |
| user\_account\_id | String (Optional)      | The User Account ID, acting as an [identifier](/user-points/user-profiles.md#user-profile-object) in correlation with `compartment_id`                                                                                                                                                                                                                                                                                            |
| email\_hash       | String (Optional)      | The Email Hash, acting as an [identifier](/user-points.md#user-identifiers)                                                                                                                                                                                                                                                                                                                                                       |
| user\_agent\_id   | String (Optional)      | The User Agent ID, acting as an [identifier](/user-points.md#user-identifiers)                                                                                                                                                                                                                                                                                                                                                    |
| force\_replace    | Boolean (Optional)     | <p>Mandatory when the operation is <code>UPSERT</code>.<br><br>If true, then the User Choice will be completely replaced by the object passed in the <code>user\_choice</code> field.</p><p><br>If false, the object passed in the <code>user\_choice</code> field will be merged with the existing User Choice of the UserPoint.</p>                                                                                             |
| user\_choice      | JSON Object (Optional) | <p>Mandatory when operation is UPSERT. </p><p></p><p>This is a JSON Object representing the User Choice. </p><p>Please refer to the <a href="/advanced-usages/data-privacy-compliance/user-choices.md">User choices page</a> for more </p><p>information.</p><p></p><p>Note that the <code>$processing\_id</code> field is always mandatory, and <code>$choice\_ts</code> is mandatory when operation is <code>UPSERT</code>.</p> |

### Example

```bash
# 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>"
}'
```

```bash
# 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>"
        }
      }'
```

{% hint style="success" %}
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`
{% endhint %}

{% hint style="warning" %}
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.&#x20;
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.mediarithmics.io/data-ingestion/bulk-processing/imports/user_choices.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
