2018-02-05 10:12:22 -06:00
+++
title = "Dashboard Permissions HTTP API "
description = "Grafana Dashboard Permissions HTTP API"
keywords = ["grafana", "http", "documentation", "api", "dashboard", "permission", "permissions", "acl"]
2019-12-30 01:17:03 -06:00
aliases = ["/docs/grafana/latest/http_api/dashboardpermissions/"]
2018-02-05 10:12:22 -06:00
+++
2018-02-12 07:50:35 -06:00
# Dashboard Permissions API
2018-02-05 10:12:22 -06:00
2018-02-21 06:09:54 -06:00
This API can be used to update/get the permissions for a dashboard.
2018-02-05 10:12:22 -06:00
2018-02-12 07:50:35 -06:00
Permissions with `dashboardId=-1` are the default permissions for users with the Viewer and Editor roles. Permissions can be set for a user, a team or a role (Viewer or Editor). Permissions cannot be set for Admins - they always have access to everything.
2018-02-05 10:12:22 -06:00
The permission levels for the permission field:
- 1 = View
- 2 = Edit
- 4 = Admin
2018-02-21 06:09:54 -06:00
## Get permissions for a dashboard
2018-02-05 10:12:22 -06:00
2018-02-21 06:09:54 -06:00
`GET /api/dashboards/id/:dashboardId/permissions`
2018-02-05 10:12:22 -06:00
2018-02-21 06:09:54 -06:00
Gets all existing permissions for the dashboard with the given `dashboardId` .
2018-02-05 10:12:22 -06:00
2018-02-12 07:50:35 -06:00
**Example request**:
2018-02-05 10:12:22 -06:00
```http
2018-02-21 06:09:54 -06:00
GET /api/dashboards/id/1/permissions HTTP/1.1
2018-02-05 10:12:22 -06:00
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: 551
[
{
"id": 1,
"dashboardId": -1,
"created": "2017-06-20T02:00:00+02:00",
"updated": "2017-06-20T02:00:00+02:00",
"userId": 0,
"userLogin": "",
"userEmail": "",
"teamId": 0,
"team": "",
"role": "Viewer",
"permission": 1,
"permissionName": "View",
"uid": "",
"title": "",
"slug": "",
"isFolder": false,
"url": ""
},
{
"id": 2,
"dashboardId": -1,
"created": "2017-06-20T02:00:00+02:00",
"updated": "2017-06-20T02:00:00+02:00",
"userId": 0,
"userLogin": "",
"userEmail": "",
"teamId": 0,
"team": "",
"role": "Editor",
"permission": 2,
"permissionName": "Edit",
"uid": "",
"title": "",
"slug": "",
"isFolder": false,
"url": ""
}
]
```
Status Codes:
- **200** - Ok
2018-02-12 07:50:35 -06:00
- **401** - Unauthorized
2018-02-05 10:12:22 -06:00
- **403** - Access denied
2018-02-21 06:09:54 -06:00
- **404** - Dashboard not found
2018-02-05 10:12:22 -06:00
2018-02-21 06:09:54 -06:00
## Update permissions for a dashboard
2018-02-05 10:12:22 -06:00
2018-02-21 06:09:54 -06:00
`POST /api/dashboards/id/:dashboardId/permissions`
2018-02-05 10:12:22 -06:00
2018-02-21 06:09:54 -06:00
Updates permissions for a dashboard. This operation will remove existing permissions if they're not included in the request.
2018-02-05 10:12:22 -06:00
2018-02-12 07:50:35 -06:00
**Example request**:
2018-02-05 10:12:22 -06:00
```http
2018-02-21 06:09:54 -06:00
POST /api/dashboards/id/1/permissions
2018-02-05 10:12:22 -06:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2018-05-10 21:19:28 -05:00
{
2018-02-05 10:12:22 -06:00
"items": [
{
"role": "Viewer",
"permission": 1
},
{
"role": "Editor",
"permission": 2
},
{
"teamId": 1,
"permission": 1
},
{
"userId": 11,
"permission": 4
}
]
}
```
JSON body schema:
2018-02-12 07:50:35 -06:00
- **items** - The permission items to add/update. Items that are omitted from the list will be removed.
2018-02-05 10:12:22 -06:00
**Example response**:
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
2018-02-21 06:09:54 -06:00
{"message":"Dashboard permissions updated"}
2018-02-05 10:12:22 -06:00
```
Status Codes:
- **200** - Ok
2018-02-12 07:50:35 -06:00
- **401** - Unauthorized
2018-02-05 10:12:22 -06:00
- **403** - Access denied
- **404** - Dashboard not found