curl -X POST "https://apiweb.mile.app/api/v3/data/export?download=xlsx&dataTypeId=6422816ef6710f053056d812&fields=dataId,name,address&limit=100" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"curl -X POST "https://apiweb.mile.app/api/v3/data/export?download=xlsx&dataTypeId=6422816ef6710f053056d812&background=true" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"const axios = require('axios');
const exportDataSource = async () => {
try {
const response = await axios.post(
'https://apiweb.mile.app/api/v3/data/export',
null,
{
params: {
download: 'xlsx',
dataTypeId: '6422816ef6710f053056d812',
fields: 'dataId,name,address',
hubId: '63c63ab1b6972d3150348172',
limit: 100,
sortBy: 'createdTime',
sortOrder: 'desc'
},
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
console.log('Export completed:', response.data);
console.log('Download link:', response.data.data.link);
} catch (error) {
console.error('Export failed:', error.response?.data || error.message);
}
};
exportDataSource();import requests
url = "https://apiweb.mile.app/api/v3/data/export"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://apiweb.mile.app/api/v3/data/export', 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://apiweb.mile.app/api/v3/data/export",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://apiweb.mile.app/api/v3/data/export"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiweb.mile.app/api/v3/data/export")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/data/export")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": true,
"message": "Success",
"total_data_be": 10,
"last_id": "642282a259c3f74157368012",
"last_field": "address",
"data": {
"time": 1681194657,
"organizationId": "63d397ca8cb4d07e9d581c82",
"reportType": "data",
"link": "https://staticdev.mile.app/dev-mile/20230411/data_63d397ca8cb4d07e9d581c82_1681194657.xlsx",
"status": "Done"
}
}{
"status": false,
"message": "The download parameter is required."
}{
"status": false,
"message": "Unauthorized"
}{
"status": false,
"message": "You do not have permission to export data"
}{
"status": false,
"message": "Internal server error",
"error": {
"message": "<string>",
"file": "<string>",
"line_of_code": 123
}
}Export data source
Export data source records by applying specific filters. This endpoint supports exporting various data types defined in your organization with customizable field selection.
Export Modes:
- Direct Export (
background=false): Returns file immediately. Best for datasets < 10,000 records - Background Export (
background=true): Queued for processing. Monitor via GET /tasks/export-log. Best for large datasets
Supported Formats:
xlsx: Excel format (recommended for most use cases)json: JSON format (for programmatic processing)
Important Notes:
- Use
fieldsparameter to select specific columns for export - Filter by
dataTypeIdto export specific data type records - Maximum 1,000,000 records per export
- Export files are stored for 30 days
curl -X POST "https://apiweb.mile.app/api/v3/data/export?download=xlsx&dataTypeId=6422816ef6710f053056d812&fields=dataId,name,address&limit=100" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"curl -X POST "https://apiweb.mile.app/api/v3/data/export?download=xlsx&dataTypeId=6422816ef6710f053056d812&background=true" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"const axios = require('axios');
const exportDataSource = async () => {
try {
const response = await axios.post(
'https://apiweb.mile.app/api/v3/data/export',
null,
{
params: {
download: 'xlsx',
dataTypeId: '6422816ef6710f053056d812',
fields: 'dataId,name,address',
hubId: '63c63ab1b6972d3150348172',
limit: 100,
sortBy: 'createdTime',
sortOrder: 'desc'
},
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
console.log('Export completed:', response.data);
console.log('Download link:', response.data.data.link);
} catch (error) {
console.error('Export failed:', error.response?.data || error.message);
}
};
exportDataSource();import requests
url = "https://apiweb.mile.app/api/v3/data/export"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://apiweb.mile.app/api/v3/data/export', 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://apiweb.mile.app/api/v3/data/export",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://apiweb.mile.app/api/v3/data/export"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiweb.mile.app/api/v3/data/export")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/data/export")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": true,
"message": "Success",
"total_data_be": 10,
"last_id": "642282a259c3f74157368012",
"last_field": "address",
"data": {
"time": 1681194657,
"organizationId": "63d397ca8cb4d07e9d581c82",
"reportType": "data",
"link": "https://staticdev.mile.app/dev-mile/20230411/data_63d397ca8cb4d07e9d581c82_1681194657.xlsx",
"status": "Done"
}
}{
"status": false,
"message": "The download parameter is required."
}{
"status": false,
"message": "Unauthorized"
}{
"status": false,
"message": "You do not have permission to export data"
}{
"status": false,
"message": "Internal server error",
"error": {
"message": "<string>",
"file": "<string>",
"line_of_code": 123
}
}Query Parameters
If the user sets the background parameter to true, the export process will utilize background processing, and the results will be available at GET /tasks/export-log API. If the user sets the background parameter to false, the export process will run directly, and the results will be immediately available in the response.
Example: true.
Default: false
The identifier for the hub that generated by system. Use GET /hubs API to get the list of Hub IDs.
Example: 63c63ab1b6972d3150348172
The identifier for the dataType that generated by system. Use GET /data-types API to get the list of dataType IDs.
Example: 6422816ef6710f053056d812
Response
Success - Export completed or queued