Create custom widget
curl --request POST \
--url https://apiweb.mile.app/api/v3/dynamic-dashboard-widget \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Done tasks per hub",
"description": "Completed tasks per hub in the selected range.",
"viz": "bar",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "hubName",
"limit": 10
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
},
"defaultLayout": {
"w": 6,
"h": 6
}
}
'import requests
url = "https://apiweb.mile.app/api/v3/dynamic-dashboard-widget"
payload = {
"name": "Done tasks per hub",
"description": "Completed tasks per hub in the selected range.",
"viz": "bar",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "hubName",
"limit": 10
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
},
"defaultLayout": {
"w": 6,
"h": 6
}
}
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({
name: 'Done tasks per hub',
description: 'Completed tasks per hub in the selected range.',
viz: 'bar',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'hubName', limit: 10}],
filters: [{id: 'f1', field: 'status', operator: 'eq', value: 'DONE'}]
},
defaultLayout: {w: 6, h: 6}
})
};
fetch('https://apiweb.mile.app/api/v3/dynamic-dashboard-widget', 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/dynamic-dashboard-widget",
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([
'name' => 'Done tasks per hub',
'description' => 'Completed tasks per hub in the selected range.',
'viz' => 'bar',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'hubName',
'limit' => 10
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'eq',
'value' => 'DONE'
]
]
],
'defaultLayout' => [
'w' => 6,
'h' => 6
]
]),
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/dynamic-dashboard-widget"
payload := strings.NewReader("{\n \"name\": \"Done tasks per hub\",\n \"description\": \"Completed tasks per hub in the selected range.\",\n \"viz\": \"bar\",\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\": \"terms\",\n \"field\": \"hubName\",\n \"limit\": 10\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n },\n \"defaultLayout\": {\n \"w\": 6,\n \"h\": 6\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/dynamic-dashboard-widget")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Done tasks per hub\",\n \"description\": \"Completed tasks per hub in the selected range.\",\n \"viz\": \"bar\",\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\": \"terms\",\n \"field\": \"hubName\",\n \"limit\": 10\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n },\n \"defaultLayout\": {\n \"w\": 6,\n \"h\": 6\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/dynamic-dashboard-widget")
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 \"name\": \"Done tasks per hub\",\n \"description\": \"Completed tasks per hub in the selected range.\",\n \"viz\": \"bar\",\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\": \"terms\",\n \"field\": \"hubName\",\n \"limit\": 10\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n },\n \"defaultLayout\": {\n \"w\": 6,\n \"h\": 6\n }\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"code": 201,
"message": "Widget has been added successfully.",
"data": {
"_id": "66fcd2a1e4b0a7d3c1f20c01",
"organizationId": "6650c2a1f3b9e4001c7d2a10",
"schemaVersion": 1,
"name": "Done tasks per hub",
"description": "Completed tasks per hub in the selected range.",
"category": "custom",
"viz": "bar",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "hubName",
"limit": 10
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
},
"composite": null,
"content": null,
"defaultLayout": {
"w": 6,
"h": 6
},
"isCustom": true,
"createdBy": "[email protected]",
"updatedBy": "[email protected]",
"createdTime": "2026-10-02T03:00:00.000000Z",
"updatedTime": "2026-10-02T03:00:00.000000Z"
}
}{
"status": false,
"message": "The widget query is not valid: Field 'hubId' is not available: field_blocked.identifier",
"error": {
"code": "field_blocked",
"message": "Field 'hubId' is not available: field_blocked.identifier",
"field": "hubId"
},
"failedCode": "dydsh-014"
}{
"status": false,
"message": "Unauthenticated.",
"failedCode": "auth-034"
}{
"status": false,
"message": "Access denied. You do not have permission for add dashboard. Please contact your admin to request access.",
"failedCode": "sys-035"
}{
"status": false,
"code": 500,
"message": "something_wrong",
"failedCode": "dydsh-045"
}Dashboard
Create custom widget
Creates a custom widget for the caller’s organization. It is listed in the custom category of Read widgets, and a card that uses it gets its own copy. The server sets isCustom: true and category: custom.
POST
/
dynamic-dashboard-widget
Create custom widget
curl --request POST \
--url https://apiweb.mile.app/api/v3/dynamic-dashboard-widget \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Done tasks per hub",
"description": "Completed tasks per hub in the selected range.",
"viz": "bar",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "hubName",
"limit": 10
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
},
"defaultLayout": {
"w": 6,
"h": 6
}
}
'import requests
url = "https://apiweb.mile.app/api/v3/dynamic-dashboard-widget"
payload = {
"name": "Done tasks per hub",
"description": "Completed tasks per hub in the selected range.",
"viz": "bar",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "hubName",
"limit": 10
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
},
"defaultLayout": {
"w": 6,
"h": 6
}
}
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({
name: 'Done tasks per hub',
description: 'Completed tasks per hub in the selected range.',
viz: 'bar',
spec: {
specVersion: 1,
dataSourceId: 'task',
timeField: 'doneTime',
measures: [{id: 'm1', fn: 'count'}],
dimensions: [{id: 'd1', kind: 'terms', field: 'hubName', limit: 10}],
filters: [{id: 'f1', field: 'status', operator: 'eq', value: 'DONE'}]
},
defaultLayout: {w: 6, h: 6}
})
};
fetch('https://apiweb.mile.app/api/v3/dynamic-dashboard-widget', 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/dynamic-dashboard-widget",
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([
'name' => 'Done tasks per hub',
'description' => 'Completed tasks per hub in the selected range.',
'viz' => 'bar',
'spec' => [
'specVersion' => 1,
'dataSourceId' => 'task',
'timeField' => 'doneTime',
'measures' => [
[
'id' => 'm1',
'fn' => 'count'
]
],
'dimensions' => [
[
'id' => 'd1',
'kind' => 'terms',
'field' => 'hubName',
'limit' => 10
]
],
'filters' => [
[
'id' => 'f1',
'field' => 'status',
'operator' => 'eq',
'value' => 'DONE'
]
]
],
'defaultLayout' => [
'w' => 6,
'h' => 6
]
]),
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/dynamic-dashboard-widget"
payload := strings.NewReader("{\n \"name\": \"Done tasks per hub\",\n \"description\": \"Completed tasks per hub in the selected range.\",\n \"viz\": \"bar\",\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\": \"terms\",\n \"field\": \"hubName\",\n \"limit\": 10\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n },\n \"defaultLayout\": {\n \"w\": 6,\n \"h\": 6\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/dynamic-dashboard-widget")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Done tasks per hub\",\n \"description\": \"Completed tasks per hub in the selected range.\",\n \"viz\": \"bar\",\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\": \"terms\",\n \"field\": \"hubName\",\n \"limit\": 10\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n },\n \"defaultLayout\": {\n \"w\": 6,\n \"h\": 6\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/dynamic-dashboard-widget")
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 \"name\": \"Done tasks per hub\",\n \"description\": \"Completed tasks per hub in the selected range.\",\n \"viz\": \"bar\",\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\": \"terms\",\n \"field\": \"hubName\",\n \"limit\": 10\n }\n ],\n \"filters\": [\n {\n \"id\": \"f1\",\n \"field\": \"status\",\n \"operator\": \"eq\",\n \"value\": \"DONE\"\n }\n ]\n },\n \"defaultLayout\": {\n \"w\": 6,\n \"h\": 6\n }\n}"
response = http.request(request)
puts response.read_body{
"status": true,
"code": 201,
"message": "Widget has been added successfully.",
"data": {
"_id": "66fcd2a1e4b0a7d3c1f20c01",
"organizationId": "6650c2a1f3b9e4001c7d2a10",
"schemaVersion": 1,
"name": "Done tasks per hub",
"description": "Completed tasks per hub in the selected range.",
"category": "custom",
"viz": "bar",
"spec": {
"specVersion": 1,
"dataSourceId": "task",
"timeField": "doneTime",
"measures": [
{
"id": "m1",
"fn": "count"
}
],
"dimensions": [
{
"id": "d1",
"kind": "terms",
"field": "hubName",
"limit": 10
}
],
"filters": [
{
"id": "f1",
"field": "status",
"operator": "eq",
"value": "DONE"
}
]
},
"composite": null,
"content": null,
"defaultLayout": {
"w": 6,
"h": 6
},
"isCustom": true,
"createdBy": "[email protected]",
"updatedBy": "[email protected]",
"createdTime": "2026-10-02T03:00:00.000000Z",
"updatedTime": "2026-10-02T03:00:00.000000Z"
}
}{
"status": false,
"message": "The widget query is not valid: Field 'hubId' is not available: field_blocked.identifier",
"error": {
"code": "field_blocked",
"message": "Field 'hubId' is not available: field_blocked.identifier",
"field": "hubId"
},
"failedCode": "dydsh-014"
}{
"status": false,
"message": "Unauthenticated.",
"failedCode": "auth-034"
}{
"status": false,
"message": "Access denied. You do not have permission for add dashboard. Please contact your admin to request access.",
"failedCode": "sys-035"
}{
"status": false,
"code": 500,
"message": "something_wrong",
"failedCode": "dydsh-045"
}Authorizations
Use a valid Bearer token to authenticate.
Body
application/json
Custom widget
Literal display name, never translated
Maximum string length:
200Chart type: one of the chart types used by the built-in query widgets (currently bar, donut, heatmap, kpi, line, table)
Maximum string length:
50Query spec, validated the same way as Run analytics query. Do not send timeRange; the dashboard supplies it.
Default card size when the widget is added to a dashboard
Show child attributes
Show child attributes