2016-11-24 10:16:24 +01:00
+++
title = "Dashboard HTTP API "
description = "Grafana Dashboard HTTP API"
keywords = ["grafana", "http", "documentation", "api", "dashboard"]
2021-04-15 14:08:58 -07:00
aliases = ["/docs/grafana/latest/http_api/dashboard/"]
2016-11-24 10:16:24 +01:00
+++
2016-02-02 22:59:22 -08:00
2016-02-05 01:47:34 -08:00
# Dashboard API
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
## Identifier (id) vs unique identifier (uid)
The identifier (id) of a dashboard is an auto-incrementing numeric value and is only unique per Grafana install.
The unique identifier (uid) of a dashboard can be used for uniquely identify a dashboard between multiple Grafana installs.
2020-02-14 21:41:08 +05:30
It's automatically generated if not provided when creating a dashboard. The uid allows having consistent URLs for accessing
2019-12-30 02:38:08 -05:00
dashboards and when syncing dashboards between multiple Grafana installs, see [dashboard provisioning ]({{< relref "../administration/provisioning.md#dashboards" >}} )
2018-02-05 20:53:58 +01:00
for more information. This means that changing the title of a dashboard will not break any bookmarked links to that dashboard.
The uid can have a maximum length of 40 characters.
2016-02-05 01:47:34 -08:00
## Create / Update dashboard
2016-02-02 22:59:22 -08:00
`POST /api/dashboards/db`
2021-10-05 19:46:29 -04:00
Creates a new dashboard or updates an existing dashboard. When updating existing dashboards, if you do not define the `folderId` or the `folderUid` property, then the dashboard(s) are moved to the General folder. (You need to define only one property, not both).
2016-02-02 22:59:22 -08:00
**Example Request for new dashboard** :
2017-05-08 08:02:08 +02:00
```http
POST /api/dashboards/db HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"dashboard" : {
"id" : null ,
2018-02-05 20:53:58 +01:00
"uid" : null ,
2017-05-08 08:02:08 +02:00
"title" : "Production Overview" ,
"tags" : [ "templated" ],
"timezone" : "browser" ,
2018-03-09 10:39:28 -05:00
"schemaVersion" : 16 ,
2020-08-17 21:00:10 +02:00
"version" : 0 ,
"refresh" : "25s"
2017-05-08 08:02:08 +02:00
},
2018-02-05 20:53:58 +01:00
"folderId" : 0 ,
2021-05-26 16:20:13 +02:00
"folderUid" : "l3KqBxCMz" ,
2021-03-29 15:00:27 -04:00
"message" : "Made changes to xyz" ,
2017-05-08 08:02:08 +02:00
"overwrite" : false
}
```
2016-02-02 22:59:22 -08:00
JSON Body schema:
2018-02-05 20:53:58 +01:00
- **dashboard** – The complete dashboard model, id = null to create a new dashboard.
- **dashboard.id** – id = null to create a new dashboard.
2020-02-11 10:36:18 -08:00
- **dashboard.uid** – Optional unique identifier when creating a dashboard. uid = null will generate a new uid.
2018-02-05 20:53:58 +01:00
- **folderId** – The id of the folder to save the dashboard in.
2021-05-26 16:20:13 +02:00
- **folderUid** – The UID of the folder to save the dashboard in. Overrides the `folderId` .
2018-02-05 20:53:58 +01:00
- **overwrite** – Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid.
2017-07-09 02:00:50 +02:00
- **message** - Set a commit message for the version history.
2020-08-17 21:00:10 +02:00
- **refresh** - Set the dashboard refresh interval. If this is lower than [the minimum refresh interval ]({{< relref "../administration/configuration.md#min_refresh_interval">}} ), then Grafana will ignore it and will enforce the minimum refresh interval.
2016-02-02 22:59:22 -08:00
2020-06-01 15:53:22 +03:00
For adding or updating an alert rule for a dashboard panel the user should declare a
`dashboard.panels.alert` block.
**Example Request for updating dashboard alert rule** :
```http
HTTP / 1.1 200 OK
Content-Type : application/json; charset=UTF-8
Content-Length : 78
{
"dashboard" : {
"id" : 104 ,
"panels" : [
{
"alert" : {
"alertRuleTags" : {},
"conditions" : [
{
"evaluator" : {
"params" : [
25
],
"type" : "gt"
},
"operator" : {
"type" : "and"
},
"query" : {
"params" : [
"A" ,
"5m" ,
"now"
]
},
"reducer" : {
"params" : [],
"type" : "avg"
},
"type" : "query"
}
],
"executionErrorState" : "alerting" ,
"for" : "5m" ,
"frequency" : "1m" ,
"handler" : 1 ,
"name" : "Panel Title alert" ,
"noDataState" : "no_data" ,
"notifications" : []
},
"aliasColors" : {},
"bars" : false ,
"dashLength" : 10 ,
"dashes" : false ,
"datasource" : null ,
"fieldConfig" : {
"defaults" : {
"custom" : {}
},
"overrides" : []
},
"fill" : 1 ,
"fillGradient" : 0 ,
"gridPos" : {
"h" : 9 ,
"w" : 12 ,
"x" : 0 ,
"y" : 0
},
"hiddenSeries" : false ,
"id" : 2 ,
"legend" : {
"avg" : false ,
"current" : false ,
"max" : false ,
"min" : false ,
"show" : true ,
"total" : false ,
"values" : false
},
"lines" : true ,
"linewidth" : 1 ,
"nullPointMode" : "null" ,
"options" : {
"dataLinks" : []
},
"percentage" : false ,
"pointradius" : 2 ,
"points" : false ,
"renderer" : "flot" ,
"seriesOverrides" : [],
"spaceLength" : 10 ,
"stack" : false ,
"steppedLine" : false ,
"targets" : [
{
"refId" : "A" ,
"scenarioId" : "random_walk"
}
],
"thresholds" : [
{
"colorMode" : "critical" ,
"fill" : true ,
"line" : true ,
"op" : "gt" ,
"value" : 50
}
],
"timeFrom" : null ,
"timeRegions" : [],
"timeShift" : null ,
"title" : "Panel Title" ,
"tooltip" : {
"shared" : true ,
"sort" : 0 ,
"value_type" : "individual"
},
"type" : "graph" ,
"xaxis" : {
"buckets" : null ,
"mode" : "time" ,
"name" : null ,
"show" : true ,
"values" : []
},
"yaxes" : [
{
"format" : "short" ,
"label" : null ,
"logBase" : 1 ,
"max" : null ,
"min" : null ,
"show" : true
},
{
"format" : "short" ,
"label" : null ,
"logBase" : 1 ,
"max" : null ,
"min" : null ,
"show" : true
}
],
"yaxis" : {
"align" : false ,
"alignLevel" : null
}
}
],
"title" : "Update alert rule via API" ,
"uid" : "dHEquNzGz" ,
"version" : 1
}
}
```
2016-02-02 22:59:22 -08:00
**Example Response** :
2017-05-08 08:02:08 +02:00
```http
HTTP / 1.1 200 OK
Content-Type : application/json; charset=UTF-8
Content-Length : 78
2016-02-02 22:59:22 -08:00
2017-05-08 08:02:08 +02:00
{
2018-02-05 20:53:58 +01:00
"id" : 1 ,
"uid" : "cIBgcSjkk" ,
"url" : "/d/cIBgcSjkk/production-overview" ,
"status" : "success" ,
"version" : 1 ,
"slug" : "production-overview" //deprecated in Grafana v5.0
2017-05-08 08:02:08 +02:00
}
```
2016-02-02 22:59:22 -08:00
Status Codes:
- **200** – Created
- **400** – Errors (invalid json, missing or invalid fields, etc)
- **401** – Unauthorized
2018-02-05 20:53:58 +01:00
- **403** – Access denied
2016-02-02 22:59:22 -08:00
- **412** – Precondition failed
2018-08-11 23:44:15 -07:00
The **412** status code is used for explaining that you cannot create the dashboard and why.
2018-02-05 20:53:58 +01:00
There can be different reasons for this:
- The dashboard has been changed by someone else, `status=version-mismatch`
- A dashboard with the same name in the folder already exists, `status=name-exists`
- A dashboard with the same uid already exists, `status=name-exists`
- The dashboard belongs to plugin `<plugin title>` , `status=plugin-dashboard`
2021-08-06 07:52:36 -06:00
The response body will have the following properties:
2016-02-02 22:59:22 -08:00
2017-05-08 08:02:08 +02:00
```http
HTTP / 1.1 412 Precondition Failed
Content-Type : application/json; charset=UTF-8
Content-Length : 97
2016-02-02 22:59:22 -08:00
2017-05-08 08:02:08 +02:00
{
"message" : "The dashboard has been changed by someone else" ,
"status" : "version-mismatch"
}
```
2016-02-02 22:59:22 -08:00
2018-02-14 10:53:14 +03:00
In case of title already exists the `status` property will be `name-exists` .
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
## Get dashboard by uid
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
`GET /api/dashboards/uid/:uid`
2016-02-02 22:59:22 -08:00
2021-05-26 16:20:13 +02:00
Will return the dashboard given the dashboard unique identifier (uid). Information about the unique identifier of a folder containing the requested dashboard might be found in the metadata.
2016-02-02 22:59:22 -08:00
**Example Request** :
2017-05-08 08:02:08 +02:00
```http
2018-02-05 20:53:58 +01:00
GET /api/dashboards/uid/cIBgcSjkk HTTP / 1.1
2017-05-08 08:02:08 +02:00
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-02 22:59:22 -08:00
**Example Response** :
2017-05-08 08:02:08 +02:00
```http
HTTP / 1.1 200
Content-Type : application/json
{
"dashboard" : {
2018-02-05 20:53:58 +01:00
"id" : 1 ,
"uid" : "cIBgcSjkk" ,
2017-05-08 08:02:08 +02:00
"title" : "Production Overview" ,
"tags" : [ "templated" ],
"timezone" : "browser" ,
2018-03-09 10:39:28 -05:00
"schemaVersion" : 16 ,
2017-05-08 08:02:08 +02:00
"version" : 0
2018-02-05 20:53:58 +01:00
},
"meta" : {
"isStarred" : false ,
"url" : "/d/cIBgcSjkk/production-overview" ,
2021-05-26 16:20:13 +02:00
"folderId" : 2 ,
"folderUid" : "l3KqBxCMz" ,
2018-02-05 20:53:58 +01:00
"slug" : "production-overview" //deprecated in Grafana v5.0
2017-05-08 08:02:08 +02:00
}
}
```
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
Status Codes:
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
- **200** – Found
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
## Delete dashboard by uid
`DELETE /api/dashboards/uid/:uid`
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
Will delete the dashboard given the specified unique identifier (uid).
2016-02-02 22:59:22 -08:00
**Example Request** :
2017-05-08 08:02:08 +02:00
```http
2018-02-05 20:53:58 +01:00
DELETE /api/dashboards/uid/cIBgcSjkk HTTP / 1.1
2017-05-08 08:02:08 +02:00
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-02 22:59:22 -08:00
**Example Response** :
2017-05-08 08:02:08 +02:00
```http
HTTP / 1.1 200
Content-Type : application/json
2016-02-02 22:59:22 -08:00
2020-07-31 08:22:09 +02:00
{
"title" : "Production Overview" ,
"message" : "Dashboard Production Overview deleted" ,
"id" : 2
}
2017-05-08 08:02:08 +02:00
```
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
2016-02-05 01:47:34 -08:00
## Gets the home dashboard
2016-02-02 22:59:22 -08:00
`GET /api/dashboards/home`
Will return the home dashboard.
**Example Request** :
2017-10-05 19:01:03 +02:00
```http
GET /api/dashboards/home HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-02 22:59:22 -08:00
**Example Response** :
2017-10-05 19:01:03 +02:00
```http
HTTP / 1.1 200
Content-Type : application/json
2016-02-02 22:59:22 -08:00
2017-10-05 19:01:03 +02:00
{
"dashboard" : {
"editable" : false ,
"hideControls" : true ,
"nav" :[
{
2018-03-09 10:39:28 -05:00
"enable" : false ,
"type" : "timepicker"
2017-10-05 19:01:03 +02:00
}
],
"style" : "dark" ,
"tags" :[],
"templating" :{
"list" :[
]
},
"time" :{
},
"timezone" : "browser" ,
"title" : "Home" ,
"version" : 5
2018-02-05 20:53:58 +01:00
},
"meta" : {
"isHome" : true ,
"canSave" : false ,
"canEdit" : false ,
"canStar" : false ,
"url" : "" ,
"expires" : "0001-01-01T00:00:00Z" ,
"created" : "0001-01-01T00:00:00Z"
2017-10-05 19:01:03 +02:00
}
}
```
2016-02-02 22:59:22 -08:00
2016-02-05 01:47:34 -08:00
## Tags for Dashboard
2016-02-02 22:59:22 -08:00
`GET /api/dashboards/tags`
2016-04-23 22:00:42 -07:00
Get all tags of dashboards
2016-02-02 22:59:22 -08:00
**Example Request** :
2017-10-05 19:01:03 +02:00
```http
GET /api/dashboards/tags HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-02 22:59:22 -08:00
**Example Response** :
2017-10-05 19:01:03 +02:00
```http
HTTP / 1.1 200
Content-Type : application/json
2016-02-02 22:59:22 -08:00
2017-10-05 19:01:03 +02:00
[
{
"term" : "tag1" ,
"count" : 1
},
{
"term" : "tag2" ,
"count" : 4
}
]
```
2016-02-02 22:59:22 -08:00
2018-02-05 20:53:58 +01:00
## Dashboard Search
2021-08-06 07:52:36 -06:00
2019-12-30 02:38:08 -05:00
See [Folder/Dashboard Search API ]({{< relref "folder_dashboard_search.md" >}} ).