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"
],
"utcOffset": "+07:00",
"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": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "avgDuration",
"field": "createdToDone"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "ageBucket",
"field": "createdTime",
"buckets": "age_default"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "in",
"value": [
"UNASSIGNED",
"ONGOING"
]
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "hourOfDay",
"field": "doneTime"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N",
"spec": {
"specVersion": 1,
"dataSourceId": "data:6ae211692fd5463064096512",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
],
"filters": []
}
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v3/analytics/query"
payload = {
"timeRange": { "preset": "last_30d" },
"hubIds": ["6650c2a1f3b9e4001c7d2c30"],
"utcOffset": "+07:00",
"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": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "avgDuration",
"field": "createdToDone"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "ageBucket",
"field": "createdTime",
"buckets": "age_default"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "in",
"value": ["UNASSIGNED", "ONGOING"]
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "hourOfDay",
"field": "doneTime"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N",
"spec": {
"specVersion": 1,
"dataSourceId": "data:6ae211692fd5463064096512",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
],
"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'],
utcOffset: '+07:00',
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: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'm1', fn: 'avgDuration', field: 'createdToDone'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'ageBucket', field: 'createdTime', buckets: 'age_default'}],
filters: [{id: 'f1', field: 'status', operator: 'in', value: ['UNASSIGNED', 'ONGOING']}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'hourOfDay', field: 'doneTime'}],
filters: [{id: 'f1', field: 'status', operator: 'eq', value: 'DONE'}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N',
spec: {
specVersion: 1,
dataSourceId: 'data:6ae211692fd5463064096512',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'status', limit: 10}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P',
spec: {
specVersion: 1,
dataSourceId: 'user',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'status', limit: 10}],
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'
],
'utcOffset' => '+07:00',
'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' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'avgDuration',
'field' => 'createdToDone'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'ageBucket',
'field' => 'createdTime',
'buckets' => 'age_default'
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'in',
'value' => [
'UNASSIGNED',
'ONGOING'
]
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'hourOfDay',
'field' => 'doneTime'
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'eq',
'value' => 'DONE'
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'data:6ae211692fd5463064096512',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'status',
'limit' => 10
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'user',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'status',
'limit' => 10
]
],
'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 \"utcOffset\": \"+07:00\",\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 \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avgDuration\",\n \"field\": \"createdToDone\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"ageBucket\",\n \"field\": \"createdTime\",\n \"buckets\": \"age_default\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"in\",\n \"value\": [\n \"UNASSIGNED\",\n \"ONGOING\"\n ]\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"hourOfDay\",\n \"field\": \"doneTime\"\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_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"data:6ae211692fd5463064096512\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P\",\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 {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\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 \"utcOffset\": \"+07:00\",\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 \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avgDuration\",\n \"field\": \"createdToDone\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"ageBucket\",\n \"field\": \"createdTime\",\n \"buckets\": \"age_default\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"in\",\n \"value\": [\n \"UNASSIGNED\",\n \"ONGOING\"\n ]\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"hourOfDay\",\n \"field\": \"doneTime\"\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_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"data:6ae211692fd5463064096512\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P\",\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 {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\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 \"utcOffset\": \"+07:00\",\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 \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avgDuration\",\n \"field\": \"createdToDone\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"ageBucket\",\n \"field\": \"createdTime\",\n \"buckets\": \"age_default\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"in\",\n \"value\": [\n \"UNASSIGNED\",\n \"ONGOING\"\n ]\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"hourOfDay\",\n \"field\": \"doneTime\"\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_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"data:6ae211692fd5463064096512\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P\",\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 {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\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
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K",
"status": "ok",
"columns": [
{
"id": "m1",
"role": "measure",
"fn": "avgDuration",
"field": "createdToDone",
"unit": "minute"
}
],
"rows": [
[
1520.5
]
],
"meta": {
"bucketCount": 1,
"rowCount": 1,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 5,
"basis": {
"m1": 128
}
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "createdTime",
"unit": null,
"kind": "ageBucket"
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"lt1d",
14
],
[
"1to3d",
22
],
[
"3to7d",
9
],
[
"gte7d",
31
]
],
"meta": {
"bucketCount": 4,
"rowCount": 4,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 3
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "doneTime",
"unit": null,
"kind": "hourOfDay"
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
0,
0
],
[
1,
2
],
[
2,
0
]
],
"meta": {
"bucketCount": 24,
"rowCount": 24,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 6
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "status",
"unit": null,
"kind": "terms",
"title": "Status"
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"open",
12
],
[
"closed",
7
],
[
"hold",
2
]
],
"meta": {
"bucketCount": 3,
"rowCount": 3,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 4
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "status",
"unit": null,
"kind": "terms",
"title": null
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"active",
42
],
[
"pending",
6
],
[
"disable",
3
],
[
"unverified",
1
]
],
"meta": {
"bucketCount": 4,
"rowCount": 4,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 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. Aggregates need view/dashboard only; the source’s own view permission (viewPermission, view/task for the Task family, view/data for a Data source) is needed for Sample rows (Get sample rows) and for choosing the source in the widget composer, never for a card’s numbers, with one exception: a user item that groups (at least one dimension) or filters (at least one filter) also needs view/user. Without it only that item comes back no_permission with error.code data_source_forbidden; the other items still run. A plain count of users (no dimension, no filter) needs view/dashboard only. On the user source, Group by Hub (hub) returns only the caller’s own hubs when the caller is limited to some hubs: a user who also belongs to a hub the caller cannot see adds no bucket for that hub. Visibility: organization, hub, and team. A caller in a team sees Task sources (Task (Common field) and Task - ) limited to tasks assigned to members of their teams (users without a team count as members) or with no assignee, as in the task list, unless the query names assignees itself with an assignee eq or in filter (an exists or range filter on assignee still applies the team limit); when no member is found, only the caller’s own tasks and tasks with no assignee. The User source is limited to users of the caller’s teams plus users without a team. Data sources are not limited by team. An owner and a caller without a team are not limited. Team and hub both apply.
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"
],
"utcOffset": "+07:00",
"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": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "avgDuration",
"field": "createdToDone"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "ageBucket",
"field": "createdTime",
"buckets": "age_default"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "in",
"value": [
"UNASSIGNED",
"ONGOING"
]
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "hourOfDay",
"field": "doneTime"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N",
"spec": {
"specVersion": 1,
"dataSourceId": "data:6ae211692fd5463064096512",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
],
"filters": []
}
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v3/analytics/query"
payload = {
"timeRange": { "preset": "last_30d" },
"hubIds": ["6650c2a1f3b9e4001c7d2c30"],
"utcOffset": "+07:00",
"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": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "avgDuration",
"field": "createdToDone"
}
],
"dimensions": [],
"filters": []
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "ageBucket",
"field": "createdTime",
"buckets": "age_default"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "in",
"value": ["UNASSIGNED", "ONGOING"]
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "hourOfDay",
"field": "doneTime"
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N",
"spec": {
"specVersion": 1,
"dataSourceId": "data:6ae211692fd5463064096512",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
]
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P",
"spec": {
"specVersion": 1,
"dataSourceId": "user",
"timeField": "createdTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "status",
"limit": 10
}
],
"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'],
utcOffset: '+07:00',
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: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'm1', fn: 'avgDuration', field: 'createdToDone'}],
dimensions: [],
filters: []
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'ageBucket', field: 'createdTime', buckets: 'age_default'}],
filters: [{id: 'f1', field: 'status', operator: 'in', value: ['UNASSIGNED', 'ONGOING']}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'hourOfDay', field: 'doneTime'}],
filters: [{id: 'f1', field: 'status', operator: 'eq', value: 'DONE'}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N',
spec: {
specVersion: 1,
dataSourceId: 'data:6ae211692fd5463064096512',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'status', limit: 10}]
}
},
{
id: 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P',
spec: {
specVersion: 1,
dataSourceId: 'user',
timeField: 'createdTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'status', limit: 10}],
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'
],
'utcOffset' => '+07:00',
'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' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'avgDuration',
'field' => 'createdToDone'
]
],
'dimensions' => [
],
'filters' => [
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'ageBucket',
'field' => 'createdTime',
'buckets' => 'age_default'
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'in',
'value' => [
'UNASSIGNED',
'ONGOING'
]
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'hourOfDay',
'field' => 'doneTime'
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'eq',
'value' => 'DONE'
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'data:6ae211692fd5463064096512',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'status',
'limit' => 10
]
]
]
],
[
'id' => 'crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'user',
'timeField' => 'createdTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'status',
'limit' => 10
]
],
'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 \"utcOffset\": \"+07:00\",\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 \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avgDuration\",\n \"field\": \"createdToDone\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"ageBucket\",\n \"field\": \"createdTime\",\n \"buckets\": \"age_default\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"in\",\n \"value\": [\n \"UNASSIGNED\",\n \"ONGOING\"\n ]\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"hourOfDay\",\n \"field\": \"doneTime\"\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_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"data:6ae211692fd5463064096512\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P\",\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 {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\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 \"utcOffset\": \"+07:00\",\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 \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avgDuration\",\n \"field\": \"createdToDone\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"ageBucket\",\n \"field\": \"createdTime\",\n \"buckets\": \"age_default\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"in\",\n \"value\": [\n \"UNASSIGNED\",\n \"ONGOING\"\n ]\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"hourOfDay\",\n \"field\": \"doneTime\"\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_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"data:6ae211692fd5463064096512\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P\",\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 {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\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 \"utcOffset\": \"+07:00\",\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 \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"avgDuration\",\n \"field\": \"createdToDone\"\n }\n ],\n \"dimensions\": [],\n \"filters\": []\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"ageBucket\",\n \"field\": \"createdTime\",\n \"buckets\": \"age_default\"\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"in\",\n \"value\": [\n \"UNASSIGNED\",\n \"ONGOING\"\n ]\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"task\",\n \"timeField\": \"doneTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"hourOfDay\",\n \"field\": \"doneTime\"\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_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N\",\n \"spec\": {\n \"specVersion\": 1,\n \"dataSourceId\": \"data:6ae211692fd5463064096512\",\n \"timeField\": \"createdTime\",\n \"measures\": [\n {\n \"id\": \"m1\",\n \"fn\": \"count\"\n }\n ],\n \"dimensions\": [\n {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\n }\n ]\n }\n },\n {\n \"id\": \"crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P\",\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 {\n \"id\": \"d1\",\n \"kind\": \"terms\",\n \"field\": \"status\",\n \"limit\": 10\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
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3K",
"status": "ok",
"columns": [
{
"id": "m1",
"role": "measure",
"fn": "avgDuration",
"field": "createdToDone",
"unit": "minute"
}
],
"rows": [
[
1520.5
]
],
"meta": {
"bucketCount": 1,
"rowCount": 1,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 5,
"basis": {
"m1": 128
}
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3L",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "createdTime",
"unit": null,
"kind": "ageBucket"
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"lt1d",
14
],
[
"1to3d",
22
],
[
"3to7d",
9
],
[
"gte7d",
31
]
],
"meta": {
"bucketCount": 4,
"rowCount": 4,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 3
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3M",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "doneTime",
"unit": null,
"kind": "hourOfDay"
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
0,
0
],
[
1,
2
],
[
2,
0
]
],
"meta": {
"bucketCount": 24,
"rowCount": 24,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 6
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3N",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "status",
"unit": null,
"kind": "terms",
"title": "Status"
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"open",
12
],
[
"closed",
7
],
[
"hold",
2
]
],
"meta": {
"bucketCount": 3,
"rowCount": 3,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 4
}
},
{
"id": "crd_01J8ZQ4R5W6X7Y8Z9A0B1C2D3P",
"status": "ok",
"columns": [
{
"id": "d1",
"role": "dimension",
"field": "status",
"unit": null,
"kind": "terms",
"title": null
},
{
"id": "m1",
"role": "measure",
"fn": "count",
"field": null,
"unit": "plain"
}
],
"rows": [
[
"active",
42
],
[
"pending",
6
],
[
"disable",
3
],
[
"unverified",
1
]
],
"meta": {
"bucketCount": 4,
"rowCount": 4,
"truncated": false,
"fanOut": false,
"partial": false,
"tookMs": 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"
}Body
Batch of up to 12 queries
Response
Success - one result per item, in request order. Individual items can still be error, timeout, no_data or no_permission. In the example, the hour-of-day item shows only its first 3 rows; the API returns all 24 (0-23, on utcOffset +07:00). The Data source card (...D3N) counts all records of the data type, whatever the time range, and its dimension column carries the field title. The last item is a Users card: it counts the organization's users by account status, whatever the time range; because it groups, the caller needs view/user as well, or the item is no_permission with data_source_forbidden. Status values are active, pending, disable, reject, inactive and unverified, returned as stored.