Skip to main content
POST
/
api
/
v1
/
analytics
/
exports
Trigger an Export Job
curl --request POST \
  --url https://appex.userpilot.io/api/v1/analytics/exports \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "from": "<string>",
  "to": "<string>",
  "emails": [
    "<string>"
  ],
  "event_type": [
    "<string>"
  ],
  "user_id": [
    "<string>"
  ],
  "company_id": [
    "<string>"
  ],
  "segment_id": "<string>",
  "exclusions": "<string>"
}
'
import requests

url = "https://appex.userpilot.io/api/v1/analytics/exports"

payload = {
"from": "<string>",
"to": "<string>",
"emails": ["<string>"],
"event_type": ["<string>"],
"user_id": ["<string>"],
"company_id": ["<string>"],
"segment_id": "<string>",
"exclusions": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
to: '<string>',
emails: ['<string>'],
event_type: ['<string>'],
user_id: ['<string>'],
company_id: ['<string>'],
segment_id: '<string>',
exclusions: '<string>'
})
};

fetch('https://appex.userpilot.io/api/v1/analytics/exports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://appex.userpilot.io/api/v1/analytics/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 => json_encode([
'from' => '<string>',
'to' => '<string>',
'emails' => [
'<string>'
],
'event_type' => [
'<string>'
],
'user_id' => [
'<string>'
],
'company_id' => [
'<string>'
],
'segment_id' => '<string>',
'exclusions' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://appex.userpilot.io/api/v1/analytics/exports"

payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": \"<string>\",\n \"emails\": [\n \"<string>\"\n ],\n \"event_type\": [\n \"<string>\"\n ],\n \"user_id\": [\n \"<string>\"\n ],\n \"company_id\": [\n \"<string>\"\n ],\n \"segment_id\": \"<string>\",\n \"exclusions\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://appex.userpilot.io/api/v1/analytics/exports")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": \"<string>\",\n \"emails\": [\n \"<string>\"\n ],\n \"event_type\": [\n \"<string>\"\n ],\n \"user_id\": [\n \"<string>\"\n ],\n \"company_id\": [\n \"<string>\"\n ],\n \"segment_id\": \"<string>\",\n \"exclusions\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://appex.userpilot.io/api/v1/analytics/exports")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"<string>\",\n \"to\": \"<string>\",\n \"emails\": [\n \"<string>\"\n ],\n \"event_type\": [\n \"<string>\"\n ],\n \"user_id\": [\n \"<string>\"\n ],\n \"company_id\": [\n \"<string>\"\n ],\n \"segment_id\": \"<string>\",\n \"exclusions\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "environment_app_token": "NX-RE213S2",
  "environment_name": "production",
  "job_id": "123e4567-e89b-12d3-a456-426614174000",
  "links": "<string>",
  "start_time": "<string>"
}
{
"errors": [
{
"details": "<string>",
"error": "<string>",
"error_code": "<string>",
"message": "<string>"
}
]
}
{
"errors": [
{
"details": "<string>",
"error": "<string>",
"error_code": "<string>",
"message": "<string>"
}
]
}

Headers

Content-Type
string

The content type of the request body. Must be application/json.

Accept
string

The content type of the response body. Must be application/json.

Authorization
string
required

API authentication token in the format: Token {{API_KEY}}. Obtain your API key from the Userpilot Environment Settings.

Body

application/json
from
string
to
string
emails
string[]
event_type
string[]
user_id
string[]
company_id
string[]
segment_id
string
format
enum<string>
Available options:
avro,
csv,
ndjson,
parquet
exclusions
string

Response

Created - Export job successfully created

environment_app_token
string

The app token of the environment.

Example:

"NX-RE213S2"

environment_name
string

The name of the environment.

Example:

"production"

job_id
string

The ID of the export job.

Example:

"123e4567-e89b-12d3-a456-426614174000"

The links to the export job.

start_time
string

The start time of the export job.