grafana/docs/sources/developers/http_api/dashboard_public.md

327 lines
9.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
aliases:
- ../../http_api/dashboard_public/
canonical: /docs/grafana/latest/developers/http_api/dashboard_public/
description: Grafana Public Dashboard HTTP API
keywords:
- grafana
- http
- documentation
- api
- dashboard
labels:
products:
- enterprise
- oss
title: Public Dashboard HTTP API
---
# Public Dashboard API
{{% admonition type="note" %}}
If you're running Grafana Enterprise, you'll need to have specific permissions for some endpoints. Refer to [Role-based access control permissions][] for more information.
{{% /admonition %}}
## Create a public dashboard
`POST /api/dashboards/uid/:uid/public-dashboards/`
Creates a new public dashboard.
**Required permissions**
See note in the [introduction](#public-dashboard-api) for an explanation.
| Action | Scope |
| ------------------------- | -------------------------------- |
| `dashboards.public:write` | `dashboards:uid:<dashboard UID>` |
**Example Request for new public dashboard**:
```http
POST /api/dashboards/uid/xCpsVuc4z/public-dashboards/ HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
JSON Body schema:
- **uid** Optional. Unique identifier when creating a public dashboard. If it's null, it will generate a new uid.
- **accessToken** Optional. Unique access token. If it's null, it will generate a new access token.
- **timeSelectionEnabled** Optional. Set to `true` to enable the time picker in the public dashboard. The default value is `false`.
- **isEnabled** Optional. Set to `true` to enable the public dashboard. The default value is `false`.
- **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
```
Status Codes:
- **200** Created
- **400** Errors (such as invalid json, missing or invalid fields, or dashboard is public)
- **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
```
## Update a public dashboard
`PATCH /api/dashboards/uid/:uid/public-dashboards/:publicDashboardUid`
Will update the public dashboard given the specified unique identifier (uid).
**Required permissions**
See note in the [introduction](#public-dashboard-api) for an explanation.
| Action | Scope |
| ------------------------- | -------------------------------- |
| `dashboards.public:write` | `dashboards:uid:<dashboard UID>` |
**Example Request for updating a public dashboard**:
```http
PATCH /api/dashboards/uid/xCpsVuc4z/public-dashboards/cd56d9fd-f3d4-486d-afba-a21760e2acbe HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
JSON Body schema:
- **timeSelectionEnabled** Optional. Set to `true` to enable the time picker in the public dashboard. The default value is `false`.
- **isEnabled** Optional. Set to `true` to enable the public dashboard. The default value is `false`.
- **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
```
Status Codes:
- **200** Updated
- **400** Errors (such as invalid json, missing or invalid fields)
- **401** Unauthorized
- **403** Access denied
- **404** Public 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
```
## Get public dashboard by dashboard uid
`GET /api/dashboards/uid/:uid/public-dashboards/`
Will return the public dashboard given the dashboard unique identifier (uid).
**Required permissions**
See note in the [introduction](#public-dashboard-api) for an explanation.
| Action | Scope |
| ----------------- | -------------------------------- |
| `dashboards:read` | `dashboards:uid:<dashboard UID>` |
**Example Request**:
```http
GET /api/dashboards/uid/xCpsVuc4z HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
```
Status Codes:
- **200** Found
- **401** Unauthorized
- **403** Access denied
- **404** Not found
## Delete public dashboard by dashboard uid and public dashboard uid
`DELETE /api/dashboards/uid/:uid/public-dashboards/:publicDashboardUid`
Will delete the public dashboard given the specified unique identifier (uid).
**Required permissions**
See note in the [introduction](#public-dashboard-api) for an explanation.
| 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
## Get a list of all public dashboards with pagination
`GET /api/dashboards/public-dashboards`
**Required permissions**
See note in the [introduction](#public-dashboard-api) for an explanation.
| 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
```
{{% docs/reference %}}
[Role-based access control permissions]: "/docs/grafana/ -> /docs/grafana/<GRAFANA VERSION>/administration/roles-and-permissions/access-control/custom-role-actions-scopes"
[Role-based access control permissions]: "/docs/grafana-cloud/ -> /docs/grafana/<GRAFANA VERSION>/administration/roles-and-permissions/access-control/custom-role-actions-scopes"
{{% /docs/reference %}}