POST/ product-events/ import/
Bulk product events import
You can import your product events from CSV files using REST API. The CSV file requires the usage of standardized attribute names for the header row, or you can use column mapping to map your custom column names. You can check the progress of your import with a GET request.
Maximum file size: 400MB
Preparing the file
For the columns you can use for product events, the required ones and how to format values, see How to Import Product Events from CSV/XLSX and CSV/XLSX Import Formatting Rules.
Parameters
| Parameter | Description |
|---|---|
| separator | Allows to choose separator type in CSV file during import. Available options: comma (default), tab, semicolon. Example usage: ?separator=semicolon |
Attributes
Optional unless marked required
- input_file
- A valid CSV file
- column_mapping
- Optional parameter to map CSV column names to different field names during import. Example:
{"product": "product_id", "EVENT": "event_type"}
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/product-events/import/?trigger_automations=false" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-F "input_file=@path/to/file.csv"
// file: a File from an <input type="file">, or a Blob
const form = new FormData();
form.append("input_file", file);
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/product-events/import/?trigger_automations=false",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
},
body: form,
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/product-events/import/?trigger_automations=false",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
],
CURLOPT_POSTFIELDS => [
"input_file" => new CURLFile("path/to/file.csv", "text/csv"),
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/product-events/import/?trigger_automations=false",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
files={"input_file": open("path/to/file.csv", "rb")},
)
print(response.json())
Response examples
- 200 OK
{"success": true,"data": {"import_id": "186dd245-475c-4a18-ba3e-046ad8fd3585"}}Response fields
Fields returned in the 200 OK response body.
- success
truewhen the file was accepted; the import itself runs in the background.- data
- A valid json object with additional data.
- data.
import_id
- data.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.