2022-05-26 16:06:25 +01:00
---
aliases :
2022-12-09 12:36:04 -04:00
- ../../http_api/team/
2023-02-06 17:14:36 +00:00
canonical : /docs/grafana/latest/developers/http_api/team/
2022-05-26 16:06:25 +01:00
description : Grafana Team HTTP API
keywords :
- grafana
- http
- documentation
- api
- team
- teams
- group
2023-07-18 09:10:12 +01:00
labels :
products :
- enterprise
- oss
2022-12-09 12:36:04 -04:00
title : Team HTTP API
2022-05-26 16:06:25 +01:00
---
2018-02-15 23:05:16 +01:00
# Team API
2022-02-09 13:44:38 +01:00
This API can be used to manage Teams and Team Memberships.
Access to these API endpoints is restricted as follows:
- All authenticated users are able to view details of teams they are a member of.
- Organization Admins are able to manage all teams and team members.
2022-02-15 17:09:03 +00:00
- If you enable `editors_can_admin` configuration flag, then Organization Editors can create teams and manage teams where they are Admin.
- If you enable `editors_can_admin` configuration flag, Editors can find out whether a team that they are not members of exists by trying to create a team with the same name.
2018-02-15 23:05:16 +01:00
2023-03-15 17:06:31 +00:00
> If you are running Grafana Enterprise, for some endpoints you'll need to have specific permissions. Refer to [Role-based access control permissions]({{< relref "/docs/grafana/latest/administration/roles-and-permissions/access-control/custom-role-actions-scopes" >}}) for more information.
2022-02-11 17:00:13 +00:00
2018-02-15 23:05:16 +01:00
## Team Search With Paging
2023-09-28 17:20:51 +02:00
`GET /api/teams/search?perpage=50&page=1&query=myteam&sort=memberCount-desc`
2018-02-15 23:05:16 +01:00
or
`GET /api/teams/search?name=myteam`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ---------- | -------- |
| teams:read | teams:\* |
**Example Request** :
2018-02-15 23:05:16 +01:00
```http
2022-02-11 17:00:13 +00:00
GET /api/teams/search?perpage=10&page=1&query=mytestteam HTTP / 1.1
2018-02-15 23:05:16 +01:00
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
2021-04-16 22:39:38 +02:00
{
2018-02-15 23:05:16 +01:00
"totalCount" : 1 ,
"teams" : [
{
"id" : 1 ,
"orgId" : 1 ,
"name" : "MyTestTeam" ,
"email" : "" ,
"avatarUrl" : "\/avatar\/3f49c15916554246daa714b9bd0ee398" ,
"memberCount" : 1
}
],
"page" : 1 ,
"perPage" : 1000
}
```
2022-02-11 17:00:13 +00:00
### Using the query parameter
Default value for the `perpage` parameter is `1000` and for the `page` parameter is `1` .
The `totalCount` field in the response can be used for pagination of the teams list E.g. if `totalCount` is equal to 100 teams and the `perpage` parameter is set to 10 then there are 10 pages of teams.
The `query` parameter is optional and it will return results where the query value is contained in the `name` field. Query values with spaces need to be URL encoded e.g. `query=my%20team` .
2023-09-28 17:20:51 +02:00
The `sort` param is an optional comma separated list of options to order the search result. Accepted values for the sort filter are: ` name-asc` , `name-desc` , `email-asc` , `email-desc` , `memberCount-asc` , `memberCount-desc` . By default, if `sort` is not specified, the teams list will be ordered by `name` in ascending order.
2022-02-11 17:00:13 +00:00
### Using the name parameter
The `name` parameter returns a single team if the parameter matches the `name` field.
#### Status Codes:
2018-02-15 23:05:16 +01:00
- **200** - Ok
2023-09-28 17:20:51 +02:00
- **400** - Bad Request
2018-02-15 23:05:16 +01:00
- **401** - Unauthorized
- **403** - Permission denied
2018-02-16 11:18:41 +01:00
- **404** - Team not found (if searching by name)
2018-02-15 23:05:16 +01:00
## Get Team By Id
`GET /api/teams/:id`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ---------- | -------- |
| teams:read | teams:\* |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
GET /api/teams/1 HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{
"id" : 1 ,
"orgId" : 1 ,
"name" : "MyTestTeam" ,
"email" : "" ,
"created" : "2017-12-15T10:40:45+01:00" ,
"updated" : "2017-12-15T10:40:45+01:00"
}
```
Status Codes:
- **200** - Ok
- **401** - Unauthorized
- **403** - Permission denied
- **404** - Team not found
## Add Team
2020-06-05 13:42:53 +08:00
The Team `name` needs to be unique. `name` is required and `email` ,`orgId` is optional.
2018-02-15 23:05:16 +01:00
`POST /api/teams`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ------------ | ----- |
| teams:create | N/A |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
POST /api/teams HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
{
"name" : "MyTestTeam" ,
2020-06-05 13:42:53 +08:00
"email" : "email@test.com" ,
"orgId" : 2
2018-02-15 23:05:16 +01:00
}
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{ "message" : "Team created" , "teamId" : 2 }
```
Status Codes:
- **200** - Ok
- **401** - Unauthorized
- **403** - Permission denied
- **409** - Team name is taken
## Update Team
There are two fields that can be updated for a team: `name` and `email` .
`PUT /api/teams/:id`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ----------- | -------- |
| teams:write | teams:\* |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
PUT /api/teams/2 HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
{
"name" : "MyTestTeam" ,
"email" : "email@test.com"
}
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{ "message" : "Team updated" }
```
2018-02-16 11:18:41 +01:00
Status Codes:
- **200** - Ok
- **401** - Unauthorized
- **403** - Permission denied
- **404** - Team not found
- **409** - Team name is taken
2018-02-15 23:05:16 +01:00
## Delete Team By Id
`DELETE /api/teams/:id`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ------------ | -------- |
| teams:delete | teams:\* |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
DELETE /api/teams/2 HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{ "message" : "Team deleted" }
```
Status Codes:
- **200** - Ok
- **401** - Unauthorized
- **403** - Permission denied
- **404** - Failed to delete Team. ID not found
## Get Team Members
`GET /api/teams/:teamId/members`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ---------------------- | -------- |
| teams.permissions:read | teams:\* |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
GET /api/teams/1/members HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
[
{
"orgId" : 1 ,
"teamId" : 1 ,
"userId" : 3 ,
"email" : "user1@email.com" ,
"login" : "user1" ,
"avatarUrl" : "\/avatar\/1b3c32f6386b0185c40d359cdc733a79"
},
{
"orgId" : 1 ,
"teamId" : 1 ,
"userId" : 2 ,
"email" : "user2@email.com" ,
"login" : "user2" ,
"avatarUrl" : "\/avatar\/cad3c68da76e45d10269e8ef02f8e73e"
}
]
```
Status Codes:
- **200** - Ok
- **401** - Unauthorized
- **403** - Permission denied
## Add Team Member
`POST /api/teams/:teamId/members`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ----------------------- | -------- |
| teams.permissions:write | teams:\* |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
POST /api/teams/1/members HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
{
"userId" : 2
}
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{ "message" : "Member added to Team" }
```
Status Codes:
- **200** - Ok
- **400** - User is already added to this team
- **401** - Unauthorized
- **403** - Permission denied
2018-02-16 11:18:41 +01:00
- **404** - Team not found
2018-02-15 23:05:16 +01:00
## Remove Member From Team
`DELETE /api/teams/:teamId/members/:userId`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ----------------------- | -------- |
| teams.permissions:write | teams:\* |
2018-02-15 23:05:16 +01:00
**Example Request** :
```http
DELETE /api/teams/2/members/3 HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Basic YWRtaW46YWRtaW4=
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{ "message" : "Team Member removed" }
```
Status Codes:
- **200** - Ok
- **401** - Unauthorized
- **403** - Permission denied
2018-02-16 11:18:41 +01:00
- **404** - Team not found/Team member not found
2018-11-14 17:59:32 +01:00
## Get Team Preferences
`GET /api/teams/:teamId/preferences`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ---------- | -------- |
| teams:read | teams:\* |
2018-11-14 17:59:32 +01:00
**Example Request** :
```http
GET /api/teams/2/preferences HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : application/json
{
"theme" : "" ,
"homeDashboardId" : 0 ,
"timezone" : ""
}
```
## Update Team Preferences
`PUT /api/teams/:teamId/preferences`
2022-05-20 21:48:52 +02:00
**Required permissions**
2022-02-11 17:00:13 +00:00
See note in the [introduction ]({{< ref "#team-api" >}} ) for an explanation.
| Action | Scope |
| ----------- | -------- |
| teams:write | teams:\* |
2018-11-14 17:59:32 +01:00
**Example Request** :
```http
PUT /api/teams/2/preferences HTTP / 1.1
Accept : application/json
Content-Type : application/json
Authorization : Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"theme" : "dark" ,
"homeDashboardId" : 39 ,
"timezone" : "utc"
}
```
JSON Body Schema:
2021-08-06 07:52:36 -06:00
- **theme** - One of: `light` , `dark` , or an empty string for the default theme
- **homeDashboardId** - The numerical `:id` of a dashboard, default: `0`
- **timezone** - One of: `utc` , `browser` , or an empty string for the default
2018-11-14 17:59:32 +01:00
Omitting a key will cause the current value to be replaced with the system default value.
**Example Response** :
```http
HTTP / 1.1 200
Content-Type : text/plain; charset=utf-8
{
"message" :"Preferences updated"
}
```