2023-09-09 03:10:44 +08:00
---
aliases:
- ../../http_api/dashboard_public/
canonical: /docs/grafana/latest/developers/http_api/dashboard_public/
2024-09-25 21:42:58 +08:00
description: Grafana Shared Dashboards HTTP API
2023-09-09 03:10:44 +08:00
keywords:
- grafana
- http
- documentation
- api
- dashboard
labels:
products:
- enterprise
- oss
2024-09-25 21:42:58 +08:00
title: Shared Dashboards HTTP API
2024-05-20 23:29:57 +08:00
refs:
role-based-access-control-permissions:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /administration/roles-and-permissions/access-control/custom-role-actions-scopes/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /administration/roles-and-permissions/access-control/custom-role-actions-scopes/
2023-09-09 03:10:44 +08:00
---
2024-09-25 21:42:58 +08:00
# Shared Dashboards API
2023-09-09 03:10:44 +08:00
{{% admonition type="note" %}}
2024-05-20 23:29:57 +08:00
If you're running Grafana Enterprise, you'll need to have specific permissions for some endpoints. Refer to [Role-based access control permissions ](ref:role-based-access-control-permissions ) for more information.
2023-09-09 03:10:44 +08:00
{{% /admonition %}}
2024-09-25 21:42:58 +08:00
## Create a shared dashboard
2023-09-09 03:10:44 +08:00
`POST /api/dashboards/uid/:uid/public-dashboards/`
2024-09-25 21:42:58 +08:00
Creates a new shared dashboard.
2023-09-09 03:10:44 +08:00
**Required permissions**
2024-09-25 21:42:58 +08:00
See note in the [introduction ](#shared-dashboards-api ) for an explanation.
2023-09-09 03:10:44 +08:00
| Action | Scope |
| ------------------------- | -------------------------------- |
| `dashboards.public:write` | `dashboards:uid:<dashboard UID>` |
2024-09-25 21:42:58 +08:00
**Example Request for new shared dashboard**:
2023-09-09 03:10:44 +08:00
```http
POST /api/dashboards/uid/xCpsVuc4z/public-dashboards/ HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"uid": "cd56d9fd-f3d4-486d-afba-a21760e2acbe",
"accessToken": "5c948bf96e6a4b13bd91975f9a2028b7",
"timeSelectionEnabled": false,
"isEnabled": true,
"annotationsEnabled": false,
"share": "public"
}
```
JSON Body schema:
2024-09-25 21:42:58 +08:00
- **uid** – Optional. Unique identifier when creating a shared dashboard. If it's null, it will generate a new uid.
2023-09-09 03:10:44 +08:00
- **accessToken** – Optional. Unique access token. If it's null, it will generate a new access token.
2024-09-25 21:42:58 +08:00
- **timeSelectionEnabled** – Optional. Set to `true` to enable the time picker in the shared dashboard. The default value is `false` .
- **isEnabled** – Optional. Set to `true` to enable the shared dashboard. The default value is `false` .
2023-09-09 03:10:44 +08:00
- **annotationsEnabled** – Optional. Set to `true` to show annotations. The default value is `false` .
- **share** – Optional. Set the share mode. The default value is `public` .
**Example Response**:
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 78
{
"uid": "cd56d9fd-f3d4-486d-afba-a21760e2acbe",
"dashboardUid": "xCpsVuc4z",
"accessToken": "5c948bf96e6a4b13bd91975f9a2028b7",
"createdBy": 1,
"updatedBy": 1,
"createdAt": "2023-09-05T15:48:21-03:00",
"updatedAt": "2023-09-05T15:48:21-03:00",
"timeSelectionEnabled": false,
"isEnabled": false,
"annotationsEnabled": false,
"share": "public"
}
```
Status Codes:
- **200** – Created
2024-09-25 21:42:58 +08:00
- **400** – Errors (such as invalid json, missing or invalid fields, or dashboard is shared)
2023-09-09 03:10:44 +08:00
- **401** – Unauthorized
- **403** – Access denied
- **404** – Dashboard not found
The error response body will have the following properties:
```http
HTTP/1.1 400 Bad request
Content-Type: application/json; charset=UTF-8
Content-Length: 107
{
"statusCode": 400,
"messageId": "publicdashboards.dashboardIsPublic",
"message": "Dashboard is already public"
}
```
2024-09-25 21:42:58 +08:00
## Update a shared dashboard
2023-09-09 03:10:44 +08:00
2024-01-13 01:07:16 +08:00
`PATCH /api/dashboards/uid/:uid/public-dashboards/:publicDashboardUid`
2024-09-25 21:42:58 +08:00
Will update the shared dashboard given the specified unique identifier (uid).
2023-09-09 03:10:44 +08:00
**Required permissions**
2024-09-25 21:42:58 +08:00
See note in the [introduction ](#shared-dashboard-api ) for an explanation.
2023-09-09 03:10:44 +08:00
| Action | Scope |
| ------------------------- | -------------------------------- |
| `dashboards.public:write` | `dashboards:uid:<dashboard UID>` |
2024-09-25 21:42:58 +08:00
**Example Request for updating a shared dashboard**:
2023-09-09 03:10:44 +08:00
```http
2024-01-13 01:07:16 +08:00
PATCH /api/dashboards/uid/xCpsVuc4z/public-dashboards/cd56d9fd-f3d4-486d-afba-a21760e2acbe HTTP/1.1
2023-09-09 03:10:44 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"timeSelectionEnabled": false,
"isEnabled": true,
"annotationsEnabled": false,
"share": "public"
}
```
JSON Body schema:
2024-09-25 21:42:58 +08:00
- **timeSelectionEnabled** – Optional. Set to `true` to enable the time picker in the shared dashboard. The default value is `false` .
- **isEnabled** – Optional. Set to `true` to enable the shared dashboard. The default value is `false` .
2023-09-09 03:10:44 +08:00
- **annotationsEnabled** – Optional. Set to `true` to show annotations. The default value is `false` .
- **share** – Optional. Set the share mode. The default value is `public` .
**Example Response**:
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 78
{
"uid": "cd56d9fd-f3d4-486d-afba-a21760e2acbe",
"dashboardUid": "xCpsVuc4z",
"accessToken": "5c948bf96e6a4b13bd91975f9a2028b7",
"createdBy": 1,
"updatedBy": 1,
"createdAt": "2023-09-05T15:48:21-03:00",
"updatedAt": "2023-09-05T15:48:21-03:00",
"timeSelectionEnabled": false,
"isEnabled": false,
"annotationsEnabled": false,
"share": "public"
}
```
Status Codes:
- **200** – Updated
- **400** – Errors (such as invalid json, missing or invalid fields)
- **401** – Unauthorized
- **403** – Access denied
2024-09-25 21:42:58 +08:00
- **404** – Dashboard not found
2023-09-09 03:10:44 +08:00
The error response body will have the following properties:
```http
HTTP/1.1 400 Bad request
Content-Type: application/json; charset=UTF-8
Content-Length: 107
{
"statusCode": 400,
"messageId": "publicdashboards.dashboardIsPublic",
"message": "Dashboard is already public"
}
```
2024-09-25 21:42:58 +08:00
## Get shared dashboard by dashboard uid
2023-09-09 03:10:44 +08:00
`GET /api/dashboards/uid/:uid/public-dashboards/`
2024-09-25 21:42:58 +08:00
Will return the shared dashboard given the dashboard unique identifier (uid).
2023-09-09 03:10:44 +08:00
**Required permissions**
2024-09-25 21:42:58 +08:00
See note in the [introduction ](#shared-dashboard-api ) for an explanation.
2023-09-09 03:10:44 +08:00
| Action | Scope |
| ----------------- | -------------------------------- |
| `dashboards:read` | `dashboards:uid:<dashboard UID>` |
**Example Request**:
```http
2024-02-14 02:08:49 +08:00
GET /api/dashboards/uid/xCpsVuc4z/public-dashboards/ HTTP/1.1
2023-09-09 03:10:44 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{
"uid": "e71950f3-e7dd-4d1e-aa8a-a857bc5e7d64",
"dashboardUid": "xCpsVuc4z",
"accessToken": "dab10f3a4fbb4342a602b03079c7ed64",
"createdBy": 1,
"updatedBy": 1,
"createdAt": "2023-09-05T15:48:21-03:00",
"updatedAt": "2023-09-05T15:48:21-03:00",
"timeSelectionEnabled": false,
"isEnabled": false,
"annotationsEnabled": false,
"share": "public"
}
```
Status Codes:
- **200** – Found
- **401** – Unauthorized
- **403** – Access denied
2024-09-25 21:42:58 +08:00
- **404** – Dashboard not found
2023-09-09 03:10:44 +08:00
2024-09-25 21:42:58 +08:00
## Delete shared dashboard by dashboard uid and shared dashboard uid
2023-09-09 03:10:44 +08:00
`DELETE /api/dashboards/uid/:uid/public-dashboards/:publicDashboardUid`
2024-09-25 21:42:58 +08:00
Will delete the shared dashboard given the specified unique identifier (uid).
2023-09-09 03:10:44 +08:00
**Required permissions**
2024-09-25 21:42:58 +08:00
See note in the [introduction ](#shared-dashboard-api ) for an explanation.
2023-09-09 03:10:44 +08:00
| Action | Scope |
| ------------------------- | -------------------------------- |
| `dashboards.public:write` | `dashboards:uid:<dashboard UID>` |
**Example Request**:
```http
DELETE /api/dashboards/uid/xCpsVuc4z/public-dashboards/cd56d9fd-f3d4-486d-afba-a21760e2acbe HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
Status Codes:
- **200** – Deleted
- **401** – Unauthorized
- **403** – Access denied
2024-09-25 21:42:58 +08:00
## Get a list of all shared dashboards with pagination
2023-09-09 03:10:44 +08:00
`GET /api/dashboards/public-dashboards`
**Required permissions**
2024-09-25 21:42:58 +08:00
See note in the [introduction ](#shared-dashboard-api ) for an explanation.
2023-09-09 03:10:44 +08:00
| Action | Scope |
| ----------------- | -------------------------------- |
| `dashboards:read` | `dashboards:uid:<dashboard UID>` |
**Example Request**:
```http
GET /api/dashboards/public-dashboards?perpage=2& page=3 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{
"publicDashboards": [
{
"uid": "e9f29a3c-fcc3-4fc5-a690-ae39c97d24ba",
"accessToken": "6c13ec1997ba48c5af8c9c5079049692",
"title": "Datasource Shared Queries",
"dashboardUid": "d2f21d0a-76c7-47ec-b5f3-9dda16e5a996",
"isEnabled": true
},
{
"uid": "a174f604-6fe7-47de-97b4-48b7e401b540",
"accessToken": "d1fcff345c0f45e8a78c096c9696034a",
"title": "Datasource with template variables",
"dashboardUid": "51DiOw0Vz",
"isEnabled": true
}
],
"totalCount": 30,
"page": 3,
"perPage": 2
}
```