# User activities import

Bulk import [user activities](https://developer.mediarithmics.io/user-points/user-activities#user-activity-object) to insert user activities that happened outside of [real-time tracking](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking). Those activities usually are offline activities, like store visits or store purchases, but you can adapt it to your use cases.

{% hint style="warning" %}
Activities imported through bulk import don't go through the [activity processing pipeline](https://developer.mediarithmics.io/data-streams/real-time-user-tracking#the-processing-pipeline). You shouldn't use this feature if you intend to do conversion detection or automation activation. Your [activity analyzers](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking/activity-analyzers) also won't process those activities, and you should format exactly how you expect them to be stored by mediarithmics.
{% endhint %}

## How-to

Use the [bulk import ](https://developer.mediarithmics.io/data-streams/data-ingestion/bulk-processing)endpoints to create a [document import](https://developer.mediarithmics.io/data-streams/data-ingestion/bulk-processing/..#document-import) with the`USER_ACTIVITY`document type and `APPLICATION_X_NDJSON` mime type. Only `ndjson` data is supported for user activities.

Then, create an[ execution ](https://developer.mediarithmics.io/data-streams/data-ingestion/bulk-processing/..#create-an-execution)with your user activities formatted in `ndjson` .

### 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_ACTIVITY",
	"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 '{ "$user_agent_id": "<USER_AGENT_ID>", "$type":"TOUCH","$session_status":"NO_SESSION","$ts":<TIMESTAMP>,"$events":[{"$event_name":"$email_mapping","$ts":<TIMESTAMP>,"$properties":{}}]}'
```

{% hint style="success" %}
You can, of course, upload multiple activities at once. Note the uploaded data is in `ndjson` and not `json`. That means the different activities are not separated by commas, but by a line separator `\n`
{% endhint %}
