2022-05-26 11:06:25 -04:00
---
aliases:
2026-04-29 08:19:49 -04:00
- ../../../../http_api/datasource_permissions/ # /docs/grafana/next/http_api/datasource_permissions/
- ../../../../http_api/datasourcepermissions/ # /docs/grafana/next/http_api/datasourcepermissions/
- ../../../../developers/http_api/datasource_permissions/ # /docs/grafana/next/developers/http_api/datasource_permissions/
2026-04-15 06:17:11 -04:00
- ../../../../developer-resources/api-reference/http-api/datasource_permissions/ #legacy folder
canonical: https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/api-legacy/datasource_permissions/
2022-05-26 11:06:25 -04:00
description: Data Source Permissions API
keywords:
- grafana
- http
- documentation
- api
- datasource
- permission
- permissions
- acl
- enterprise
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 04:10:12 -04:00
labels:
products:
- enterprise
- oss
2025-11-13 09:04:57 -05:00
- cloud
2026-04-15 09:24:56 -04:00
title: Data source permissions HTTP API
menuTitle: Data source permissions HTTP API
2022-05-26 11:06:25 -04:00
---
2018-10-30 14:02:12 -04:00
2026-04-15 09:24:56 -04:00
# Data source Permissions API
2018-10-30 14:02:12 -04:00
2026-04-16 09:59:25 -04:00
{{< docs / shared lookup = "developers/deprecated-apis.md" source = "grafana" version = "<GRAFANA_VERSION>" > }}
2026-04-15 06:17:11 -04:00
2025-03-06 07:59:08 -05:00
> The Data Source Permissions is only available in Grafana Enterprise. Read more about [Grafana Enterprise](/docs/grafana/latest/introduction/grafana-enterprise/).
2018-10-30 14:02:12 -04:00
2025-03-06 07:59:08 -05:00
> 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.
2021-09-29 11:45:27 -04:00
2023-10-24 09:51:12 -04:00
This API can be used to list, add and remove permissions for a data source.
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
Permissions can be set for a user, team, service account or a basic role (Admin, Editor, Viewer).
2018-10-30 14:02:12 -04:00
2026-03-31 16:34:11 -04:00
### Optional `ds_type` query parameter {#ds-type}
2026-06-08 05:07:32 -04:00
Every endpoint in this API accepts an optional query parameter `ds_type` . Set it to the data source **plugin type** (for example `prometheus` or `loki` ). Use `ds_type` when more than one data source in the organization shares the same UID so Grafana can resolve the correct instance.
2026-03-31 16:34:11 -04:00
2023-10-24 09:51:12 -04:00
## Get permissions for a data source
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
`GET /api/access-control/datasources/:uid`
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
Gets all existing permissions for the data source with the given `uid` .
2018-10-30 14:02:12 -04:00
2026-03-31 16:34:11 -04:00
Append `?ds_type=<TYPE>` when you need to disambiguate the UID; refer to [Optional `ds_type` query parameter ](#ds-type ).
2022-05-20 15:48:52 -04:00
**Required permissions**
2021-09-29 11:45:27 -04:00
2025-03-06 07:59:08 -05:00
See note in the [introduction ](#data-source-permissions-api ) for an explanation.
2021-09-29 11:45:27 -04:00
2023-10-24 09:51:12 -04:00
| Action | Scope |
| ---------------------------- | ------------------------------------------------------------------------------------------ |
| datasources.permissions:read | datasources:\*< br > datasources:uid:\*< br > datasources:uid:my_datasource (single data source) |
2021-09-29 11:45:27 -04:00
### Examples
2019-09-24 17:46:55 -04:00
**Example request:**
2018-10-30 14:02:12 -04:00
```http
2023-10-24 09:51:12 -04:00
GET /api/access-control/datasources/my_datasource HTTP/1.1
2018-10-30 14:02:12 -04:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2026-03-31 16:34:11 -04:00
**Example request (with `ds_type` when the UID is not unique):**
```http
GET /api/access-control/datasources/my_datasource?ds_type=prometheus HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2019-09-24 17:46:55 -04:00
**Example response:**
2018-10-30 14:02:12 -04:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
2023-10-24 09:51:12 -04:00
Content-Length: 551
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
[
{
"id": 1,
"roleName": "fixed:datasources:reader",
"isManaged": false,
"isInherited": false,
"isServiceAccount": false,
"userId": 1,
"userLogin": "admin_user",
"userAvatarUrl": "/avatar/admin_user",
"actions": [
"datasources:read",
"datasources:query",
"datasources:read",
"datasources:query",
"datasources:write",
"datasources:delete"
],
"permission": "Edit"
},
{
"id": 2,
"roleName": "managed:teams:1:permissions",
"isManaged": true,
"isInherited": false,
"isServiceAccount": false,
"team": "A team",
"teamId": 1,
"teamAvatarUrl": "/avatar/523d70c8551046f441727d690431858c",
"actions": [
"datasources:read",
"datasources:query"
],
"permission": "Query"
},
{
"id": 3,
"roleName": "basic:admin",
"isManaged": false,
"isInherited": false,
"isServiceAccount": false,
"builtInRole": "Admin",
"actions": [
"datasources:query",
"datasources:read",
"datasources:write",
"datasources:delete"
],
"permission": "Edit"
},
]
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
Status codes:
2018-10-30 14:02:12 -04:00
- **200** - Ok
- **401** - Unauthorized
- **403** - Access denied
2023-10-24 09:51:12 -04:00
- **500** - Internal error
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
## Add or revoke access to a data source for a user
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
`POST /api/access-control/datasources/:uid/users/:id`
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
Sets user permission for the data source with the given `uid` .
2026-03-31 16:34:11 -04:00
Append `?ds_type=<TYPE>` when you need to disambiguate the UID; refer to [Optional `ds_type` query parameter ](#ds-type ).
2023-10-24 09:51:12 -04:00
To add a permission, set the `permission` field to either `Query` , `Edit` , or `Admin` .
To remove a permission, set the `permission` field to an empty string.
2018-10-30 14:02:12 -04:00
2022-05-20 15:48:52 -04:00
**Required permissions**
2021-09-29 11:45:27 -04:00
2025-03-06 07:59:08 -05:00
See note in the [introduction ](#data-source-permissions-api ) for an explanation.
2021-09-29 11:45:27 -04:00
2023-10-24 09:51:12 -04:00
| Action | Scope |
| ----------------------------- | ------------------------------------------------------------------------------------------ |
| datasources.permissions:write | datasources:\*< br > datasources:uid:\*< br > datasources:uid:my_datasource (single data source) |
2021-09-29 11:45:27 -04:00
### Examples
2019-09-24 17:46:55 -04:00
**Example request:**
2018-10-30 14:02:12 -04:00
```http
2023-10-24 09:51:12 -04:00
POST /api/access-control/datasources/my_datasource/users/1
2018-10-30 14:02:12 -04:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2023-10-24 09:51:12 -04:00
{
"permission": "Query",
}
2018-10-30 14:02:12 -04:00
```
2026-06-08 05:07:32 -04:00
When granting a `Query` permission, the user also has read access to the data source.
2019-09-24 17:46:55 -04:00
**Example response:**
2018-10-30 14:02:12 -04:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
2023-10-24 09:51:12 -04:00
{"message": "Permission updated"}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
**Example request:**
2018-10-30 14:02:12 -04:00
```http
2023-10-24 09:51:12 -04:00
POST /api/access-control/datasources/my_datasource/users/1
2018-10-30 14:02:12 -04:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2023-10-24 09:51:12 -04:00
{
"permission": "",
}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
**Example response:**
2018-10-30 14:02:12 -04:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
2023-10-24 09:51:12 -04:00
Content-Length: 35
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
{"message": "Permission removed"}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
Status codes:
2018-10-30 14:02:12 -04:00
- **200** - Ok
2023-10-24 09:51:12 -04:00
- **400** - Permission cannot be added, see response body for details
2018-10-30 14:02:12 -04:00
- **401** - Unauthorized
- **403** - Access denied
2023-10-24 09:51:12 -04:00
## Add or revoke access to a data source for a team
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
`POST /api/access-control/datasources/:uid/teams/:id`
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
Sets team permission for the data source with the given `uid` .
2026-03-31 16:34:11 -04:00
Append `?ds_type=<TYPE>` when you need to disambiguate the UID; refer to [Optional `ds_type` query parameter ](#ds-type ).
2023-10-24 09:51:12 -04:00
To add a permission, set the `permission` field to either `Query` , `Edit` , or `Admin` .
To remove a permission, set the `permission` field to an empty string.
2018-10-30 14:02:12 -04:00
2026-06-08 05:07:32 -04:00
When adding `Query` , `Edit` , or `Admin` permissions, the user implicitly has `Read` access.
2022-05-20 15:48:52 -04:00
**Required permissions**
2021-09-29 11:45:27 -04:00
2025-03-06 07:59:08 -05:00
See note in the [introduction ](#data-source-permissions-api ) for an explanation.
2021-09-29 11:45:27 -04:00
2023-10-24 09:51:12 -04:00
| Action | Scope |
| ----------------------------- | ------------------------------------------------------------------------------------------ |
| datasources.permissions:write | datasources:\*< br > datasources:uid:\*< br > datasources:uid:my_datasource (single data source) |
2021-09-29 11:45:27 -04:00
### Examples
2019-09-24 17:46:55 -04:00
**Example request:**
2018-10-30 14:02:12 -04:00
```http
2023-10-24 09:51:12 -04:00
POST /api/access-control/datasources/my_datasource/teams/1
2018-10-30 14:02:12 -04:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
2023-10-24 09:51:12 -04:00
"permission": "Edit",
2018-10-30 14:02:12 -04:00
}
```
2019-09-24 17:46:55 -04:00
**Example response:**
2018-10-30 14:02:12 -04:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
2023-10-24 09:51:12 -04:00
{"message": "Permission updated"}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
**Example request:**
2018-10-30 14:02:12 -04:00
```http
2023-10-24 09:51:12 -04:00
POST /api/access-control/datasources/my_datasource/teams/1
2018-10-30 14:02:12 -04:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
2023-10-24 09:51:12 -04:00
"permission": "",
2018-10-30 14:02:12 -04:00
}
```
2019-09-24 17:46:55 -04:00
**Example response:**
2018-10-30 14:02:12 -04:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
2023-10-24 09:51:12 -04:00
{"message": "Permission removed"}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
Status codes:
2018-10-30 14:02:12 -04:00
- **200** - Ok
- **400** - Permission cannot be added, see response body for details
- **401** - Unauthorized
- **403** - Access denied
2023-10-24 09:51:12 -04:00
## Add or revoke access to a data source for a basic role
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
`POST /api/access-control/datasources/:uid/builtInRoles/:builtinRoleName`
2018-10-30 14:02:12 -04:00
2023-10-24 09:51:12 -04:00
Sets permission for the data source with the given `uid` to all users who have the specified basic role.
2026-03-31 16:34:11 -04:00
Append `?ds_type=<TYPE>` when you need to disambiguate the UID; refer to [Optional `ds_type` query parameter ](#ds-type ).
2023-10-24 09:51:12 -04:00
You can set permissions for the following basic roles: `Admin` , `Editor` , `Viewer` .
To add a permission, set the `permission` field to either `Query` , `Edit` , or `Admin` .
To remove a permission, set the `permission` field to an empty string.
2018-10-30 14:02:12 -04:00
2022-05-20 15:48:52 -04:00
**Required permissions**
2021-09-29 11:45:27 -04:00
2025-03-06 07:59:08 -05:00
See note in the [introduction ](#data-source-permissions-api ) for an explanation.
2021-09-29 11:45:27 -04:00
2023-10-24 09:51:12 -04:00
| Action | Scope |
| ----------------------------- | ------------------------------------------------------------------------------------------ |
| datasources.permissions:write | datasources:\*< br > datasources:uid:\*< br > datasources:uid:my_datasource (single data source) |
2021-09-29 11:45:27 -04:00
### Examples
2019-09-24 17:46:55 -04:00
**Example request:**
2018-10-30 14:02:12 -04:00
```http
2023-10-24 09:51:12 -04:00
POST /api/access-control/datasources/my_datasource/builtInRoles/Admin
2018-10-30 14:02:12 -04:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2023-10-24 09:51:12 -04:00
{
"permission": "Edit",
}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
**Example response:**
2018-10-30 14:02:12 -04:00
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
2023-10-24 09:51:12 -04:00
{"message": "Permission updated"}
```
**Example request:**
```http
POST /api/access-control/datasources/my_datasource/builtInRoles/Viewer
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"permission": "",
}
```
**Example response:**
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
{"message": "Permission removed"}
2018-10-30 14:02:12 -04:00
```
2019-09-24 17:46:55 -04:00
Status codes:
2018-10-30 14:02:12 -04:00
- **200** - Ok
2023-10-24 09:51:12 -04:00
- **400** - Permission cannot be added, see response body for details
2018-10-30 14:02:12 -04:00
- **401** - Unauthorized
- **403** - Access denied