2022-05-26 23:06:25 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../../http_api/dashboard/
2023-02-07 01:14:36 +08:00
canonical: /docs/grafana/latest/developers/http_api/dashboard/
2022-05-26 23:06:25 +08:00
description: Grafana Dashboard HTTP API
keywords:
- grafana
- http
- documentation
- api
- dashboard
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- enterprise
- oss
2022-12-10 00:36:04 +08:00
title: Dashboard HTTP API
2022-05-26 23:06:25 +08:00
---
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
# Dashboard API
2016-02-03 14:59:22 +08:00
2023-03-16 01:06:31 +08:00
> If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to [Role-based access control permissions]({{< relref "/docs/grafana/latest/administration/roles-and-permissions/access-control/custom-role-actions-scopes" >}}) for more information.
2022-05-21 03:48:52 +08:00
2018-02-06 03:53:58 +08: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-15 00:11:08 +08:00
It's automatically generated if not provided when creating a dashboard. The uid allows having consistent URLs for accessing
2023-03-16 01:06:31 +08:00
dashboards and when syncing dashboards between multiple Grafana installs, see [dashboard provisioning ]({{< relref "/docs/grafana/latest/administration/provisioning#dashboards" >}} )
2018-02-06 03:53:58 +08: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 17:47:34 +08:00
## Create / Update dashboard
2016-02-03 14:59:22 +08:00
`POST /api/dashboards/db`
2023-09-08 10:57:16 +08: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 root level. (You need to define only one property, not both).
2016-02-03 14:59:22 +08:00
2024-02-04 08:16:19 +08:00
> **Note:** This endpoint is not intended for creating folders, use `POST /api/folders` for that.
2022-05-21 03:48:52 +08:00
**Required permissions**
See note in the [introduction ]({{< ref "#dashboard-api" >}} ) for an explanation.
2024-09-10 16:50:03 +08:00
<!-- prettier - ignore - start -->
| Action | Scope |
| ------------------- | ------------------------------------------------------------------------------------------------------- |
| `dashboards:create` | < ul >< li > `folders:*`</ li >< li > `folders:uid:*`</ li ></ ul > |
| `dashboards:write` | < ul >< li > `dashboards:*`</ li >< li > `dashboards:uid:*`</ li >< li > `folders:*`</ li >< li > `folders:uid:*`</ li ></ ul > |
{ .no-spacing-list }
<!-- prettier - ignore - end -->
2022-05-21 03:48:52 +08:00
2016-02-03 14:59:22 +08:00
**Example Request for new dashboard**:
2017-05-08 14:02:08 +08:00
```http
POST /api/dashboards/db HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"dashboard": {
"id": null,
2018-02-06 03:53:58 +08:00
"uid": null,
2017-05-08 14:02:08 +08:00
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
2018-03-09 23:39:28 +08:00
"schemaVersion": 16,
2020-08-18 03:00:10 +08:00
"refresh": "25s"
2017-05-08 14:02:08 +08:00
},
2021-05-26 22:20:13 +08:00
"folderUid": "l3KqBxCMz",
2021-03-30 03:00:27 +08:00
"message": "Made changes to xyz",
2017-05-08 14:02:08 +08:00
"overwrite": false
}
```
2016-02-03 14:59:22 +08:00
JSON Body schema:
2023-08-18 01:20:00 +08:00
- **dashboard** – The complete dashboard model.
2018-02-06 03:53:58 +08:00
- **dashboard.id** – id = null to create a new dashboard.
2020-02-12 02:36:18 +08:00
- **dashboard.uid** – Optional unique identifier when creating a dashboard. uid = null will generate a new uid.
2023-08-18 01:20:00 +08:00
- **dashboard.refresh** - Set the dashboard refresh interval. If this is lower than [the minimum refresh interval ]({{< relref "/docs/grafana/latest/setup-grafana/configure-grafana#min_refresh_interval" >}} ), then Grafana will ignore it and will enforce the minimum refresh interval.
2018-02-06 03:53:58 +08:00
- **folderId** – The id of the folder to save the dashboard in.
2021-05-26 22:20:13 +08:00
- **folderUid** – The UID of the folder to save the dashboard in. Overrides the `folderId` .
2024-11-26 17:36:44 +08:00
- **overwrite** – Set to true if you want to overwrite an existing dashboard with a given dashboard UID.
2017-07-09 08:00:50 +08:00
- **message** - Set a commit message for the version history.
2016-02-03 14:59:22 +08:00
2023-08-18 01:20:00 +08:00
**Example Request for updating a dashboard**:
2020-06-01 20:53:22 +08:00
```http
2023-08-18 01:20:00 +08:00
POST /api/dashboards/db HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2020-06-01 20:53:22 +08:00
{
2023-08-18 01:20:00 +08:00
"dashboard": {
"id": 1,
"title": "Production Overview Updated",
"tags": [ "templated" ],
"timezone": "browser",
"schemaVersion": 16,
"version": 1,
"refresh": "25s"
},
"folderUid": "l3KqBxCMz",
"message": "Made changes to xyz",
"overwrite": false
2020-06-01 20:53:22 +08:00
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-05-08 14:02:08 +08:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 78
2016-02-03 14:59:22 +08:00
2017-05-08 14:02:08 +08:00
{
2023-08-18 01:20:00 +08:00
"id": 1,
"uid": "e883f11b-77c0-4ee3-9a70-3ba223d66e56",
"url": "/d/e883f11b-77c0-4ee3-9a70-3ba223d66e56/production-overview-updated",
"status": "success",
"version": 2
"slug": "production-overview-updated",
2017-05-08 14:02:08 +08:00
}
```
2016-02-03 14:59:22 +08:00
Status Codes:
- **200** – Created
- **400** – Errors (invalid json, missing or invalid fields, etc)
- **401** – Unauthorized
2018-02-06 03:53:58 +08:00
- **403** – Access denied
2016-02-03 14:59:22 +08:00
- **412** – Precondition failed
2018-08-12 14:44:15 +08:00
The **412** status code is used for explaining that you cannot create the dashboard and why.
2018-02-06 03:53:58 +08:00
There can be different reasons for this:
- The dashboard has been changed by someone else, `status=version-mismatch`
- A dashboard with the same uid already exists, `status=name-exists`
- The dashboard belongs to plugin `<plugin title>` , `status=plugin-dashboard`
2021-08-06 21:52:36 +08:00
The response body will have the following properties:
2016-02-03 14:59:22 +08:00
2017-05-08 14:02:08 +08:00
```http
HTTP/1.1 412 Precondition Failed
Content-Type: application/json; charset=UTF-8
Content-Length: 97
2016-02-03 14:59:22 +08:00
2017-05-08 14:02:08 +08:00
{
"message": "The dashboard has been changed by someone else",
"status": "version-mismatch"
}
```
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
## Get dashboard by uid
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
`GET /api/dashboards/uid/:uid`
2016-02-03 14:59:22 +08:00
2021-05-26 22:20:13 +08: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-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
See note in the [introduction ]({{< ref "#dashboard-api" >}} ) for an explanation.
2024-09-10 16:50:03 +08:00
<!-- prettier - ignore - start -->
| Action | Scope |
| ----------------- | ------------------------------------------------------------------------------------------------------- |
| `dashboards:read` | < ul >< li > `dashboards:*`</ li >< li > `dashboards:uid:*`</ li >< li > `folders:*`</ li >< li > `folders:uid:*`</ li ></ ul > |
{ .no-spacing-list }
<!-- prettier - ignore - end -->
2022-05-21 03:48:52 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-05-08 14:02:08 +08:00
```http
2018-02-06 03:53:58 +08:00
GET /api/dashboards/uid/cIBgcSjkk HTTP/1.1
2017-05-08 14:02:08 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-05-08 14:02:08 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
{
"dashboard": {
2018-02-06 03:53:58 +08:00
"id": 1,
"uid": "cIBgcSjkk",
2017-05-08 14:02:08 +08:00
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
2018-03-09 23:39:28 +08:00
"schemaVersion": 16,
2017-05-08 14:02:08 +08:00
"version": 0
2018-02-06 03:53:58 +08:00
},
"meta": {
"isStarred": false,
"url": "/d/cIBgcSjkk/production-overview",
2021-05-26 22:20:13 +08:00
"folderId": 2,
"folderUid": "l3KqBxCMz",
2018-02-06 03:53:58 +08:00
"slug": "production-overview" //deprecated in Grafana v5.0
2017-05-08 14:02:08 +08:00
}
}
```
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
Status Codes:
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
- **200** – Found
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
## Delete dashboard by uid
`DELETE /api/dashboards/uid/:uid`
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
Will delete the dashboard given the specified unique identifier (uid).
2016-02-03 14:59:22 +08:00
2022-05-21 03:48:52 +08:00
**Required permissions**
See note in the [introduction ]({{< ref "#dashboard-api" >}} ) for an explanation.
2024-09-10 16:50:03 +08:00
<!-- prettier - ignore - start -->
| Action | Scope |
| ------------------- | ------------------------------------------------------------------------------------------------------- |
| `dashboards:delete` | < ul >< li > `dashboards:*`</ li >< li > `dashboards:uid:*`</ li >< li > `folders:*`</ li >< li > `folders:uid:*`</ li ></ ul > |
{ .no-spacing-list }
<!-- prettier - ignore - end -->
2022-05-21 03:48:52 +08:00
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-05-08 14:02:08 +08:00
```http
2018-02-06 03:53:58 +08:00
DELETE /api/dashboards/uid/cIBgcSjkk HTTP/1.1
2017-05-08 14:02:08 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-05-08 14:02:08 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2020-07-31 14:22:09 +08:00
{
"title": "Production Overview",
"message": "Dashboard Production Overview deleted",
"id": 2
}
2017-05-08 14:02:08 +08:00
```
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
2024-05-17 01:36:26 +08:00
## Hard delete dashboard by uid
{{% admonition type="note" %}}
This feature is currently in private preview and behind the `dashboardRestore` feature toggle.
{{% /admonition %}}
`DELETE /api/dashboards/uid/:uid/trash`
Will delete permanently the dashboard given the specified unique identifier (uid).
**Required permissions**
See note in the [introduction ]({{< ref "#dashboard-api" >}} ) for an explanation.
2024-09-10 16:50:03 +08:00
<!-- prettier - ignore - start -->
| Action | Scope |
| ------------------- | ------------------------------------------------------------------------------------------------------- |
| `dashboards:delete` | < ul >< li > `dashboards:*`</ li >< li > `dashboards:uid:*`</ li >< li > `folders:*`</ li >< li > `folders:uid:*`</ li ></ ul > |
{ .no-spacing-list }
<!-- prettier - ignore - end -->
2024-05-17 01:36:26 +08:00
**Example Request**:
```http
DELETE /api/dashboards/uid/cIBgcSjkk/trash 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",
"message": "Dashboard Production Overview deleted",
"uid": "cIBgcSjkk"
}
```
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
## Restore deleted dashboard by uid
{{% admonition type="note" %}}
This feature is currently in private preview and behind the `dashboardRestore` feature toggle.
{{% /admonition %}}
`PATCH /api/dashboards/uid/:uid/trash`
Will restore a deleted dashboard given the specified unique identifier (uid).
**Required permissions**
See note in the [introduction ]({{< ref "#dashboard-api" >}} ) for an explanation.
2024-09-10 16:50:03 +08:00
<!-- prettier - ignore - start -->
| Action | Scope |
| ------------------- | ----------------------------------------------------- |
| `dashboards:create` | < ul >< li > `folders:*`</ li >< li > `folders:uid:*`</ li ></ ul > |
{ .no-spacing-list }
<!-- prettier - ignore - end -->
2024-05-17 01:36:26 +08:00
**Example Request**:
```http
PATCH /api/dashboards/uid/cIBgcSjkk/trash 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",
"message": "Dashboard Production Overview restored",
"uid": "cIBgcSjkk"
}
```
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
- **404** – Not found
-
2016-02-05 17:47:34 +08:00
## Gets the home dashboard
2016-02-03 14:59:22 +08:00
`GET /api/dashboards/home`
Will return the home dashboard.
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
GET /api/dashboards/home HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
{
"dashboard": {
"editable":false,
"nav":[
{
2018-03-09 23:39:28 +08:00
"enable":false,
"type":"timepicker"
2017-10-06 01:01:03 +08:00
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"Home",
"version":5
2018-02-06 03:53:58 +08: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-06 01:01:03 +08:00
}
}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Tags for Dashboard
2016-02-03 14:59:22 +08:00
`GET /api/dashboards/tags`
2016-04-24 13:00:42 +08:00
Get all tags of dashboards
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
GET /api/dashboards/tags HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2017-10-06 01:01:03 +08:00
[
{
"term":"tag1",
"count":1
},
{
"term":"tag2",
"count":4
}
]
```
2016-02-03 14:59:22 +08:00
2018-02-06 03:53:58 +08:00
## Dashboard Search
2021-08-06 21:52:36 +08:00
2022-06-03 00:57:22 +08:00
See [Folder/Dashboard Search API ]({{< relref "folder_dashboard_search/" >}} ).