2016-11-24 03:16:24 -06:00
+++
title = "Dashboard HTTP API "
description = "Grafana Dashboard HTTP API"
keywords = ["grafana", "http", "documentation", "api", "dashboard"]
2019-12-30 01:17:03 -06:00
aliases = ["/docs/grafana/latest/http_api/dashboard/"]
2016-11-24 03:16:24 -06:00
type = "docs"
[menu.docs]
name = "Dashboard"
parent = "http_api"
+++
2016-02-03 00:59:22 -06:00
2016-02-05 03:47:34 -06:00
# Dashboard API
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06: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.
It's automatically generated if not provided when creating a dashboard. The uid allows having consistent URL's for accessing
2019-12-30 01:38:08 -06:00
dashboards and when syncing dashboards between multiple Grafana installs, see [dashboard provisioning ]({{< relref "../administration/provisioning.md#dashboards" >}} )
2018-02-05 13:53:58 -06: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 03:47:34 -06:00
## Create / Update dashboard
2016-02-03 00:59:22 -06:00
`POST /api/dashboards/db`
Creates a new dashboard or updates an existing dashboard.
**Example Request for new dashboard**:
2017-05-08 01:02:08 -05: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 13:53:58 -06:00
"uid": null,
2017-05-08 01:02:08 -05:00
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
2018-03-09 09:39:28 -06:00
"schemaVersion": 16,
2017-05-08 01:02:08 -05:00
"version": 0
},
2018-02-05 13:53:58 -06:00
"folderId": 0,
2017-05-08 01:02:08 -05:00
"overwrite": false
}
```
2016-02-03 00:59:22 -06:00
JSON Body schema:
2018-02-05 13:53:58 -06:00
- **dashboard** – The complete dashboard model, id = null to create a new dashboard.
- **dashboard.id** – id = null to create a new dashboard.
- **dashboard.uid** – Optional [unique identifier ](/http_api/dashboard/#identifier-id-vs-unique-identifier-uid ) when creating a dashboard. uid = null will generate a new uid.
- **folderId** – The id of the folder to save the dashboard in.
- **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-08 19:00:50 -05:00
- **message** - Set a commit message for the version history.
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-05-08 01:02:08 -05:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 78
2016-02-03 00:59:22 -06:00
2017-05-08 01:02:08 -05:00
{
2018-02-05 13:53:58 -06: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 01:02:08 -05:00
}
```
2016-02-03 00:59:22 -06:00
Status Codes:
- **200** – Created
- **400** – Errors (invalid json, missing or invalid fields, etc)
- **401** – Unauthorized
2018-02-05 13:53:58 -06:00
- **403** – Access denied
2016-02-03 00:59:22 -06:00
- **412** – Precondition failed
2018-08-12 01:44:15 -05:00
The **412** status code is used for explaining that you cannot create the dashboard and why.
2018-02-05 13:53:58 -06: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`
The response body will have the following properties:
2016-02-03 00:59:22 -06:00
2017-05-08 01:02:08 -05:00
```http
HTTP/1.1 412 Precondition Failed
Content-Type: application/json; charset=UTF-8
Content-Length: 97
2016-02-03 00:59:22 -06:00
2017-05-08 01:02:08 -05:00
{
"message": "The dashboard has been changed by someone else",
"status": "version-mismatch"
}
```
2016-02-03 00:59:22 -06:00
2018-02-14 01:53:14 -06:00
In case of title already exists the `status` property will be `name-exists` .
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
## Get dashboard by uid
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
`GET /api/dashboards/uid/:uid`
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
Will return the dashboard given the dashboard unique identifier (uid).
2016-02-03 00:59:22 -06:00
**Example Request**:
2017-05-08 01:02:08 -05:00
```http
2018-02-05 13:53:58 -06:00
GET /api/dashboards/uid/cIBgcSjkk HTTP/1.1
2017-05-08 01:02:08 -05:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-05-08 01:02:08 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
{
"dashboard": {
2018-02-05 13:53:58 -06:00
"id": 1,
"uid": "cIBgcSjkk",
2017-05-08 01:02:08 -05:00
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
2018-03-09 09:39:28 -06:00
"schemaVersion": 16,
2017-05-08 01:02:08 -05:00
"version": 0
2018-02-05 13:53:58 -06:00
},
"meta": {
"isStarred": false,
"url": "/d/cIBgcSjkk/production-overview",
"slug": "production-overview" //deprecated in Grafana v5.0
2017-05-08 01:02:08 -05:00
}
}
```
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
Status Codes:
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
- **200** – Found
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
## Delete dashboard by uid
`DELETE /api/dashboards/uid/:uid`
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
Will delete the dashboard given the specified unique identifier (uid).
2016-02-03 00:59:22 -06:00
**Example Request**:
2017-05-08 01:02:08 -05:00
```http
2018-02-05 13:53:58 -06:00
DELETE /api/dashboards/uid/cIBgcSjkk HTTP/1.1
2017-05-08 01:02:08 -05:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-05-08 01:02:08 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
{"title": "Production Overview"}
2017-05-08 01:02:08 -05:00
```
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
2016-02-05 03:47:34 -06:00
## Gets the home dashboard
2016-02-03 00:59:22 -06:00
`GET /api/dashboards/home`
Will return the home dashboard.
**Example Request**:
2017-10-05 12:01:03 -05:00
```http
GET /api/dashboards/home HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-10-05 12:01:03 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 00:59:22 -06:00
2017-10-05 12:01:03 -05:00
{
"dashboard": {
"editable":false,
"hideControls":true,
"nav":[
{
2018-03-09 09:39:28 -06:00
"enable":false,
"type":"timepicker"
2017-10-05 12:01:03 -05:00
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"Home",
"version":5
2018-02-05 13:53:58 -06: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 12:01:03 -05:00
}
}
```
2016-02-03 00:59:22 -06:00
2016-02-05 03:47:34 -06:00
## Tags for Dashboard
2016-02-03 00:59:22 -06:00
`GET /api/dashboards/tags`
2016-04-24 00:00:42 -05:00
Get all tags of dashboards
2016-02-03 00:59:22 -06:00
**Example Request**:
2017-10-05 12:01:03 -05:00
```http
GET /api/dashboards/tags HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-10-05 12:01:03 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 00:59:22 -06:00
2017-10-05 12:01:03 -05:00
[
{
"term":"tag1",
"count":1
},
{
"term":"tag2",
"count":4
}
]
```
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
## Dashboard Search
2019-12-30 01:38:08 -06:00
See [Folder/Dashboard Search API ]({{< relref "folder_dashboard_search.md" >}} ).
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
## Deprecated resources
Please note that these resource have been deprecated and will be removed in a future release.
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
### Get dashboard by slug
**Deprecated starting from Grafana v5.0. Please update to use the new *Get dashboard by uid* resource instead**
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
`GET /api/dashboards/db/:slug`
Will return the dashboard given the dashboard slug. Slug is the url friendly version of the dashboard title.
If there exists multiple dashboards with the same slug, one of them will be returned in the response.
2016-02-03 00:59:22 -06:00
**Example Request**:
2017-10-05 12:01:03 -05:00
```http
2018-02-05 13:53:58 -06:00
GET /api/dashboards/db/production-overview HTTP/1.1
2017-10-05 12:01:03 -05:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-10-05 12:01:03 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 00:59:22 -06:00
2018-02-05 13:53:58 -06:00
{
"dashboard": {
"id": 1,
"uid": "cIBgcSjkk",
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
2018-03-09 09:39:28 -06:00
"schemaVersion": 16,
2018-02-05 13:53:58 -06:00
"version": 0
},
"meta": {
"isStarred": false,
"url": "/d/cIBgcSjkk/production-overview",
"slug": "production-overview" // deprecated in Grafana v5.0
2017-10-05 12:01:03 -05:00
}
2018-02-05 13:53:58 -06:00
}
```
Status Codes:
- **200** – Found
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
### Delete dashboard by slug
**Deprecated starting from Grafana v5.0. Please update to use the *Delete dashboard by uid* resource instead.**
`DELETE /api/dashboards/db/:slug`
Will delete the dashboard given the specified slug. Slug is the url friendly version of the dashboard title.
**Example Request**:
```http
DELETE /api/dashboards/db/test HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{"title": "Production Overview"}
```
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
- **412** – Precondition failed
The **412** status code is used when there exists multiple dashboards with the same slug.
The response body will look like this:
```http
HTTP/1.1 412 Precondition Failed
Content-Type: application/json; charset=UTF-8
Content-Length: 97
{
"message": "Multiple dashboards with the same slug exists",
"status": "multiple-slugs-exists"
}
2017-11-02 01:04:51 -05:00
```