1169 lines
33 KiB
Markdown
1169 lines
33 KiB
Markdown
---
|
||
aliases:
|
||
- ../../../http_api/dashboard/ # /docs/grafana/next/http_api/dashboard/
|
||
- ../../../developers/http_api/dashboard/ # /docs/grafana/next/developers/http_api/dashboard/
|
||
canonical: https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/dashboard/
|
||
description: Grafana Dashboard HTTP API
|
||
keywords:
|
||
- grafana
|
||
- http
|
||
- documentation
|
||
- api
|
||
- dashboard
|
||
labels:
|
||
products:
|
||
- enterprise
|
||
- oss
|
||
- cloud
|
||
title: Dashboard HTTP API
|
||
---
|
||
|
||
# New Dashboard APIs
|
||
|
||
> If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to [Role-based access control permissions](/docs/grafana/latest/administration/roles-and-permissions/access-control/custom-role-actions-scopes/) for more information.
|
||
|
||
> To view more about the new API structure, refer to [API overview](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/http_api/apis/).
|
||
|
||
## Create Dashboard
|
||
|
||
`POST /apis/dashboard.grafana.app/v1beta1/namespaces/:namespace/dashboards`
|
||
|
||
Creates a new dashboard.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/http_api/apis/).
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#dashboard-api" >}}) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Create Request**:
|
||
|
||
```http
|
||
POST /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **metadata.name** – The Grafana [unique identifier]({{< ref "#identifier-id-vs-unique-identifier-uid" >}}). If you do not want to provide this, set metadata.generateName instead to the prefix you would like for the randomly generated uid (cannot be an empty string).
|
||
- **metadata.annotations.grafana.app/folder** - Optional field, the unique identifier of the folder under which the dashboard should be created.
|
||
- **spec** – The dashboard json.
|
||
|
||
{{< admonition type="note" >}}
|
||
Custom labels and annotations in the metadata field are supported on some instances, with full support planned for all instances when these APIs reach general availability. If they are not yet supported on your instance, they will be ignored.
|
||
{{< /admonition >}}
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 485
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **201** – Created
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **409** – Conflict (dashboard with the same uid already exists)
|
||
|
||
## Update Dashboard
|
||
|
||
`PUT /apis/dashboard.grafana.app/v1beta1/namespaces/:namespace/dashboards/:uid`
|
||
|
||
Updates an existing dashboard via the dashboard uid.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/http_api/apis/).
|
||
- uid: the unique identifier of the dashboard to update. this will be the _name_ in the dashboard response
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#dashboard-api" >}}) for an explanation.
|
||
|
||
<!-- prettier-ignore-start -->
|
||
| Action | Scope |
|
||
| ------------------- | ------------------------------------------------------------------------------------------------------- |
|
||
| `dashboards:write` | <ul><li>`dashboards:*`</li><li>`dashboards:uid:*`</li><li>`folders:*`</li><li>`folders:uid:*`</li></ul> |
|
||
{ .no-spacing-list }
|
||
<!-- prettier-ignore-end -->
|
||
|
||
**Example Update Request**:
|
||
|
||
```http
|
||
POST /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards/gdxccn HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **metadata.name** – The [unique identifier]({{< ref "#identifier-id-vs-unique-identifier-uid" >}}).
|
||
- **metadata.annotations.grafana.app/folder** - Optional field, the unique identifier of the folder under which the dashboard should be created.
|
||
- **metadata.annotations.grafana.app/message** - Optional field, to set a commit message for the version history.
|
||
- **spec** – The dashboard json.
|
||
|
||
{{< admonition type="note" >}}
|
||
Custom labels and annotations in the metadata field are supported on some instances, with full support planned for all instances when these APIs reach general availability. If they are not yet supported on your instance, they will be ignored.
|
||
{{< /admonition >}}
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 485
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – OK
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **409** – Conflict (dashboard with the same version already exists)
|
||
|
||
## Get Dashboard
|
||
|
||
`GET /apis/dashboard.grafana.app/v1beta1/namespaces/:namespace/dashboards/:uid`
|
||
|
||
Gets a dashboard via the dashboard uid.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/http_api/apis/).
|
||
- uid: the unique identifier of the dashboard to update. this will be the _name_ in the dashboard response
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#dashboard-api" >}}) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Get Request**:
|
||
|
||
```http
|
||
GET /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards/gdxccn HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 485
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – OK
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **404** – Not Found
|
||
|
||
### Retrieve additional access information
|
||
|
||
`GET /apis/dashboard.grafana.app/v1beta1/namespaces/:namespace/dashboards/:uid/dto`
|
||
|
||
Retrieves a dashboard with additional access information.
|
||
|
||
The `GET` response includes an additional `access` section with data such as if it's a public dashboard, or the dashboard permissions (admin, editor) of the user who made the request.
|
||
|
||
## List Dashboards
|
||
|
||
`GET /apis/dashboard.grafana.app/v1beta1/namespaces/:namespace/dashboards`
|
||
|
||
Lists all dashboards in the given organization. You can control the maximum number of dashboards returned through the `limit` query parameter. You can then use the `continue` token returned to fetch the next page of dashboards.
|
||
|
||
- namespace: to read more about the namespace to use, see the [API overview](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/http_api/apis/).
|
||
|
||
**Query parameters**:
|
||
|
||
- **`limit`** (optional): Maximum number of dashboards to return
|
||
- **`continue`** (optional): Continue token from a previous response to fetch the next page
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction]({{< ref "#dashboard-api" >}}) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Get Request**:
|
||
|
||
```http
|
||
GET /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards?limit=1 HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 644
|
||
|
||
```
|
||
|
||
The `metadata.continue` field contains a token to fetch the next page.
|
||
|
||
**Example subsequent request using continue token**:
|
||
|
||
```http
|
||
GET /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards?limit=1&continue=eyJvIjoxNTIsInYiOjE3NjE3MDQyMjQyMDcxODksInMiOmZhbHNlfQ== HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example subsequent response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
|
||
```
|
||
|
||
Continue making requests with the updated `continue` token until you receive a response without a `continue` field in the metadata, indicating you've reached the last page.
|
||
|
||
Status Codes:
|
||
|
||
- **200** – OK
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
|
||
## Delete Dashboard
|
||
|
||
`DELETE /apis/dashboard.grafana.app/v1beta1/namespaces/:namespace/dashboards/:uid`
|
||
|
||
Deletes a dashboard via the dashboard uid.
|
||
|
||
- **`namespace`**: To read more about the namespace to use, see the [API overview](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/developers/http_api/apis/).
|
||
- **`uid`**: The unique identifier of the dashboard to update. This is the `metadata.name` field in the dashboard response and _not_ the `metadata.uid` field.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#new-dashboard-apis) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Delete Request**:
|
||
|
||
```http
|
||
DELETE /apis/dashboard.grafana.app/v1beta1/namespaces/default/dashboards/gdxccn HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 78
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – OK
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **404** – Not found
|
||
|
||
## Gets the home dashboard
|
||
|
||
`GET /api/dashboards/home`
|
||
|
||
Will return the home dashboard.
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/dashboards/home HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
## Tags for Dashboard
|
||
|
||
`GET /api/dashboards/tags`
|
||
|
||
Get all tags of dashboards
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/dashboards/tags HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
## Dashboard Search
|
||
|
||
See [Folder/Dashboard Search API](../folder_dashboard_search/).
|
||
|
||
## APIs
|
||
|
||
### Unique identifier (uid) vs identifier (id)
|
||
|
||
The unique identifier (uid) of a dashboard can be used to uniquely identify a dashboard within a given org.
|
||
It's automatically generated if not provided when creating a dashboard. The uid allows having consistent URLs for accessing
|
||
dashboards and when syncing dashboards between multiple Grafana installs, see [dashboard provisioning](/docs/grafana/latest/administration/provisioning/#dashboards)
|
||
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.
|
||
|
||
The identifier (id) of a dashboard is deprecated in favor of the unique identifier (uid).
|
||
|
||
### Create / Update dashboard
|
||
|
||
`POST /api/dashboards/db`
|
||
|
||
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).
|
||
|
||
> **Note:** This endpoint is not intended for creating folders, use `POST /api/folders` for that.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#dashboard-api) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Request for new dashboard**:
|
||
|
||
```http
|
||
POST /api/dashboards/db HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **dashboard** – The complete dashboard model.
|
||
- **dashboard.id** – id = null to create a new dashboard.
|
||
- **dashboard.uid** – Optional unique identifier when creating a dashboard. uid = null will generate a new uid.
|
||
- **dashboard.refresh** - Set the dashboard refresh interval. If this is lower than [the minimum refresh interval](/docs/grafana/latest/setup-grafana/configure-grafana/#min_refresh_interval), then Grafana will ignore it and will enforce the minimum refresh interval.
|
||
- **folderId** – The id of the folder to save the dashboard in.
|
||
- **folderUid** – The UID of the folder to save the dashboard in. Overrides the `folderId`.
|
||
- **overwrite** – Set to true if you want to overwrite an existing dashboard with a given dashboard UID.
|
||
- **message** - Set a commit message for the version history.
|
||
|
||
**Example Request for updating a dashboard**:
|
||
|
||
```http
|
||
POST /api/dashboards/db HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200 OK
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 78
|
||
|
||
```
|
||
|
||
Status Codes:
|
||
|
||
- **200** – Created
|
||
- **400** – Errors (invalid json, missing or invalid fields, etc)
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **412** – Precondition failed
|
||
|
||
The **412** status code is used for explaining that you cannot create the dashboard and why.
|
||
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`
|
||
|
||
The response body will have the following properties:
|
||
|
||
```http
|
||
HTTP/1.1 412 Precondition Failed
|
||
Content-Type: application/json; charset=UTF-8
|
||
Content-Length: 97
|
||
|
||
```
|
||
|
||
### Get dashboard by uid
|
||
|
||
`GET /api/dashboards/uid/:uid`
|
||
|
||
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.
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#dashboard-api) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/dashboards/uid/cIBgcSjkk 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 dashboard by uid
|
||
|
||
`DELETE /api/dashboards/uid/:uid`
|
||
|
||
Will delete the dashboard given the specified unique identifier (uid).
|
||
|
||
**Required permissions**
|
||
|
||
See note in the [introduction](#dashboard-api) for an explanation.
|
||
|
||
<!-- 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 -->
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
DELETE /api/dashboards/uid/cIBgcSjkk 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** – Deleted
|
||
- **401** – Unauthorized
|
||
- **403** – Access denied
|
||
- **404** – Not found
|