Create dashboard
Create a custom dashboard, optionally with its widgets. Every widget query is checked against the queryable tables before it is saved. Creating more dashboards than your plan allows returns a 403.
import { query } from "@trigger.dev/sdk";
const dashboard = await query.dashboards.create({
title: "Email tasks",
widgets: [
{
title: "Total runs",
query: "SELECT count() AS total FROM runs",
display: { type: "bignumber", column: "total", aggregation: "sum" },
},
],
});curl --request POST \
--url https://api.trigger.dev/api/v1/query/dashboards \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"description": "<string>",
"widgets": [
{
"title": "<string>",
"display": {
"type": "table",
"prettyFormatting": true,
"sorting": [
{
"id": "<string>",
"desc": true
}
]
},
"id": "<string>",
"query": "<string>",
"fillGaps": true
}
]
}
'import requests
url = "https://api.trigger.dev/api/v1/query/dashboards"
payload = {
"title": "<string>",
"description": "<string>",
"widgets": [
{
"title": "<string>",
"display": {
"type": "table",
"prettyFormatting": True,
"sorting": [
{
"id": "<string>",
"desc": True
}
]
},
"id": "<string>",
"query": "<string>",
"fillGaps": True
}
]
}
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({
title: '<string>',
description: '<string>',
widgets: [
{
title: '<string>',
display: {type: 'table', prettyFormatting: true, sorting: [{id: '<string>', desc: true}]},
id: '<string>',
query: '<string>',
fillGaps: true
}
]
})
};
fetch('https://api.trigger.dev/api/v1/query/dashboards', 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://api.trigger.dev/api/v1/query/dashboards",
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([
'title' => '<string>',
'description' => '<string>',
'widgets' => [
[
'title' => '<string>',
'display' => [
'type' => 'table',
'prettyFormatting' => true,
'sorting' => [
[
'id' => '<string>',
'desc' => true
]
]
],
'id' => '<string>',
'query' => '<string>',
'fillGaps' => true
]
]
]),
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://api.trigger.dev/api/v1/query/dashboards"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"widgets\": [\n {\n \"title\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"id\": \"<string>\",\n \"query\": \"<string>\",\n \"fillGaps\": true\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://api.trigger.dev/api/v1/query/dashboards")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"widgets\": [\n {\n \"title\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"id\": \"<string>\",\n \"query\": \"<string>\",\n \"fillGaps\": true\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trigger.dev/api/v1/query/dashboards")
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 \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"widgets\": [\n {\n \"title\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"id\": \"<string>\",\n \"query\": \"<string>\",\n \"fillGaps\": true\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"title": "<string>",
"description": "<string>",
"revision": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"widgets": [
{
"id": "<string>",
"title": "<string>",
"query": "<string>",
"display": {
"type": "table",
"prettyFormatting": true,
"sorting": [
{
"id": "<string>",
"desc": true
}
]
},
"fillGaps": true,
"position": {
"x": 5,
"y": 1,
"w": 6,
"h": 2
}
}
]
}Authorizations
Use a named environment API key. It starts with tr_dev_sk_, tr_prod_sk_, tr_stg_sk_, etc.
Create a named API key in the API Keys section of your Trigger.dev project dashboard. Choose the narrowest access preset that supports your integration.
Our TypeScript SDK will default to using the value of the TRIGGER_SECRET_KEY environment variable if it is set. If you are using the SDK in a different environment, you can set the key using the configure function.
import { configure } from "@trigger.dev/sdk"; configure({ accessToken: "tr_dev_sk_1234" });
Body
Response
Dashboard created
The dashboard id, starting with dashboard_
The revision from the dashboard you last read. Send it to reject the write with a 409 if someone else changed the dashboard in the meantime.
Widgets in grid order, top to bottom then left to right.
Show child attributes
Show child attributes
Was this page helpful?
import { query } from "@trigger.dev/sdk";
const dashboard = await query.dashboards.create({
title: "Email tasks",
widgets: [
{
title: "Total runs",
query: "SELECT count() AS total FROM runs",
display: { type: "bignumber", column: "total", aggregation: "sum" },
},
],
});curl --request POST \
--url https://api.trigger.dev/api/v1/query/dashboards \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"description": "<string>",
"widgets": [
{
"title": "<string>",
"display": {
"type": "table",
"prettyFormatting": true,
"sorting": [
{
"id": "<string>",
"desc": true
}
]
},
"id": "<string>",
"query": "<string>",
"fillGaps": true
}
]
}
'import requests
url = "https://api.trigger.dev/api/v1/query/dashboards"
payload = {
"title": "<string>",
"description": "<string>",
"widgets": [
{
"title": "<string>",
"display": {
"type": "table",
"prettyFormatting": True,
"sorting": [
{
"id": "<string>",
"desc": True
}
]
},
"id": "<string>",
"query": "<string>",
"fillGaps": True
}
]
}
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({
title: '<string>',
description: '<string>',
widgets: [
{
title: '<string>',
display: {type: 'table', prettyFormatting: true, sorting: [{id: '<string>', desc: true}]},
id: '<string>',
query: '<string>',
fillGaps: true
}
]
})
};
fetch('https://api.trigger.dev/api/v1/query/dashboards', 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://api.trigger.dev/api/v1/query/dashboards",
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([
'title' => '<string>',
'description' => '<string>',
'widgets' => [
[
'title' => '<string>',
'display' => [
'type' => 'table',
'prettyFormatting' => true,
'sorting' => [
[
'id' => '<string>',
'desc' => true
]
]
],
'id' => '<string>',
'query' => '<string>',
'fillGaps' => true
]
]
]),
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://api.trigger.dev/api/v1/query/dashboards"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"widgets\": [\n {\n \"title\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"id\": \"<string>\",\n \"query\": \"<string>\",\n \"fillGaps\": true\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://api.trigger.dev/api/v1/query/dashboards")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"widgets\": [\n {\n \"title\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"id\": \"<string>\",\n \"query\": \"<string>\",\n \"fillGaps\": true\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trigger.dev/api/v1/query/dashboards")
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 \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"widgets\": [\n {\n \"title\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"id\": \"<string>\",\n \"query\": \"<string>\",\n \"fillGaps\": true\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"title": "<string>",
"description": "<string>",
"revision": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"widgets": [
{
"id": "<string>",
"title": "<string>",
"query": "<string>",
"display": {
"type": "table",
"prettyFormatting": true,
"sorting": [
{
"id": "<string>",
"desc": true
}
]
},
"fillGaps": true,
"position": {
"x": 5,
"y": 1,
"w": 6,
"h": 2
}
}
]
}
