Sending documents
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.
Let's unpack this:
for
document_type
we have chosenUSER_ACTIVITY
in order to send user activities. Other valid values would beUSER_SEGMENT
,USER_PROFILE
,USER_IDENTIFIERS_ASSOCIATION_DECLARATIONS
mime_type
should match the type of format you will use for your data. Valid values areAPPLICATION_X_NDJSON
(if you will send data in aNDJSON
format) orTEXT_CSV
(if you format your data as comma-separated values). In the case ofUSER_ACTIVITY
, onlyNDJSON
is validencoding
is the encoding of the data that will be importedname
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:
Let's take note of provided the <DOCUMENT_IMPORT_ID>
.
Create a document import execution
Once we have created our document import, we can start creating executions (i.e. actually sending data!).
Let's send some store visits. First, we will prepare our JSON
file:
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.
The response should look like this:
Take note of the <DOCUMENTATION_IMPORT_EXECUTION_ID>
here, you will need it if you want to check the status of your execution.
Checking your document import execution status
You can check the status of your execution with this simple request:
The response should look like this:
Notice the PENDING
status: after a while, the execution will be processed and if you check again, status will be changed to RUNNING
then to SUCCEEDED
.
Last updated
Was this helpful?