Update dashboard widget
Change a widget’s title, query, display or position.
import { query } from "@trigger.dev/sdk";
await query.dashboards.widgets.update("dashboard_1234", "widget_1", {
position: { x: 0, y: 0, w: 6, h: 10 },
});curl --request PATCH \
--url https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"query": "<string>",
"display": {
"type": "table",
"prettyFormatting": true,
"sorting": [
{
"id": "<string>",
"desc": true
}
]
},
"fillGaps": true,
"revision": "<string>"
}
'import requests
url = "https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}"
payload = {
"title": "<string>",
"query": "<string>",
"display": {
"type": "table",
"prettyFormatting": True,
"sorting": [
{
"id": "<string>",
"desc": True
}
]
},
"fillGaps": True,
"revision": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: '<string>',
query: '<string>',
display: {type: 'table', prettyFormatting: true, sorting: [{id: '<string>', desc: true}]},
fillGaps: true,
revision: '<string>'
})
};
fetch('https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}', 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/{dashboardId}/widgets/{widgetId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'title' => '<string>',
'query' => '<string>',
'display' => [
'type' => 'table',
'prettyFormatting' => true,
'sorting' => [
[
'id' => '<string>',
'desc' => true
]
]
],
'fillGaps' => true,
'revision' => '<string>'
]),
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/{dashboardId}/widgets/{widgetId}"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"query\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"fillGaps\": true,\n \"revision\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"query\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"fillGaps\": true,\n \"revision\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"<string>\",\n \"query\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"fillGaps\": true,\n \"revision\": \"<string>\"\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" });
Path Parameters
The custom dashboard id, starting with dashboard_
The widget id
Body
How the widget renders its query results.
- Table
- Chart
- Big number
- Section title
Show child attributes
Show child attributes
A position on the dashboard's 12-column grid.
Show child attributes
Show child attributes
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.
Response
The updated dashboard
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";
await query.dashboards.widgets.update("dashboard_1234", "widget_1", {
position: { x: 0, y: 0, w: 6, h: 10 },
});curl --request PATCH \
--url https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"query": "<string>",
"display": {
"type": "table",
"prettyFormatting": true,
"sorting": [
{
"id": "<string>",
"desc": true
}
]
},
"fillGaps": true,
"revision": "<string>"
}
'import requests
url = "https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}"
payload = {
"title": "<string>",
"query": "<string>",
"display": {
"type": "table",
"prettyFormatting": True,
"sorting": [
{
"id": "<string>",
"desc": True
}
]
},
"fillGaps": True,
"revision": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: '<string>',
query: '<string>',
display: {type: 'table', prettyFormatting: true, sorting: [{id: '<string>', desc: true}]},
fillGaps: true,
revision: '<string>'
})
};
fetch('https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}', 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/{dashboardId}/widgets/{widgetId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'title' => '<string>',
'query' => '<string>',
'display' => [
'type' => 'table',
'prettyFormatting' => true,
'sorting' => [
[
'id' => '<string>',
'desc' => true
]
]
],
'fillGaps' => true,
'revision' => '<string>'
]),
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/{dashboardId}/widgets/{widgetId}"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"query\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"fillGaps\": true,\n \"revision\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"query\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"fillGaps\": true,\n \"revision\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trigger.dev/api/v1/query/dashboards/{dashboardId}/widgets/{widgetId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"<string>\",\n \"query\": \"<string>\",\n \"display\": {\n \"type\": \"table\",\n \"prettyFormatting\": true,\n \"sorting\": [\n {\n \"id\": \"<string>\",\n \"desc\": true\n }\n ]\n },\n \"fillGaps\": true,\n \"revision\": \"<string>\"\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
}
}
]
}
