/api/public/exports/Export data
You can export data from specific section (People/Deals/etc.) or campaign logs (Email deliveries/clicks or SMS deliveries) based on segment (for sections) as well as based on date of campaign sending or user's click/opening/unsubscription.
| Attributes | Type | Required | Description |
|---|---|---|---|
| segment | integer | yes / no | A unique identifier for the segment of People/Deals/etc. |
| date_from | date (Y-m-d) | no | A date from which the data will be returned (format: Y-m-d, e.g.,
2024-01-15). |
| date_to | date (Y-m-d) | no | A date to which the data will be returned (format: Y-m-d,
e.g.,2024-01-31). |
| filter_by | array | no | Array of email action types to filter by, based on the
|
| event_id | integer | yes / no | ID of the specific event. |
| deal_id | integer | no | ID of the specific deal. |
| type | string | yes | Type of the exported data.
|
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST
"https://<your_app_subdomain>.user.com/api/public/exports/"
-H 'authorization: Token <your_64_char_api_key>'
-H 'content-type: application/json'
-H "Accept: */*; version=2"
-d '{
"type": "people",
"segment": 1
}'
var data = JSON.stringify({
"type": "people",
"segment": 1
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.#### ResponseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/exports/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/exports/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n\t\"type\": \"people\",\n\t\"segment\": 12\n}",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/exports/"
payload = "{\n\t\"type\": \"people\",\n\t\"segment\": 12\n}"
headers = {
'authorization': "Token <your_64_char_api_key>",
'Accept': "*/*; version=2",
'content-type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Response
{
"filename": "d1d69214-d07f-418f-bd85-27c49fd3398f.csv"
}
Email logs export example
- CURL
- JavaScript
- PHP
- Python
curl -X POST
"https://<your_app_subdomain>.user.com/api/public/exports/"
-H 'authorization: Token <your_64_char_api_key>'
-H 'content-type: application/json'
-H "Accept: */*; version=2"
-d '{
"type": "email_delivery_logs",
"date_from": "2024-01-01",
"date_to": "2024-01-31",
"filter_by": ["sent_at", "opened_at"]
}'
var data = JSON.stringify({
type: "email_delivery_logs",
date_from: "2024-01-01",
date_to: "2024-01-31",
filter_by: ["sent_at", "opened_at"],
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/exports/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/exports/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n\t\"type\": \"email_delivery_logs\",\n\t\"date_from\": \"2024-01-01\",\n\t\"date_to\": \"2024-01-31\",\n\t\"filter_by\": [\"sent_at\", \"opened_at\"]\n}",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/exports/"
payload = "{\n\t\"type\": \"email_delivery_logs\",\n\t\"date_from\": \"2024-01-01\",\n\t\"date_to\": \"2024-01-31\",\n\t\"filter_by\": [\"sent_at\", \"opened_at\"]\n}"
headers = {
'authorization': "Token <your_64_char_api_key>",
'Accept': "*/*; version=2",
'content-type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)