You'll first need to create a document import, then you'll be able to launch executions.
Create a document import
The first step if you want to use bulk imports is to create a document import. See this as creating a configuration for your imports of the same type.
Creating a document import is done with a simple request to POST /v1/datamarts//documents_imports. Let's create a document import for user activities that we will call "My user activity document import". You will need to replace <DATAMART_ID> with your datamart id (which can be found in the UI in Settings > Datamart > Datamarts) and <YOUR_API_TOKEN> with your authentication token.
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": "My user activity document import"
}'
Let's unpack this:
for document_type we have chosen USER_ACTIVITY in order to send user activities. Other valid values would be USER_SEGMENT, USER_PROFILE, USER_IDENTIFIERS_ASSOCIATION_DECLARATIONS
mime_type should match the type of format you will use for your data. Valid values are APPLICATION_X_NDJSON (if you will send data in a NDJSON format) or TEXT_CSV (if you format your data as comma-separated values). In the case of USER_ACTIVITY, only NDJSON is valid
encoding is the encoding of the data that will be imported
name is the name you want to give this document import
See the API documentation on this endpoint or our guide on document imports for more information on the other types of document.If everything went well, the response should look something like this:
Please check our guide on user activity imports for a complete explanation of all the properties in our payload.
Now we will convert our JSON file to NDJSON and send in the body of the following request. If you want to learn more about the NDJSON format, check out this site.
You will need to replace <DATAMART_ID> with your datamart id, <DOCUMENT_IMPORT_ID> with the document import id you got in the previous request and <YOUR_API_TOKEN> with your authentication token.
Please note that your Content-Type header must match the mime_type you set when creating the document import earlier.