2024-09-18 18:54:21 +08:00
---
aliases:
- ../../http_api/datasource_lbac_rules/
canonical: /docs/grafana/latest/developers/http_api/datasource_lbac_rules/
description: Data Source LBAC rules API
keywords:
- grafana
- http
- documentation
- api
- datasource
- lbac
- acl
- enterprise
labels:
products:
- cloud
title: Datasource LBAC rules HTTP API
---
# Data Source LBAC rules API
LBAC (Label-Based Access Control) rules can be set for teams.
## Get LBAC rules for a data source
2024-11-12 01:06:07 +08:00
`GET /api/datasources/uid/:uid/lbac/teams`
2024-09-18 18:54:21 +08:00
Gets all existing LBAC rules for the data source with the given `uid` .
**Required permissions**
| Action | Scope |
| ---------------- | ---------------------------------------------------------------------------------------- |
| datasources:read | datasources:_< br > datasources:uid:_< br > datasources:uid:my_datasource (single data source) |
### Examples
**Example request:**
```
2024-11-12 01:06:07 +08:00
GET /api/datasources/uid/my_datasource/lbac/teams HTTP/1.1
2024-09-18 18:54:21 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2024-10-25 22:20:36 +08:00
**Example response:**
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 131
{
"rules": [
{
2024-12-06 17:48:19 +08:00
"teamUId": "fdnd1pf4m9sxvc",
2024-10-25 22:20:36 +08:00
"rules": [
"{ service_name=\"bigquery-sync-mysql\" }"
]
},
{
2024-12-06 17:48:19 +08:00
"teamUid": "dfed1p2m9sxvfc",
2024-10-25 22:20:36 +08:00
"rules": [
"{ service_name=\"api\" }"
]
}
]
}
```
2024-09-18 18:54:21 +08:00
## Update LBAC rules for a data source
2024-11-12 01:06:07 +08:00
`PUT /api/datasources/uid/:uid/lbac/teams`
2024-09-18 18:54:21 +08:00
Updates LBAC rules for teams associated with the data source with the given `uid` . Here you submit a list of teams and the rules for each team.
Deleting a team from the list will remove the team's LBAC rules. You have to submit all teams and their rules to be updated, to remove a team's rules, you have to submit the current list of rules without the team.
**Required permissions**
| Action | Scope |
| ----------------------------- | ---------------------------------------------------------------------------------------- |
| datasources:write | datasources:_< br > datasources:uid:_< br > datasources:uid:my_datasource (single data source) |
| datasources.permissions:write | datasources:_< br > datasources:uid:_< br > datasources:uid:my_datasource (single data source) |
### Examples
**Example request:**
```http
2024-11-12 01:06:07 +08:00
PUT /api/datasources/uid/my_datasource/lbac/teams
2024-09-18 18:54:21 +08:00
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"rules": [
{
2024-12-06 17:48:19 +08:00
"teamUId": "fdnd1pf4m9sxvc",
2024-10-25 22:20:36 +08:00
"rules": [
"{ service_name=\"bigquery-sync-mysql\" }"
]
},
{
2024-12-06 17:48:19 +08:00
"teamUid": "dfed1p2m9sxvfc",
2024-10-25 22:20:36 +08:00
"rules": [
"{ service_name=\"api\" }"
]
2024-09-18 18:54:21 +08:00
}
]
}
```
**Example response:**
```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
{
"id": 1,
2024-10-25 22:20:36 +08:00
"message": "Data source LBAC rules updated",
"name": "loki",
"rules": [
2024-09-18 18:54:21 +08:00
{
2024-12-06 17:48:19 +08:00
"teamUId": "fdnd1pf4m9sxvc",
2024-09-18 18:54:21 +08:00
"rules": [
2024-10-25 22:20:36 +08:00
"{ service_name=\"bigquery-sync-mysql\" }"
]
},
{
2024-12-06 17:48:19 +08:00
"teamUid": "dfed1p2m9sxvfc",
2024-10-25 22:20:36 +08:00
"rules": [
"{ service_name=\"api\" }"
2024-09-18 18:54:21 +08:00
]
}
2024-10-25 22:20:36 +08:00
],
"uid": "ee1nm1t7spog0e",
2024-09-18 18:54:21 +08:00
}
```