curl --request POST \
--url https://apiweb.mile.app/api/v3/analytics/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"timeRange": {
"preset": "last_30d"
},
"hubIds": [
"6650c2a1f3b9e4001c7d2c30"
],
"queries": [
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E",
"widgetId": "66f9a1c2e4b0a7d3c1f20b01",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "dateHistogram",
"field": "startTime",
"granularity": "day",
"gapFill": "null"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "flow",
"limit": 10
}
],
"filters": [],
"sort": [
{
"by": "m1",
"direction": "desc"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"timeRange": {
"from": "2026-08-01",
"to": "2026-09-15"
},
"measures": [
{
"id": "m1",
"fn": "avg",
"field": "travelDuration"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "cardinality",
"field": "assignee"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "count",
"fn": "count"
}
],
"dimensions": [
{
"id": "cell",
"kind": "geoGrid",
"field": "doneCoordinate",
"precision": 3
}
],
"filters": []
}
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v3/analytics/query"
payload = {
"timeRange": { "preset": "last_30d" },
"hubIds": ["6650c2a1f3b9e4001c7d2c30"],
"queries": [
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E",
"widgetId": "66f9a1c2e4b0a7d3c1f20b01",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "dateHistogram",
"field": "startTime",
"granularity": "day",
"gapFill": "null"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "flow",
"limit": 10
}
],
"filters": [],
"sort": [
{
"by": "m1",
"direction": "desc"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"timeRange": {
"from": "2026-08-01",
"to": "2026-09-15"
},
"measures": [
{
"id": "m1",
"fn": "avg",
"field": "travelDuration"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "cardinality",
"field": "assignee"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "count",
"fn": "count"
}
],
"dimensions": [
{
"id": "cell",
"kind": "geoGrid",
"field": "doneCoordinate",
"precision": 3
}
],
"filters": []
}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
timeRange: {preset: 'last_30d'},
hubIds: ['6650c2a1f3b9e4001c7d2c30'],
queries: [
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E',
widgetId: '66f9a1c2e4b0a7d3c1f20b01',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'startTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [
{
id: 'd1',
kind: 'dateHistogram',
field: 'startTime',
granularity: 'day',
gapFill: 'null'
}
],
filters: [{id: 'f1', field: 'status', operator: 'eq', value: 'DONE'}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'startTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'flow', limit: 10}],
filters: [],
sort: [{by: 'm1', direction: 'desc'}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
timeRange: {from: '2026-08-01', to: '2026-09-15'},
measures: [{id: 'm1', fn: 'avg', field: 'travelDuration'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'startTime',
measures: [{id: 'm1', fn: 'cardinality', field: 'assignee'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total',
spec: {
specVersion: 1,
dataSourceId: 'user',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'count', fn: 'count'}],
dimensions: [{id: 'cell', kind: 'geoGrid', field: 'doneCoordinate', precision: 3}],
filters: []
}
}
]
})
};
fetch('https://apiweb.mile.app/api/v3/analytics/query', 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/analytics/query",
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([
'timeRange' => [
'preset' => 'last_30d'
],
'hubIds' => [
'6650c2a1f3b9e4001c7d2c30'
],
'queries' => [
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E',
'widgetId' => '66f9a1c2e4b0a7d3c1f20b01',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'startTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'dateHistogram',
'field' => 'startTime',
'granularity' => 'day',
'gapFill' => 'null'
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'eq',
'value' => 'DONE'
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'startTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'flow',
'limit' => 10
]
],
'filters' => [
],
'sort' => [
[
'by' => 'm1',
'direction' => 'desc'
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'timeRange' => [
'from' => '2026-08-01',
'to' => '2026-09-15'
],
'measures' => [
[
'id' => 'm1',
'fn' => 'avg',
'field' => 'travelDuration'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'startTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'cardinality',
'field' => 'assignee'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'user',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'count',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'cell',
'kind' => 'geoGrid',
'field' => 'doneCoordinate',
'precision' => 3
]
],
'filters' => [
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://apiweb.mile.app/api/v3/analytics/query"
payload := strings.NewReader("{\n \"timeRange\": {\n \"preset\": \"last_30d\"\n },\n \"hubIds\": [\n \"6650c2a1f3b9e4001c7d2c30\"\n ],\n \"queries\": [\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E\",\n \"widgetId\": \"66f9a1c2e4b0a7d3c1f20b01\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"dateHistogram\",\n \"field\": \"startTime\",\n \"granularity\": \"day\",\n \"gapFill\": \"null\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"flow\",\n \"limit\": 10\n }\n ],\n \"filters\": [],\n \"sort\": [\n {\n \"by\": \"m1\",\n \"direction\": \"desc\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"timeRange\": {\n \"from\": \"2026-08-01\",\n \"to\": \"2026-09-15\"\n },\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avg\",\n \"field\": \"travelDuration\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"cardinality\",\n \"field\": \"assignee\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"user\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"count\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"cell\",\n \"kind\": \"geoGrid\",\n \"field\": \"doneCoordinate\",\n \"precision\": 3\n }\n ],\n \"filters\": []\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://apiweb.mile.app/api/v3/analytics/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"timeRange\": {\n \"preset\": \"last_30d\"\n },\n \"hubIds\": [\n \"6650c2a1f3b9e4001c7d2c30\"\n ],\n \"queries\": [\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E\",\n \"widgetId\": \"66f9a1c2e4b0a7d3c1f20b01\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"dateHistogram\",\n \"field\": \"startTime\",\n \"granularity\": \"day\",\n \"gapFill\": \"null\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"flow\",\n \"limit\": 10\n }\n ],\n \"filters\": [],\n \"sort\": [\n {\n \"by\": \"m1\",\n \"direction\": \"desc\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"timeRange\": {\n \"from\": \"2026-08-01\",\n \"to\": \"2026-09-15\"\n },\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avg\",\n \"field\": \"travelDuration\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"cardinality\",\n \"field\": \"assignee\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"user\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"count\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"cell\",\n \"kind\": \"geoGrid\",\n \"field\": \"doneCoordinate\",\n \"precision\": 3\n }\n ],\n \"filters\": []\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/analytics/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"timeRange\": {\n \"preset\": \"last_30d\"\n },\n \"hubIds\": [\n \"6650c2a1f3b9e4001c7d2c30\"\n ],\n \"queries\": [\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E\",\n \"widgetId\": \"66f9a1c2e4b0a7d3c1f20b01\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"dateHistogram\",\n \"field\": \"startTime\",\n \"granularity\": \"day\",\n \"gapFill\": \"null\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"flow\",\n \"limit\": 10\n }\n ],\n \"filters\": [],\n \"sort\": [\n {\n \"by\": \"m1\",\n \"direction\": \"desc\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"timeRange\": {\n \"from\": \"2026-08-01\",\n \"to\": \"2026-09-15\"\n },\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avg\",\n \"field\": \"travelDuration\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"cardinality\",\n \"field\": \"assignee\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"user\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"count\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"cell\",\n \"kind\": \"geoGrid\",\n \"field\": \"doneCoordinate\",\n \"precision\": 3\n }\n ],\n \"filters\": []\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"specVersion": 1,
"resolvedTimeRange": {
"from": "2026-09-01T00:00:00+07:00",
"to": "2026-09-30T23:59:59+07:00",
"timezone": "Asia/Jakarta",
"preset": "last_30d"
},
"results": [
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E",
"status": "ok",
"widgetId": "66f9a1c2e4b0a7d3c1f20b01",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "startTime",
"unit": null
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"2026-09-01T00:00:00+07:00",
212
],
[
"2026-09-02T00:00:00+07:00",
null
],
[
"2026-09-03T00:00:00+07:00",
198
]
],
"meta": {
"bucketCount": 30,
"rowCount": 30,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 4
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "flow",
"unit": null
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"Delivery",
812
],
[
"Pickup",
140
]
],
"meta": {
"bucketCount": 2,
"rowCount": 2,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 3
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G",
"status": "error",
"error": {
"code": "time_range_exceeded",
"message": "This widget asked for a 46 day range, but the limit is 31 days. Narrow the range rather than expecting a trimmed result."
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active",
"status": "ok",
"columns": [
{
"id": "m1",
"role": "measure",
"fn": "cardinality",
"field": "assignee",
"unit": "plain"
}
],
"rows": [
[
37
]
],
"meta": {
"bucketCount": 1,
"rowCount": 1,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 2
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total",
"status": "ok",
"columns": [
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
52
]
],
"meta": {
"bucketCount": 1,
"rowCount": 1,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 1
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J",
"status": "ok",
"columns": [
{
"id": "lat",
"role": "dimension",
"field": "doneCoordinate",
"unit": "latitude"
},
{
"id": "lng",
"role": "dimension",
"field": "doneCoordinate",
"unit": "longitude"
},
{
"id": "count",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
-6.2,
106.817,
318
],
[
-6.914,
107.609,
201
]
],
"meta": {
"scanned": 519,
"scanCap": 10000,
"scanTruncated": false,
"parsed": 519,
"skipped": 0,
"returned": 2,
"cellCap": 5000,
"cellTruncated": false,
"precision": 3
}
}
]
}{
"status": false,
"message": "Unauthenticated.",
"failedCode": "auth-034"
}{
"status": false,
"message": "You do not have access to hub(s): 6650c2a1f3b9e4001c7d2c31.",
"error": {
"code": "hub_not_allowed",
"message": "You do not have access to hub(s): 6650c2a1f3b9e4001c7d2c31."
}
}{
"status": false,
"message": "This request carries 14 queries, but the limit is 12.",
"error": {
"code": "batch_too_large",
"message": "This request carries 14 queries, but the limit is 12."
}
}{
"status": false,
"message": "Too Many Attempts.",
"failedCode": "sys-036"
}Run analytics query
Runs a batch of 1 to 12 query specs and returns a columns and rows table for each item. The server applies the caller’s organization and hub scope. A malformed spec fails the whole request (422), while a cost limit or engine failure fails only that item inside a 200 response. Rate-limited to 60 requests per minute per user. See the Dashboard overview for time ranges, limits and item statuses.
curl --request POST \
--url https://apiweb.mile.app/api/v3/analytics/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"timeRange": {
"preset": "last_30d"
},
"hubIds": [
"6650c2a1f3b9e4001c7d2c30"
],
"queries": [
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E",
"widgetId": "66f9a1c2e4b0a7d3c1f20b01",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "dateHistogram",
"field": "startTime",
"granularity": "day",
"gapFill": "null"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "flow",
"limit": 10
}
],
"filters": [],
"sort": [
{
"by": "m1",
"direction": "desc"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"timeRange": {
"from": "2026-08-01",
"to": "2026-09-15"
},
"measures": [
{
"id": "m1",
"fn": "avg",
"field": "travelDuration"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "cardinality",
"field": "assignee"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "count",
"fn": "count"
}
],
"dimensions": [
{
"id": "cell",
"kind": "geoGrid",
"field": "doneCoordinate",
"precision": 3
}
],
"filters": []
}
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v3/analytics/query"
payload = {
"timeRange": { "preset": "last_30d" },
"hubIds": ["6650c2a1f3b9e4001c7d2c30"],
"queries": [
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E",
"widgetId": "66f9a1c2e4b0a7d3c1f20b01",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "dateHistogram",
"field": "startTime",
"granularity": "day",
"gapFill": "null"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "flow",
"limit": 10
}
],
"filters": [],
"sort": [
{
"by": "m1",
"direction": "desc"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"timeRange": {
"from": "2026-08-01",
"to": "2026-09-15"
},
"measures": [
{
"id": "m1",
"fn": "avg",
"field": "travelDuration"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "startTime",
"measures": [
{
"id": "m1",
"fn": "cardinality",
"field": "assignee"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "count",
"fn": "count"
}
],
"dimensions": [
{
"id": "cell",
"kind": "geoGrid",
"field": "doneCoordinate",
"precision": 3
}
],
"filters": []
}
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
timeRange: {preset: 'last_30d'},
hubIds: ['6650c2a1f3b9e4001c7d2c30'],
queries: [
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E',
widgetId: '66f9a1c2e4b0a7d3c1f20b01',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'startTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [
{
id: 'd1',
kind: 'dateHistogram',
field: 'startTime',
granularity: 'day',
gapFill: 'null'
}
],
filters: [{id: 'f1', field: 'status', operator: 'eq', value: 'DONE'}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'startTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'flow', limit: 10}],
filters: [],
sort: [{by: 'm1', direction: 'desc'}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
timeRange: {from: '2026-08-01', to: '2026-09-15'},
measures: [{id: 'm1', fn: 'avg', field: 'travelDuration'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'startTime',
measures: [{id: 'm1', fn: 'cardinality', field: 'assignee'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total',
spec: {
specVersion: 1,
dataSourceId: 'user',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'count', fn: 'count'}],
dimensions: [{id: 'cell', kind: 'geoGrid', field: 'doneCoordinate', precision: 3}],
filters: []
}
}
]
})
};
fetch('https://apiweb.mile.app/api/v3/analytics/query', 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/analytics/query",
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([
'timeRange' => [
'preset' => 'last_30d'
],
'hubIds' => [
'6650c2a1f3b9e4001c7d2c30'
],
'queries' => [
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E',
'widgetId' => '66f9a1c2e4b0a7d3c1f20b01',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'startTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'dateHistogram',
'field' => 'startTime',
'granularity' => 'day',
'gapFill' => 'null'
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'eq',
'value' => 'DONE'
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'startTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'flow',
'limit' => 10
]
],
'filters' => [
],
'sort' => [
[
'by' => 'm1',
'direction' => 'desc'
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'timeRange' => [
'from' => '2026-08-01',
'to' => '2026-09-15'
],
'measures' => [
[
'id' => 'm1',
'fn' => 'avg',
'field' => 'travelDuration'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'startTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'cardinality',
'field' => 'assignee'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'user',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'count',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'cell',
'kind' => 'geoGrid',
'field' => 'doneCoordinate',
'precision' => 3
]
],
'filters' => [
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://apiweb.mile.app/api/v3/analytics/query"
payload := strings.NewReader("{\n \"timeRange\": {\n \"preset\": \"last_30d\"\n },\n \"hubIds\": [\n \"6650c2a1f3b9e4001c7d2c30\"\n ],\n \"queries\": [\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E\",\n \"widgetId\": \"66f9a1c2e4b0a7d3c1f20b01\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"dateHistogram\",\n \"field\": \"startTime\",\n \"granularity\": \"day\",\n \"gapFill\": \"null\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"flow\",\n \"limit\": 10\n }\n ],\n \"filters\": [],\n \"sort\": [\n {\n \"by\": \"m1\",\n \"direction\": \"desc\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"timeRange\": {\n \"from\": \"2026-08-01\",\n \"to\": \"2026-09-15\"\n },\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avg\",\n \"field\": \"travelDuration\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"cardinality\",\n \"field\": \"assignee\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"user\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"count\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"cell\",\n \"kind\": \"geoGrid\",\n \"field\": \"doneCoordinate\",\n \"precision\": 3\n }\n ],\n \"filters\": []\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://apiweb.mile.app/api/v3/analytics/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"timeRange\": {\n \"preset\": \"last_30d\"\n },\n \"hubIds\": [\n \"6650c2a1f3b9e4001c7d2c30\"\n ],\n \"queries\": [\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E\",\n \"widgetId\": \"66f9a1c2e4b0a7d3c1f20b01\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"dateHistogram\",\n \"field\": \"startTime\",\n \"granularity\": \"day\",\n \"gapFill\": \"null\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"flow\",\n \"limit\": 10\n }\n ],\n \"filters\": [],\n \"sort\": [\n {\n \"by\": \"m1\",\n \"direction\": \"desc\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"timeRange\": {\n \"from\": \"2026-08-01\",\n \"to\": \"2026-09-15\"\n },\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avg\",\n \"field\": \"travelDuration\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"cardinality\",\n \"field\": \"assignee\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"user\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"count\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"cell\",\n \"kind\": \"geoGrid\",\n \"field\": \"doneCoordinate\",\n \"precision\": 3\n }\n ],\n \"filters\": []\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/analytics/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"timeRange\": {\n \"preset\": \"last_30d\"\n },\n \"hubIds\": [\n \"6650c2a1f3b9e4001c7d2c30\"\n ],\n \"queries\": [\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E\",\n \"widgetId\": \"66f9a1c2e4b0a7d3c1f20b01\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"dateHistogram\",\n \"field\": \"startTime\",\n \"granularity\": \"day\",\n \"gapFill\": \"null\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"flow\",\n \"limit\": 10\n }\n ],\n \"filters\": [],\n \"sort\": [\n {\n \"by\": \"m1\",\n \"direction\": \"desc\"\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"timeRange\": {\n \"from\": \"2026-08-01\",\n \"to\": \"2026-09-15\"\n },\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avg\",\n \"field\": \"travelDuration\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"startTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"cardinality\",\n \"field\": \"assignee\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"user\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"count\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"cell\",\n \"kind\": \"geoGrid\",\n \"field\": \"doneCoordinate\",\n \"precision\": 3\n }\n ],\n \"filters\": []\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"specVersion": 1,
"resolvedTimeRange": {
"from": "2026-09-01T00:00:00+07:00",
"to": "2026-09-30T23:59:59+07:00",
"timezone": "Asia/Jakarta",
"preset": "last_30d"
},
"results": [
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3E",
"status": "ok",
"widgetId": "66f9a1c2e4b0a7d3c1f20b01",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "startTime",
"unit": null
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"2026-09-01T00:00:00+07:00",
212
],
[
"2026-09-02T00:00:00+07:00",
null
],
[
"2026-09-03T00:00:00+07:00",
198
]
],
"meta": {
"bucketCount": 30,
"rowCount": 30,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 4
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3F",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "flow",
"unit": null
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"Delivery",
812
],
[
"Pickup",
140
]
],
"meta": {
"bucketCount": 2,
"rowCount": 2,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 3
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3G",
"status": "error",
"error": {
"code": "time_range_exceeded",
"message": "This widget asked for a 46 day range, but the limit is 31 days. Narrow the range rather than expecting a trimmed result."
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#active",
"status": "ok",
"columns": [
{
"id": "m1",
"role": "measure",
"fn": "cardinality",
"field": "assignee",
"unit": "plain"
}
],
"rows": [
[
37
]
],
"meta": {
"bucketCount": 1,
"rowCount": 1,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 2
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3H#total",
"status": "ok",
"columns": [
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
52
]
],
"meta": {
"bucketCount": 1,
"rowCount": 1,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 1
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3J",
"status": "ok",
"columns": [
{
"id": "lat",
"role": "dimension",
"field": "doneCoordinate",
"unit": "latitude"
},
{
"id": "lng",
"role": "dimension",
"field": "doneCoordinate",
"unit": "longitude"
},
{
"id": "count",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
-6.2,
106.817,
318
],
[
-6.914,
107.609,
201
]
],
"meta": {
"scanned": 519,
"scanCap": 10000,
"scanTruncated": false,
"parsed": 519,
"skipped": 0,
"returned": 2,
"cellCap": 5000,
"cellTruncated": false,
"precision": 3
}
}
]
}{
"status": false,
"message": "Unauthenticated.",
"failedCode": "auth-034"
}{
"status": false,
"message": "You do not have access to hub(s): 6650c2a1f3b9e4001c7d2c31.",
"error": {
"code": "hub_not_allowed",
"message": "You do not have access to hub(s): 6650c2a1f3b9e4001c7d2c31."
}
}{
"status": false,
"message": "This request carries 14 queries, but the limit is 12.",
"error": {
"code": "batch_too_large",
"message": "This request carries 14 queries, but the limit is 12."
}
}{
"status": false,
"message": "Too Many Attempts.",
"failedCode": "sys-036"
}Authorizations
Use a valid Bearer token to authenticate.
Body
Batch of up to 12 queries
1 - 12 elementsShow child attributes
Show child attributes
Either preset, or both from and to as calendar dates YYYY-MM-DD (anything else, including 2026-02-30, relative words and datetimes, is 422 time_range_invalid), widened to whole days on the batch utcOffset. Maximum 31 days, inclusive.
Show child attributes
Show child attributes
Narrow to these hubs: a list of 24-character hex hub ids (anything else is 422 hub_ids_invalid), each one of the caller's hubs (otherwise 403 hub_not_allowed). Omitted or [] = every hub the caller belongs to; a caller with no hub sees no rows.
Optional. The UTC offset (±HH:MM) day boundaries and dateHistogram buckets are cut on. Absent = the organization calendar (Asia/Jakarta, +07:00). Anything else is 422 utc_offset_invalid.
^[+-]\d{2}:\d{2}$"+07:00"
Request the compiled engine query (internal accounts only; ignored otherwise)
debug Accepted at batch level; the spec-level value is the one validated